Skip to content

Commit

Permalink
Merge pull request #35 from jglick/no-PickleFactory-JENKINS-26137
Browse files Browse the repository at this point in the history
[JENKINS-26137] Pass pickleFactories directly into the RiverWriter constructor
  • Loading branch information
jglick committed Mar 31, 2017
2 parents 467dd0d + b4c0da2 commit a338977
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.22</version>
<version>2.25</version>
<relativePath />
</parent>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down
Expand Up @@ -27,7 +27,6 @@
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
import org.jenkinsci.plugins.workflow.pickles.Pickle;
import org.jenkinsci.plugins.workflow.pickles.PickleFactory;
import hudson.ExtensionList;
import org.jboss.marshalling.Marshaller;
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.MarshallingConfiguration;
Expand All @@ -44,6 +43,7 @@
import java.io.ObjectOutputStream;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
Expand Down Expand Up @@ -85,12 +85,20 @@ public class RiverWriter implements Closeable {
*/
List<Pickle> pickles = new ArrayList<Pickle>();

// TODO: rename to HibernatingObjectOutputStream?
@Deprecated
public RiverWriter(File f, FlowExecutionOwner _owner) throws IOException {
final ExtensionList<PickleFactory> pickleFactories = PickleFactory.all();
this(f, _owner, pickleFactories());
}

private static Collection<? extends PickleFactory> pickleFactories() {
Collection<? extends PickleFactory> pickleFactories = PickleFactory.all();
if (pickleFactories.isEmpty()) {
throw new IllegalStateException("JENKINS-26137: Jenkins is shutting down");
}
return pickleFactories;
}

public RiverWriter(File f, FlowExecutionOwner _owner, final Collection<? extends PickleFactory> pickleFactories) throws IOException {
file = f;
owner = _owner;
dout = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
Expand Down

0 comments on commit a338977

Please sign in to comment.