From 2fa9516d86dda01792ff5ce0d7c7776771b220da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 2 Oct 2023 06:44:27 +0200 Subject: [PATCH] Use local variable instead of a field for contentCompressionEnabled Using a field for contentCompressionEnabled is not required as all data is only accessed locally. Using a local variable makes the code better readable and prevents any problems with possibly concurrent access. Beside that it should be q tiny bit more performant. --- .../httpclientjava/HttpClientRetrieveFileTransfer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclientjava/src/org/eclipse/ecf/provider/filetransfer/httpclientjava/HttpClientRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclientjava/src/org/eclipse/ecf/provider/filetransfer/httpclientjava/HttpClientRetrieveFileTransfer.java index 301221c59..3a04e9243 100644 --- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclientjava/src/org/eclipse/ecf/provider/filetransfer/httpclientjava/HttpClientRetrieveFileTransfer.java +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclientjava/src/org/eclipse/ecf/provider/filetransfer/httpclientjava/HttpClientRetrieveFileTransfer.java @@ -139,8 +139,6 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer private FileTransferJob connectJob; - private boolean contentCompressionEnabled; - private HttpRequest httpRequest; public HttpClientRetrieveFileTransfer(HttpClient client) { @@ -547,14 +545,17 @@ protected void openStreams() throws IncomingFileTransferException { // Set request header for possible gzip encoding, but only if // 1) The file range specification is null (we want the whole file) // 2) The target remote file does *not* end in .gz (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=280205) + boolean contentCompressionEnabled; if (getFileRangeSpecification() == null && !targetHasGzSuffix(super.getRemoteFileName())) { // The interceptors to provide gzip are always added and are enabled by default Trace.trace(Activator.PLUGIN_ID, "Accept-Encoding: gzip,deflate added to request header"); //$NON-NLS-1$ setContentCompressionEnabled(rcfgBuilder, true); + contentCompressionEnabled = true; } else { // Disable the interceptors to provide gzip Trace.trace(Activator.PLUGIN_ID, "Accept-Encoding NOT added to header"); //$NON-NLS-1$ setContentCompressionEnabled(rcfgBuilder, false); + contentCompressionEnabled = false; } httpRequest = rcfgBuilder.build(); @@ -647,7 +648,6 @@ private void consume(CompletableFuture> httpResponse) } private void setContentCompressionEnabled(Builder builder, boolean value) { - this.contentCompressionEnabled = value; if (value) { builder.setHeader(ACCEPT_ENCODING_HEADER, GZIP_ENCODING); } else {