Skip to content

Commit 64ebbbe

Browse files
Use simple flush Method in WrappedOutputStream
1 parent cc0a54e commit 64ebbbe

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

cf-java-logging-support-servlet/src/main/java/com/sap/hcp/cf/logging/servlet/filter/WrappedOutputStream.java

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,30 @@
77

88
public class WrappedOutputStream extends ServletOutputStream {
99

10-
private long contentLength = -1;
11-
private final ServletOutputStream wrappedStream;
12-
13-
public WrappedOutputStream(ServletOutputStream out) {
14-
wrappedStream = out;
15-
}
16-
17-
public long getContentLength() {
18-
return contentLength;
19-
}
20-
21-
@Override
22-
public void write(int b) throws IOException {
23-
wrappedStream.write(b);
24-
incrContentLength(1);
25-
}
26-
27-
private void incrContentLength(int i) {
28-
if (contentLength == -1) {
29-
contentLength = i;
30-
} else {
31-
contentLength += i;
32-
}
33-
}
10+
private long contentLength = -1;
11+
private final OutputStream wrappedStream;
12+
13+
public WrappedOutputStream(OutputStream out) {
14+
wrappedStream = out;
15+
}
16+
17+
public long getContentLength() {
18+
return contentLength;
19+
}
20+
21+
@Override
22+
public void write(int b) throws IOException {
23+
wrappedStream.write(b);
24+
incrContentLength(1);
25+
}
26+
27+
private void incrContentLength(int i) {
28+
if (contentLength == -1) {
29+
contentLength = i;
30+
} else {
31+
contentLength += i;
32+
}
33+
}
3434

3535
@Override
3636
public void write(byte[] b) throws IOException {
@@ -51,8 +51,6 @@ public void close() throws IOException {
5151

5252
@Override
5353
public void flush() throws IOException {
54-
try (OutputStream ostream = wrappedStream) {
55-
wrappedStream.flush();
56-
}
54+
wrappedStream.flush();
5755
}
5856
}

0 commit comments

Comments
 (0)