-
Notifications
You must be signed in to change notification settings - Fork 874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent endless recursion, limit traversal depth. #6691
Conversation
1061236
to
f927c8c
Compare
@@ -226,15 +240,13 @@ public NbProjectInfo buildAll() { | |||
// introspection is only allowed for gradle 7.4 and above. | |||
// TODO: investigate if some of the instrospection could be done for earlier Gradles. | |||
sinceGradle("7.0", () -> { | |||
initIntrospection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rearranging exception handling code uncovered an exception from detectTaskProperties
silently ignored in NB19-20. Adding task properties to the conditional block for >= 7.0
@@ -539,19 +553,53 @@ private static boolean isPrimitiveOrString(Class c) { | |||
* @param propertyTypes | |||
* @param defaultValues | |||
*/ | |||
private void startInspectObjectAndValues(Class clazz, Object object, String prefix, Map<String, Map<String, String>> globalTypes, Map<String, String> propertyTypes, Map<String, Object> defaultValues) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just force-reset depth at the start of the inspection (top-level object).
} else { | ||
defaultValues.put(prefix + "." + k, Objects.toString(v)); // NOI18N | ||
} else if (!v.equals(value)) { | ||
defaultValues.put(prefix + "." + k, objectToString(v)); // NOI18N |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toString itself can cause StackOverflow with recursive structures.
@@ -420,10 +454,30 @@ private static GradleReport createReport(Throwable e) { | |||
} else { | |||
reported = e; | |||
} | |||
String cn = e.getClass().getName(); | |||
if (cn.contains("GradleScriptException") || cn.contains("ResolutionException")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are common exception classes for failures reported by the build system itself, mark as 'user' or expected exceptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine.
@lkishalmi do the changes look sane ? I'd merge it in the following days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally fine, just small but important change is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COMPATIBLE_CACHE_VERSION needs to be increased, in order to force reload the info from Gradle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
patched into dd185ef. Thanks.
f927c8c
to
d726811
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Prevents infinite recursion through structures in project model, should fix #6674 and #4779. This is done by:
toString()
calls in try-catch, so potential error (incl. stack overflow) does not abort and just dumps an object placeholder.The other part delivers more error details to NB. Fo unexpected exceptions, stack traces are provided in the
detail
Report field. Reports are marked withseverity
so now the loader can declare unexpected (exception) fatal (error), nonfatal (warning) and info messaes.Unexpected exceptions are presented in project problems with their (truncated to 100 lines) stacktraces. Build system exceptions (i.e. unresolved artifact) should not present stacktraces, but full details from the nested exceptions.
Just error and exception levels pop up project problems window and notifications. Stacktraces are received by NB and can be optionally logged (with appropriate loglevel) - useful for user diagnostic.
I have added a test that a project with Spotbugs plugin loads OK + checks to verify recursive structure avoidance.