Prevent hanging when deleting Docker builder container after exception
An exception being thrown while the Maven plugin is uploading the app archive bits to an ephemeral builder container would leave the interaction with the Docker daemon in a state that caused further interaction with the daemon (such as deleting the ephemeral builder) to hang indefinitely. This commit cleans up the connection on an exception to prevent this condition. Fixes gh-27515
This commit is contained in:
@@ -390,7 +390,13 @@ public class BuildImageMojo extends AbstractPackagerMojo {
|
||||
public void writeTo(OutputStream outputStream) throws IOException {
|
||||
TarArchiveOutputStream tar = new TarArchiveOutputStream(outputStream);
|
||||
tar.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
|
||||
this.packager.packageImage(this.libraries, (entry, entryWriter) -> write(entry, entryWriter, tar));
|
||||
try {
|
||||
this.packager.packageImage(this.libraries, (entry, entryWriter) -> write(entry, entryWriter, tar));
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
outputStream.close();
|
||||
throw new RuntimeException("Error packaging archive for image", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void write(ZipEntry jarEntry, EntryWriter entryWriter, TarArchiveOutputStream tar) {
|
||||
|
||||
Reference in New Issue
Block a user