You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2023/01/12 16:44:34 UTC
[netbeans] branch master updated: Catch IAE when Gradle error getLocation cannot be called.
This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new b1192bacba Catch IAE when Gradle error getLocation cannot be called.
b1192bacba is described below
commit b1192bacba56f3d5c165400f229f0bbc00ce9d92
Author: Laszlo Kishalmi <la...@gmail.com>
AuthorDate: Tue Jan 10 20:45:34 2023 -0800
Catch IAE when Gradle error getLocation cannot be called.
---
.../gradle/loaders/LegacyProjectLoader.java | 26 +++++++---------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java b/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java
index 9406a19764..fcdd052f6b 100644
--- a/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java
+++ b/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java
@@ -362,39 +362,29 @@ public class LegacyProjectLoader extends AbstractProjectLoader {
return Collections.singletonList(createReport(t.getCause()));
}
- /**
- * Accessor for the 'location' property on LocationAwareException
- */
- private static Method locationAccessor;
-
- /**
- * Accessor for the 'lineNumber' property on LocationAwareException
- */
- private static Method lineNumberAccessor;
-
private static String getLocation(Throwable locationAwareEx) {
try {
- if (locationAccessor == null) {
- locationAccessor = locationAwareEx.getClass().getMethod("getLocation"); // NOI18N
- }
+ Method locationAccessor = locationAwareEx.getClass().getMethod("getLocation"); // NOI18N
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, "This probably should not happen: " + locationAwareEx.getClass().getName(), iae);
}
+ return null;
}
private static int getLineNumber(Throwable locationAwareEx) {
try {
- if (lineNumberAccessor == null) {
- lineNumberAccessor = locationAwareEx.getClass().getMethod("getLineNumber"); // NOI18N
- }
+ Method lineNumberAccessor = locationAwareEx.getClass().getMethod("getLineNumber"); // NOI18N
Integer i = (Integer)lineNumberAccessor.invoke(locationAwareEx);
return i != null ? i : -1;
} catch (ReflectiveOperationException ex) {
LOG.log(Level.FINE,"Error getting line number", ex);
- return -1;
+ } catch (IllegalArgumentException iae) {
+ LOG.log(Level.FINE, "This probably should not happen: " + locationAwareEx.getClass().getName(), iae);
}
+ return -1;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists