Skip to content
Permalink
Browse files
[JENKINS-25735] - Make FindBugs happy & improve diagnostics
  • Loading branch information
oleg-nenashev committed Mar 16, 2017
1 parent 0a73ebe commit 590e5df2b5ddae474d191079e40ae127f3cb984b
Showing with 21 additions and 10 deletions.
  1. +21 −10 src/main/java/com/michelin/cio/hudson/plugins/maskpasswords/MaskPasswordsConfig.java
@@ -181,7 +181,7 @@ public final synchronized void reset() {

// default values for the first time the config is created
addMaskedPasswordParameterDefinition(hudson.model.PasswordParameterDefinition.class.getName());
addMaskedPasswordParameterDefinition(com.michelin.cio.hudson.plugins.passwordparam.PasswordParameterDefinition.class.getName());
addMaskedPasswordParameterDefinition(com.michelin.cio.hudson.plugins.passwordparam.PasswordParameterDefinition.class.getName());
}

public synchronized void clear() {
@@ -420,23 +420,34 @@ public boolean isMasked(final @CheckForNull ParameterValue value,
* @param parameterTypes Parameters
*/
private synchronized void tryProcessMethod(Class<?> clazz, String methodName, boolean expectedToExist, Class<?> ... parameterTypes) {

final Method method;
try {
Method method = clazz.getMethod(methodName, parameterTypes);
Class<?> returnType = method.getReturnType();
method = clazz.getMethod(methodName, parameterTypes);
} catch (NoSuchMethodException ex) {
Level logLevel = expectedToExist ? Level.INFO : Level.CONFIG;
if (LOGGER.isLoggable(logLevel)) {
String methodSpec = String.format("%s(%s)", methodName, StringUtils.join(parameterTypes, ","));
LOGGER.log(logLevel, "No method {0} for class {1}", new Object[] {methodSpec, clazz});
}
return;
} catch (RuntimeException ex) {
Level logLevel = expectedToExist ? Level.INFO : Level.CONFIG;
if (LOGGER.isLoggable(logLevel)) {
String methodSpec = String.format("%s(%s)", methodName, StringUtils.join(parameterTypes, ","));
LOGGER.log(logLevel, "Failed to retrieve the method {0} for class {1}", new Object[] {methodSpec, clazz});
}
return;
}

Class<?> returnType = method.getReturnType();
// We do not veto the the root class
if (ParameterValue.class.isAssignableFrom(returnType)) {
if (!ParameterValue.class.equals(returnType)) {
// Add this class to the cache
paramValueCache_maskedClasses.add(returnType.getName());
}
}
} catch (Exception ex) {
Level logLevel = expectedToExist ? Level.INFO : Level.CONFIG;
if (LOGGER.isLoggable(logLevel)) {
String methodSpec = String.format("%s(%s)", methodName, StringUtils.join(parameterTypes, ","));
LOGGER.log(logLevel, "No method {0} for class {1}", new Object[] {methodSpec, clazz});
}
}
}

/**

0 comments on commit 590e5df

Please sign in to comment.