Permalink
Browse files

|FIXED JENKINS-9183] Maven3 with multiple threads does not work in Je…

…nkins
  • Loading branch information...
1 parent 9bf6b3e commit 20fe6313c33ba02ce10587d7434fcf106f68030f @olamy olamy committed with kohsuke Apr 19, 2011
Showing with 12 additions and 8 deletions.
  1. +12 −8 maven-plugin/src/main/java/hudson/maven/Maven3Builder.java
View
20 maven-plugin/src/main/java/hudson/maven/Maven3Builder.java
@@ -32,6 +32,7 @@
import hudson.remoting.Channel;
import hudson.remoting.DelegatingCallable;
import hudson.remoting.Future;
+import hudson.util.CopyOnWriteList;
import hudson.util.IOException2;
import java.io.IOException;
@@ -98,7 +99,7 @@ protected Maven3Builder(BuildListener listener,Map<ModuleName,ProxyImpl2> proxie
sourceProxies = new HashMap<ModuleName, ProxyImpl2>(proxies);
this.proxies = new HashMap<ModuleName, MavenBuildProxy2>(proxies);
for (Entry<ModuleName,MavenBuildProxy2> e : this.proxies.entrySet())
- e.setValue(new FilterImpl(e.getValue(), this.mavenBuildInformation));
+ e.setValue(new FilterImpl(e.getValue(), this.mavenBuildInformation,Channel.current()));
this.reporters.putAll( reporters );
}
@@ -107,7 +108,7 @@ public Result call() throws IOException {
MavenExecutionListener mavenExecutionListener = new MavenExecutionListener( this );
try {
- futures = new ArrayList<Future<?>>();
+ futures = new CopyOnWriteArrayList<Future<?>>( );
Maven3Launcher.setMavenExecutionListener( mavenExecutionListener );
@@ -217,15 +218,18 @@ void end(Launcher launcher) throws IOException, InterruptedException {
private class FilterImpl extends MavenBuildProxy2.Filter<MavenBuildProxy2> implements Serializable {
private MavenBuildInformation mavenBuildInformation;
+
+ private Channel channel;
- public FilterImpl(MavenBuildProxy2 core, MavenBuildInformation mavenBuildInformation) {
+ public FilterImpl(MavenBuildProxy2 core, MavenBuildInformation mavenBuildInformation, Channel channel) {
super(core);
this.mavenBuildInformation = mavenBuildInformation;
+ this.channel = channel;
}
@Override
public void executeAsync(final BuildCallable<?,?> program) throws IOException {
- futures.add(Channel.current().callAsync(new AsyncInvoker(core,program)));
+ futures.add(channel.callAsync(new AsyncInvoker(core,program)));
}
private static final long serialVersionUID = 1L;
@@ -251,21 +255,21 @@ public MavenBuildInformation getMavenBuildInformation()
private final Map<ModuleName,List<ExecutedMojo>> executedMojosPerModule = new ConcurrentHashMap<ModuleName, List<ExecutedMojo>>();
- private final Map<ModuleName,List<MavenReporter>> reporters = new HashMap<ModuleName,List<MavenReporter>>();
+ private final Map<ModuleName,List<MavenReporter>> reporters = new ConcurrentHashMap<ModuleName,List<MavenReporter>>();
private final Map<ModuleName, Long> currentMojoStartPerModuleName = new ConcurrentHashMap<ModuleName, Long>();
private ExecutionEventLogger eventLogger;
public MavenExecutionListener(Maven3Builder maven3Builder) {
this.maven3Builder = maven3Builder;
- this.proxies = new HashMap<ModuleName, MavenBuildProxy2>(maven3Builder.proxies);
+ this.proxies = new ConcurrentHashMap<ModuleName, MavenBuildProxy2>(maven3Builder.proxies);
for (Entry<ModuleName,MavenBuildProxy2> e : this.proxies.entrySet())
{
- e.setValue(maven3Builder.new FilterImpl(e.getValue(), maven3Builder.mavenBuildInformation));
+ e.setValue(maven3Builder.new FilterImpl(e.getValue(), maven3Builder.mavenBuildInformation, Channel.current()));
executedMojosPerModule.put( e.getKey(), new CopyOnWriteArrayList<ExecutedMojo>() );
}
- this.reporters.putAll( new HashMap<ModuleName, List<MavenReporter>>(maven3Builder.reporters) );
+ this.reporters.putAll( new ConcurrentHashMap<ModuleName, List<MavenReporter>>(maven3Builder.reporters) );
this.eventLogger = new ExecutionEventLogger( new PrintStreamLogger( maven3Builder.listener.getLogger() ) );
}

0 comments on commit 20fe631

Please sign in to comment.