Skip to content

Commit f50ea6a

Browse files
Simplify Stacktrace in GCS Streaming Upload Logic (elastic#74716)
Aside from simplifying the code (the close is unnecessary) this change fixes access control checks breaking on Java 8 in 7.x.
1 parent 4c43d6c commit f50ea6a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageBlobStore.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ void writeBlob(String blobName, boolean failIfAlreadyExists, CheckedConsumer<Out
277277
for (int retry = 0; retry < 3; ++retry) {
278278
try {
279279
final WriteChannel writeChannel = SocketAccess.doPrivilegedIOException(() -> client().writer(blobInfo, writeOptions));
280-
try (OutputStream out = new FilterOutputStream(Channels.newOutputStream(new WritableBlobChannel(writeChannel))) {
280+
writer.accept(new FilterOutputStream(Channels.newOutputStream(new WritableBlobChannel(writeChannel))) {
281281
@Override
282282
public void write(byte[] b, int off, int len) throws IOException {
283283
int written = 0;
@@ -289,10 +289,8 @@ public void write(byte[] b, int off, int len) throws IOException {
289289
written += toWrite;
290290
}
291291
}
292-
}) {
293-
writer.accept(out);
294-
SocketAccess.doPrivilegedVoidIOException(writeChannel::close);
295-
}
292+
});
293+
SocketAccess.doPrivilegedVoidIOException(writeChannel::close);
296294
stats.trackPutOperation();
297295
return;
298296
} catch (final StorageException se) {

0 commit comments

Comments
 (0)