Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-30055] The listener which closes flow graph log files …
…must receive events immediately, and unregister itself.

Originally-Committed-As: 1084a9bd2495989bb78e013c08c8348542e7955f
  • Loading branch information
jglick committed Sep 25, 2015
1 parent a24ed04 commit 8379c0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Expand Up @@ -27,7 +27,6 @@
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.Rule;
import org.jvnet.hudson.test.Issue;
Expand All @@ -37,7 +36,6 @@ public class ScalabilityTest {

@Rule public JenkinsRule r = new JenkinsRule();

@Ignore("TODO fails w/ various errors incl. IOException: Too many open files")
@Issue("JENKINS-30055")
@Test public void manySteps() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "demo");
Expand Down
Expand Up @@ -38,6 +38,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
Expand Down Expand Up @@ -90,17 +91,20 @@ public abstract class DefaultStepContext extends StepContext {
os = filter.decorateLogger(null, os);
}
listener = new StreamTaskListener(os);
getExecution().addListener(new GraphListener() {
final AtomicReference<GraphListener> graphListener = new AtomicReference<GraphListener>();
graphListener.set(new GraphListener() {
@Override public void onNewHead(FlowNode node) {
try {
if (!getNode().isRunning()) {
getExecution().removeListener(graphListener.get());
listener.getLogger().close();
}
} catch (IOException x) {
Logger.getLogger(DefaultStepContext.class.getName()).log(Level.FINE, null, x);
}
}
});
getExecution().addListener(graphListener.get(), true);
}
return key.cast(listener);
} else if (Node.class.isAssignableFrom(key)) {
Expand Down

0 comments on commit 8379c0d

Please sign in to comment.