Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-32331 Using a concurrent map for the setters
  • Loading branch information
dcoraboeuf committed Feb 2, 2016
1 parent f9054f3 commit 8033996
Showing 1 changed file with 4 additions and 5 deletions.
Expand Up @@ -24,7 +24,6 @@
package org.jenkinsci.plugins.tokenmacro;

import com.google.common.collect.ListMultimap;
import hudson.FilePath;
import hudson.model.AbstractBuild;
import hudson.model.TaskListener;
import org.apache.commons.beanutils.ConvertUtils;
Expand All @@ -37,9 +36,9 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
Expand Down Expand Up @@ -93,15 +92,15 @@ private interface Setter {
private synchronized void buildMap() {
if (setters!=null) return;

setters = new HashMap<String, Setter>();
setters = new ConcurrentHashMap<String, Setter>();
for (final Field f : getClass().getFields()) {
final Parameter p = f.getAnnotation(Parameter.class);
if (p !=null) {
String name = f.getName();
if (StringUtils.isNotEmpty(p.alias())) {
name = p.alias();
}

setters.put(name,new Setter() {
public Class<?> getType() {
return f.getType();
Expand Down Expand Up @@ -133,7 +132,7 @@ public boolean required() {
if (name.startsWith("set")) {
name = Introspector.decapitalize(name.substring(3));
}

if (StringUtils.isNotEmpty(p.alias())) {
name = p.alias();
}
Expand Down

0 comments on commit 8033996

Please sign in to comment.