Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP2:Update
beust-jcommander.35488
0001-ParseValues-NullPointerException-patch.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-ParseValues-NullPointerException-patch.patch of Package beust-jcommander.35488
From 2b813829d02b89206493520eb86075a43b145db9 Mon Sep 17 00:00:00 2001 From: Roman Vais <rvais@redhat.com> Date: Tue, 13 Jun 2017 13:24:24 +0200 Subject: [PATCH] ParseValues-NullPointerException-patch --- .../java/com/beust/jcommander/Parameterized.java | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/beust/jcommander/Parameterized.java b/src/main/java/com/beust/jcommander/Parameterized.java index 3264008..e937a66 100644 --- a/src/main/java/com/beust/jcommander/Parameterized.java +++ b/src/main/java/com/beust/jcommander/Parameterized.java @@ -13,6 +13,8 @@ import java.lang.reflect.Type; import java.util.Collections; import java.util.List; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Encapsulate a field or a method annotated with @Parameter or @DynamicParameter @@ -180,12 +182,33 @@ public class Parameterized { String fieldName = Character.toLowerCase(name.charAt(3)) + name.substring(4); Object result = null; try { - Field field = method.getDeclaringClass().getDeclaredField(fieldName); + Field field = object.getClass().getDeclaredField(fieldName); if (field != null) { setFieldAccessible(field); result = field.get(object); } - } catch(NoSuchFieldException | IllegalAccessException ex) { + } catch(NoSuchFieldException ex) { + Class<?> clazz = object.getClass(); + Field found = null; + while (clazz != null && method.getDeclaringClass().isAssignableFrom(clazz)) { + try { + found = clazz.getDeclaredField(fieldName); + } catch (NoSuchFieldException nfex) { + // ignore + } + if (found != null) break; + clazz = clazz.getSuperclass(); + } + if (found != null) { + setFieldAccessible(found); + try { + result = found.get(object); + } catch (IllegalAccessException iex) { + // ignore + } + } + + } catch(IllegalAccessException ex) { // ignore } return result; -- 2.7.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor