mbien commented on code in PR #5270:
URL: https://github.com/apache/netbeans/pull/5270#discussion_r1066613836
##########
extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java:
##########
@@ -380,8 +380,10 @@ private static String getLocation(Throwable
locationAwareEx) {
return (String)locationAccessor.invoke(locationAwareEx);
} catch (ReflectiveOperationException ex) {
LOG.log(Level.FINE,"Error getting location", ex);
- return null;
+ } catch (IllegalArgumentException iae) {
+ LOG.log(Level.FINE,"Trying to get location from an exception, that
has no location property: " + locationAwareEx.getClass().getName());
}
+ return null;
Review Comment:
but doesn't the `Method` field has to fit to the right class? If this method
is supposed to be as generic as possible and work for all exceptions which have
a `getLocation` method, I don't think it should be cached as field. It should
be checked if that exception has `getLocation` on every invocation:
```java
Method locationAccessor =
locationAwareEx.getClass().getMethod("getLocation"); // NOI18N
return (String)locationAccessor.invoke(locationAwareEx);
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists