diff --git a/src/main/java/hudson/plugins/s3/callable/S3GzipCallable.java b/src/main/java/hudson/plugins/s3/callable/S3GzipCallable.java index 39ede386..16ebe5b8 100644 --- a/src/main/java/hudson/plugins/s3/callable/S3GzipCallable.java +++ b/src/main/java/hudson/plugins/s3/callable/S3GzipCallable.java @@ -66,12 +66,17 @@ public void progressChanged(ProgressEvent event) { } @Override - @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE") + @SuppressFBWarnings({"RV_RETURN_VALUE_IGNORED_BAD_PRACTICE","OBL_UNSATISFIED_OBLIGATION"}) public String invoke(FilePath file) throws IOException, InterruptedException { final File localFile = gzipFile(file); Upload upload = null; - try (final InputStream gzippedStream = new FileInputStream(localFile)) { + try { + // This stream is asynchronously used in startUploading, + // so we cannot use its AutoCloseable behaviour with a + // try-with-resources statement, as that would likely + // close the stream before the upload has succeeded. + final InputStream gzippedStream = new FileInputStream(localFile); final ObjectMetadata metadata = buildMetadata(file); metadata.setContentEncoding("gzip"); metadata.setContentLength(localFile.length());