From f403c4c235a158e2bd21995646fde3267d6231cd Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Tue, 29 Jun 2021 21:19:15 +0200 Subject: [PATCH] Simplify Stacktrace in GCS Streaming Upload Logic Aside from simplifying the code (the close is unnecessary) this change fixes access control checks breaking on Java 8 in 7.x. --- .../repositories/gcs/GoogleCloudStorageBlobStore.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageBlobStore.java b/plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageBlobStore.java index 3a546cdd0f13e..336e1c987fd5b 100644 --- a/plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageBlobStore.java +++ b/plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageBlobStore.java @@ -277,7 +277,7 @@ void writeBlob(String blobName, boolean failIfAlreadyExists, CheckedConsumer client().writer(blobInfo, writeOptions)); - try (OutputStream out = new FilterOutputStream(Channels.newOutputStream(new WritableBlobChannel(writeChannel))) { + writer.accept(new FilterOutputStream(Channels.newOutputStream(new WritableBlobChannel(writeChannel))) { @Override public void write(byte[] b, int off, int len) throws IOException { int written = 0; @@ -289,10 +289,8 @@ public void write(byte[] b, int off, int len) throws IOException { written += toWrite; } } - }) { - writer.accept(out); - SocketAccess.doPrivilegedVoidIOException(writeChannel::close); - } + }); + SocketAccess.doPrivilegedVoidIOException(writeChannel::close); stats.trackPutOperation(); return; } catch (final StorageException se) {