mbien commented on code in PR #5270:
URL: https://github.com/apache/netbeans/pull/5270#discussion_r1066596122
##########
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:
the problem might be deeper than this. The method accepts throwable but
expects it to be `LocationAwareException`. If someone would call it with the
wrong exception type
```java
if (locationAccessor == null) {
locationAccessor =
locationAwareEx.getClass().getMethod("getLocation"); // NOI18N
}
```
would intitialize the field wrong if it happens to have that method, and all
subsequent calls will fail or do really weird things.
I personally am not a fan of `Throwable` usage, since it is in 99% of all
cases not something you should be catching.
--
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