Skip to content

Commit

Permalink
Ensure a message is logged if we can not create an override (#80)
Browse files Browse the repository at this point in the history
* Ensure a message is logged if we can not create an override

If the first access of the ClassFilter is from a class being auto wired
then the root cause of the Issue can get swallowed and it is not clear in
the logs what is wrong.  So if something goes wrong always log the error
at the expense that it gets logged twice (which is not a bad thing as it
is fatal anyway and will cause Jenkins to pretty much not work at all)

* Move the loading of the pattern override into the try block
  • Loading branch information
jtnord authored and oleg-nenashev committed Jun 9, 2016
1 parent 25373d7 commit f18c44e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/main/java/hudson/remoting/ClassFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,20 @@ public final Class check(Class c) {
* values provide for user specified overrides - see {@link #FILE_OVERRIDE_LOCATION_PROPERTY}.
*/
/*package*/ static ClassFilter createDefaultInstance() {
List<Pattern> patternOverride = loadPatternOverride();
if (patternOverride != null) {
LOGGER.log(Level.FINE, "Using user specified overrides for class blacklisting");
return new RegExpClassFilter(patternOverride);
} else {
LOGGER.log(Level.FINE, "Using default in built class blacklisting");
return new RegExpClassFilter(DEFAULT_PATTERNS);
try {
List<Pattern> patternOverride = loadPatternOverride();
if (patternOverride != null) {
LOGGER.log(Level.FINE, "Using user specified overrides for class blacklisting");
return new RegExpClassFilter(patternOverride);
} else {
LOGGER.log(Level.FINE, "Using default in built class blacklisting");
return new RegExpClassFilter(DEFAULT_PATTERNS);
}
}
catch (Error e) {
// when being used by something like XStream the actual cause gets swallowed
LOGGER.log(Level.SEVERE, "Failed to initialize the default class filter", e);
throw e;
}
}

Expand Down

0 comments on commit f18c44e

Please sign in to comment.