2323 */
2424package org .jenkinsci .plugins .docker .workflow ;
2525
26+ import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
2627import hudson .EnvVars ;
28+ import hudson .FilePath ;
2729import java .io .IOException ;
2830import java .util .logging .Level ;
2931import java .util .logging .Logger ;
3032import org .jenkinsci .plugins .docker .commons .credentials .KeyMaterial ;
33+ import org .jenkinsci .plugins .docker .commons .credentials .KeyMaterial2 ;
3134import org .jenkinsci .plugins .docker .commons .credentials .KeyMaterialFactory ;
3235import org .jenkinsci .plugins .workflow .steps .EnvironmentExpander ;
3336import org .jenkinsci .plugins .workflow .steps .GeneralNonBlockingStepExecution ;
@@ -50,19 +53,19 @@ protected AbstractEndpointStepExecution2(StepContext context) {
5053
5154 private void doStart () throws Exception {
5255 KeyMaterialFactory keyMaterialFactory = newKeyMaterialFactory ();
53- KeyMaterial material = keyMaterialFactory .materialize ();
56+ KeyMaterial2 material = keyMaterialFactory .materialize2 ();
5457 getContext ().newBodyInvoker ().
55- withContext (EnvironmentExpander .merge (getContext ().get (EnvironmentExpander .class ), new Expander (material ))).
56- withCallback (new Callback (material )).
58+ withContext (EnvironmentExpander .merge (getContext ().get (EnvironmentExpander .class ), new Expander2 (material ))).
59+ withCallback (new Callback2 (material )).
5760 start ();
5861 }
5962
60- private static class Expander extends EnvironmentExpander {
63+ private static class Expander2 extends EnvironmentExpander {
6164
6265 private static final long serialVersionUID = 1 ;
63- private final KeyMaterial material ;
66+ private final KeyMaterial2 material ;
6467
65- Expander ( KeyMaterial material ) {
68+ Expander2 ( KeyMaterial2 material ) {
6669 this .material = material ;
6770 }
6871
@@ -72,15 +75,53 @@ private static class Expander extends EnvironmentExpander {
7275
7376 }
7477
75- private class Callback extends TailCall {
78+ private class Callback2 extends TailCall {
7679
7780 private static final long serialVersionUID = 1 ;
78- private final KeyMaterial material ;
81+ private final KeyMaterial2 material ;
7982
80- Callback ( KeyMaterial material ) {
83+ Callback2 ( KeyMaterial2 material ) {
8184 this .material = material ;
8285 }
8386
87+ @ Override protected void finished (StepContext context ) throws Exception {
88+ try {
89+ material .close (context .get (FilePath .class ).getChannel ());
90+ } catch (IOException | InterruptedException x ) {
91+ Logger .getLogger (AbstractEndpointStepExecution2 .class .getName ()).log (Level .WARNING , null , x );
92+ }
93+ }
94+
95+ }
96+
97+ @ SuppressFBWarnings (value = {"NP_UNWRITTEN_FIELD" , "UWF_NULL_FIELD" })
98+ @ Deprecated
99+ private static class Expander extends EnvironmentExpander {
100+
101+ private static final long serialVersionUID = 1 ;
102+ private final KeyMaterial material = null ;
103+
104+ private Expander () {
105+ assert false : "only deserialized" ;
106+ }
107+
108+ @ Override public void expand (EnvVars env ) throws IOException , InterruptedException {
109+ env .putAll (material .env ());
110+ }
111+
112+ }
113+
114+ @ SuppressFBWarnings (value = {"NP_UNWRITTEN_FIELD" , "UWF_NULL_FIELD" })
115+ @ Deprecated
116+ private class Callback extends TailCall {
117+
118+ private static final long serialVersionUID = 1 ;
119+ private final KeyMaterial material = null ;
120+
121+ private Callback () {
122+ assert false : "only deserialized" ;
123+ }
124+
84125 @ Override protected void finished (StepContext context ) throws Exception {
85126 try {
86127 material .close ();
0 commit comments