Skip to content

Commit

Permalink
NPE in WithMavenStepExecutionCallBack.finished (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick authored Aug 7, 2023
1 parent 90f1b24 commit 9ef317a
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import hudson.Functions;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -1107,21 +1108,26 @@ private WithMavenStepExecutionCallBack(@NonNull FilePath tempBinDir, @NonNull Li

@Override
protected void finished(StepContext context) throws Exception {
TaskListener listener = context.get(TaskListener.class);
if (tempBinDir == null) { // normal case
tempBinDir = context.get(FilePath.class).child(tempBinDirPath);
FilePath ws = context.get(FilePath.class);
if (ws == null) {
listener.getLogger().println("Missing agent to clean up " + tempBinDirPath);
return;
}
tempBinDir = ws.child(tempBinDirPath);
} // else resuming old build

mavenSpyLogProcessor.processMavenSpyLogs(context, tempBinDir, options, mavenPublisherStrategy);

try {
tempBinDir.deleteRecursive();
} catch (IOException | InterruptedException e) {
BuildListener listener = context.get(BuildListener.class);
try {
if (e instanceof IOException) {
Util.displayIOException((IOException) e, listener); // Better IOException display on windows
}
e.printStackTrace(listener.fatalError("Error deleting temporary files"));
Functions.printStackTrace(e, listener.fatalError("Error deleting temporary files"));
} catch (Throwable t) {
t.printStackTrace();
}
Expand Down

0 comments on commit 9ef317a

Please sign in to comment.