Skip to content
Permalink
Browse files
[FIXED JENKINS-26030] Close logger streams after the owning node fini…
…shes, so we do not leak file handles.

Originally-Committed-As: 7608ed3dc3c77fbfd946697869d4e669c1fc334b
  • Loading branch information
jglick committed Dec 11, 2014
1 parent 663339f commit d054b77128dcf8e83563271bc216edabcf493c4c
@@ -36,11 +36,14 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import jenkins.model.CoreEnvironmentContributor;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.flow.GraphListener;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.steps.StepContext;
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction;
@@ -83,6 +86,17 @@
}

listener = new StreamTaskListener(new FileOutputStream(la.getLogFile(), true));
getExecution().addListener(new GraphListener() {
@Override public void onNewHead(FlowNode node) {
try {
if (!getNode().isRunning()) {
listener.getLogger().close();
}
} catch (IOException x) {
Logger.getLogger(DefaultStepContext.class.getName()).log(Level.FINE, null, x);
}
}
});
}
return key.cast(listener);
} else if (Node.class.isAssignableFrom(key)) {

0 comments on commit d054b77

Please sign in to comment.