dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28486
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14224: return null on invokeMethod if mod is either protected or private (we might force visibility later)
------------------------------------------------------------
revno: 14224
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-03-14 11:56:43 +0100
message:
return null on invokeMethod if mod is either protected or private (we might force visibility later)
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java 2014-03-14 10:40:06 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java 2014-03-14 10:56:43 +0000
@@ -38,6 +38,7 @@
import org.hisp.dhis.system.util.ReflectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -145,6 +146,7 @@
Map value = fieldMap.get( key );
ReflectionUtils.PropertyDescriptor descriptor = classMap.get( key );
+
Object returned = ReflectionUtils.invokeMethod( object, descriptor.getMethod() );
if ( returned == null )
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java 2014-03-13 14:27:16 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java 2014-03-14 10:56:43 +0000
@@ -404,9 +404,14 @@
return methods;
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public static <T> T invokeMethod( Object target, Method method, Object... args )
{
+ if ( Modifier.isProtected( method.getModifiers() ) || Modifier.isPrivate( method.getModifiers() ) )
+ {
+ return null;
+ }
+
try
{
return (T) method.invoke( target, args );
@@ -421,7 +426,7 @@
}
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public static <T> T getFieldObject( Field field, T target )
{
return (T) invokeGetterMethod( field.getName(), target );