Skip to content

Commit 01b0b98

Browse files
committed
Fix potential ClassNotFoundException in ContainerExecCallback
Add back `ContainerExecCallback` to prevent potential `ClassNotFoundException`. The class was removed in #1698 to and moved to the `Resources` class. fixes: JENKINS-75720
1 parent a0283de commit 01b0b98

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerStepExecution.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
import hudson.slaves.NodeProperty;
1313
import hudson.slaves.NodePropertyDescriptor;
1414
import hudson.util.DescribableList;
15+
16+
import java.io.Closeable;
1517
import java.util.Collections;
1618
import java.util.List;
1719
import java.util.logging.Level;
1820
import java.util.logging.Logger;
1921
import jenkins.model.Jenkins;
22+
import org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback;
2023
import org.jenkinsci.plugins.workflow.steps.BodyInvoker;
2124
import org.jenkinsci.plugins.workflow.steps.EnvironmentExpander;
2225
import org.jenkinsci.plugins.workflow.steps.StepContext;
@@ -89,4 +92,27 @@ public void stop(@NonNull Throwable cause) throws Exception {
8992
LOGGER.log(Level.FINE, "Stopping container step.");
9093
closeQuietly(getContext(), decorator);
9194
}
95+
96+
/**
97+
* This class has been replaced but is not deleted to prevent {@code ClassNotFoundException}.
98+
* See <a href="https://issues.jenkins.io/browse/JENKINS-75720">JENKINS-75720</a>
99+
* @deprecated replaced {@link Resources#closeQuietlyCallback(Closeable...)}
100+
*/
101+
@Deprecated
102+
@SuppressFBWarnings("SE_BAD_FIELD")
103+
private static class ContainerExecCallback extends BodyExecutionCallback.TailCall {
104+
105+
private static final long serialVersionUID = 6385838254761750483L;
106+
107+
private final Closeable[] closeables;
108+
109+
private ContainerExecCallback(Closeable... closeables) {
110+
this.closeables = closeables;
111+
}
112+
113+
@Override
114+
public void finished(StepContext context) {
115+
closeQuietly(context, closeables);
116+
}
117+
}
92118
}

0 commit comments

Comments
 (0)