sonatype-lift[bot] commented on a change in pull request #1674:
URL: https://github.com/apache/groovy/pull/1674#discussion_r785487229
##########
File path: src/main/java/groovy/lang/MetaClassImpl.java
##########
@@ -1959,100 +1959,105 @@ public void setProperties(Object bean, Map map) {
* @return the given property's value on the object
*/
@Override
- public Object getProperty(Class sender, Object object, String name,
boolean useSuper, boolean fromInsideClass) {
+ public Object getProperty(final Class sender, final Object object, final
String name, final boolean useSuper, final boolean fromInsideClass) {
//----------------------------------------------------------------------
// handling of static
//----------------------------------------------------------------------
- boolean isStatic = theClass != Class.class && object instanceof Class;
+ boolean isStatic = (theClass != Class.class && object instanceof
Class);
if (isStatic && object != theClass) {
- MetaClass mc = registry.getMetaClass((Class) object);
+ MetaClass mc = registry.getMetaClass((Class<?>) object);
return mc.getProperty(sender, object, name, useSuper, false);
}
checkInitalised();
//----------------------------------------------------------------------
- // turn getProperty on a Map to get on the Map itself
+ // getter
//----------------------------------------------------------------------
- if (!isStatic && this.isMap) {
- return ((Map) object).get(name);
- }
-
Tuple2<MetaMethod, MetaProperty> methodAndProperty =
createMetaMethodAndMetaProperty(sender, sender, name, useSuper, isStatic);
MetaMethod method = methodAndProperty.getV1();
-
//----------------------------------------------------------------------
- // getter
-
//----------------------------------------------------------------------
- MetaProperty mp = methodAndProperty.getV2();
+ if (method == null || isSpecialProperty(name)) {
+
//------------------------------------------------------------------
+ // public field
+
//------------------------------------------------------------------
+ MetaProperty mp = methodAndProperty.getV2();
+ if (mp != null && Modifier.isPublic(mp.getModifiers())) {
+ try {
+ return mp.getProperty(object);
+ } catch (IllegalArgumentException |
CacheAccessControlException e) {
+ // can't access the field directly but there may be a
getter
+ mp = null;
+ }
+ }
-
//----------------------------------------------------------------------
- // field
-
//----------------------------------------------------------------------
- if (method == null && mp != null) {
- try {
- return mp.getProperty(object);
- } catch (IllegalArgumentException | CacheAccessControlException e)
{
- // can't access the field directly but there may be a getter
- mp = null;
+
//------------------------------------------------------------------
+ // java.util.Map get method
+
//------------------------------------------------------------------
+ if (isMap && !isStatic) {
+ return ((Map<?,?>) object).get(name);
}
- }
- // check for propertyMissing provided through a category
- Object[] arguments = EMPTY_ARGUMENTS;
- if (method == null && !useSuper && !isStatic &&
GroovyCategorySupport.hasCategoryInCurrentThread()) {
- method = getCategoryMethodGetter(sender, PROPERTY_MISSING, true);
- if (method != null) arguments = new Object[]{name};
+
//------------------------------------------------------------------
+ // non-public field
+
//------------------------------------------------------------------
+ if (mp != null) {
+ try {
+ return mp.getProperty(object);
+ } catch (IllegalArgumentException |
CacheAccessControlException e) {
Review comment:
*EmptyCatch:* Caught exceptions should not be ignored
[(details)](https://google.github.io/styleguide/javaguide.html#s6.2-caught-exceptions)
(at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with
`help` or `ignore`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]