Skip to content
Permalink
Browse files
[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 8379c0d2a7c4e36de305db68bc54acc2418b7c47
@@ -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;
@@ -37,7 +36,6 @@

@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");
@@ -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;
@@ -90,17 +91,20 @@
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)) {

0 comments on commit 8379c0d

Please sign in to comment.