Skip to content

Commit

Permalink
Use simple flush Method in WrappedOutputStream
Browse files Browse the repository at this point in the history
  • Loading branch information
KarstenSchnitter committed Aug 9, 2018
1 parent cc0a54e commit 64ebbbe
Showing 1 changed file with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@

public class WrappedOutputStream extends ServletOutputStream {

private long contentLength = -1;
private final ServletOutputStream wrappedStream;

public WrappedOutputStream(ServletOutputStream out) {
wrappedStream = out;
}

public long getContentLength() {
return contentLength;
}

@Override
public void write(int b) throws IOException {
wrappedStream.write(b);
incrContentLength(1);
}

private void incrContentLength(int i) {
if (contentLength == -1) {
contentLength = i;
} else {
contentLength += i;
}
}
private long contentLength = -1;
private final OutputStream wrappedStream;

public WrappedOutputStream(OutputStream out) {
wrappedStream = out;
}

public long getContentLength() {
return contentLength;
}

@Override
public void write(int b) throws IOException {
wrappedStream.write(b);
incrContentLength(1);
}

private void incrContentLength(int i) {
if (contentLength == -1) {
contentLength = i;
} else {
contentLength += i;
}
}

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

@Override
public void flush() throws IOException {
try (OutputStream ostream = wrappedStream) {
wrappedStream.flush();
}
wrappedStream.flush();
}
}

0 comments on commit 64ebbbe

Please sign in to comment.