summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.server
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2020-01-09 16:50:13 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2020-01-09 16:52:56 +0100
commitdb019c473edcf8cc96456f8c4ac07e42a7d2eefa (patch)
tree8ae181970f5e5e70ba202e02d3fc78cc9461c869 /org.eclipse.jgit.http.server
parent8e21f0f9c74a374e871557c5698a4bfc56e7c11a (diff)
parentd7304eddaf393375cea93433db182841fd5e08ef (diff)
downloadjgit-db019c473edcf8cc96456f8c4ac07e42a7d2eefa.tar.gz
jgit-db019c473edcf8cc96456f8c4ac07e42a7d2eefa.zip
Merge branch 'stable-5.6'
* stable-5.6: Fix API problem filters Fix unclosed resource warning in SmartOutputStream JschConfigSessionFactory: fix boxing warning SshSupport#runSshCommand: don't throw exception in finally block Don't override already managed maven-compiler-plugin version Remove unused import from CreateFileSnapshotBenchmark Remove duplicate ignore_optional_problems entry in .classpath Update maven-site-plugin used by benchmark module to 3.8.2 Add dependency to enable site generation for benchmark module Ignore warnings for generated source code in org.eclipse.jgit.benchmark Fix MBean registration Enhance WindowCache statistics Change-Id: I4a77c602bfffed60535d0b8fc251a552b128068d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.http.server')
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java31
1 files changed, 16 insertions, 15 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java
index e9a250ecc3..11123d0079 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java
@@ -72,18 +72,16 @@ class SmartOutputStream extends TemporaryBuffer {
// If output hasn't started yet, the entire thing fit into our
// buffer. Try to use a proper Content-Length header, and also
// deflate the response with gzip if it will be smaller.
- @SuppressWarnings("resource")
- TemporaryBuffer out = this;
-
- if (256 < out.length() && acceptsGzipEncoding(req)) {
+ if (256 < this.length() && acceptsGzipEncoding(req)) {
TemporaryBuffer gzbuf = new TemporaryBuffer.Heap(LIMIT);
try {
try (GZIPOutputStream gzip = new GZIPOutputStream(gzbuf)) {
- out.writeTo(gzip, null);
+ this.writeTo(gzip, null);
}
- if (gzbuf.length() < out.length()) {
- out = gzbuf;
+ if (gzbuf.length() < this.length()) {
rsp.setHeader(HDR_CONTENT_ENCODING, ENCODING_GZIP);
+ writeResponse(gzbuf);
+ return;
}
} catch (IOException err) {
// Most likely caused by overflowing the buffer, meaning
@@ -91,15 +89,18 @@ class SmartOutputStream extends TemporaryBuffer {
// copy and use the original.
}
}
+ writeResponse(this);
+ }
+ }
- // The Content-Length cannot overflow when cast to an int, our
- // hardcoded LIMIT constant above assures us we wouldn't store
- // more than 2 GiB of content in memory.
- rsp.setContentLength((int) out.length());
- try (OutputStream os = rsp.getOutputStream()) {
- out.writeTo(os, null);
- os.flush();
- }
+ private void writeResponse(TemporaryBuffer out) throws IOException {
+ // The Content-Length cannot overflow when cast to an int, our
+ // hardcoded LIMIT constant above assures us we wouldn't store
+ // more than 2 GiB of content in memory.
+ rsp.setContentLength((int) out.length());
+ try (OutputStream os = rsp.getOutputStream()) {
+ out.writeTo(os, null);
+ os.flush();
}
}
}