fix findbugs

This commit is contained in:
Nicolas De Loof 2018-02-05 16:42:16 +01:00 committed by Nicolas De loof
parent bd1b11c8ce
commit 598d9ff96e
5 changed files with 17 additions and 6 deletions

View File

@ -157,15 +157,18 @@ public abstract class BaseConfigurator<T> extends Configurator<T> {
final String name = attribute.getName();
final Object sub = removeIgnoreCase(config, name);
if (sub != null) {
final Class k = attribute.getType();
final Configurator configurator = Configurator.lookup(k);
if (configurator == null) throw new IllegalStateException("No configurator implementation to manage "+k);
if (attribute.isMultiple()) {
List values = new ArrayList<>();
for (Object o : (List) sub) {
Object value = Configurator.lookup(attribute.getType()).configure(o);
Object value = configurator.configure(o);
values.add(value);
}
attribute.setValue(instance, values);
} else {
Object value = Configurator.lookup(attribute.getType()).configure(sub);
Object value = configurator.configure(sub);
attribute.setValue(instance, value);
}
}

View File

@ -236,7 +236,7 @@ public abstract class Configurator<T> implements ExtensionPoint {
public Attribute getAttribute(@Nonnull String name) {
Set<Attribute> attrs = describe();
for (Attribute attr : attrs) {
if (name.equalsIgnoreCase(name)) {
if (attr.name.equalsIgnoreCase(name)) {
return attr;
}
}

View File

@ -79,7 +79,10 @@ public class DataBoundConfigurator extends BaseConfigurator<Object> {
} else {
final Type pt = parameters[i].getParameterizedType();
args[i] = Configurator.lookup(pt != null ? pt : t).configure(value);
final Type k = pt != null ? pt : t;
final Configurator configurator = Configurator.lookup(k);
if (configurator == null) throw new IllegalStateException("No configurator implementation to manage "+k);
args[i] = configurator.configure(value);
}
System.out.println("Setting " + target + "." + names[i] + " = " + value);
} else if (t.isPrimitive()) {

View File

@ -39,7 +39,10 @@ public class ExtensionConfigurator extends BaseConfigurator {
for (Attribute attribute : attributes) {
final String name = attribute.getName();
if (config.containsKey(name)) {
final Object value = Configurator.lookup(attribute.getType()).configure(config.get(name));
final Class k = attribute.getType();
final Configurator configurator = Configurator.lookup(k);
if (configurator == null) throw new IllegalStateException("No configurator implementation to manage "+ k);
final Object value = configurator.configure(config.get(name));
attribute.setValue(o, value);
}
}

View File

@ -69,7 +69,9 @@ public class HeteroDescribableConfigurator extends Configurator<Describable> {
final List<Descriptor> candidates = Jenkins.getInstance().getDescriptorList(target);
Class<? extends Describable> k = findDescribableBySymbol(shortname, candidates);
return (Describable) Configurator.lookup(k).configure(subconfig);
final Configurator configurator = Configurator.lookup(k);
if (configurator == null) throw new IllegalStateException("No configurator implementation to manage "+k);
return (Describable) configurator.configure(subconfig);
}
private Class findDescribableBySymbol(String shortname, List<Descriptor> candidates) {