Repository: cxf Updated Branches: refs/heads/3.1.x-fixes 4744117f9 -> efac3c9e5
Fix checkstyle Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/efac3c9e Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/efac3c9e Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/efac3c9e Branch: refs/heads/3.1.x-fixes Commit: efac3c9e56559370e2d8c8733f7886f83662b4e4 Parents: 4744117 Author: Daniel Kulp <[email protected]> Authored: Fri Nov 13 12:20:34 2015 -0500 Committer: Daniel Kulp <[email protected]> Committed: Fri Nov 13 12:21:07 2015 -0500 ---------------------------------------------------------------------- .../atmosphere/DefaultProtocolInterceptor.java | 93 +++++++++++--------- 1 file changed, 52 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/efac3c9e/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/atmosphere/DefaultProtocolInterceptor.java ---------------------------------------------------------------------- diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/atmosphere/DefaultProtocolInterceptor.java b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/atmosphere/DefaultProtocolInterceptor.java index 54431ce..3dde4b5 100644 --- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/atmosphere/DefaultProtocolInterceptor.java +++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/atmosphere/DefaultProtocolInterceptor.java @@ -298,49 +298,60 @@ public class DefaultProtocolInterceptor extends AtmosphereInterceptorAdapter { @Override public ServletOutputStream getOutputStream() throws IOException { if (sout == null) { - sout = new ServletOutputStream() { - CachedOutputStream out = new CachedOutputStream(); - OutputStream getOut() { - if (out == null) { - out = new CachedOutputStream(); - } - return out; - } - void send(boolean complete) throws IOException { - if (out == null) { - return; - } - if (response.getStatus() >= 400) { - int i = response.getStatus(); - response.setStatus(200); - response.addIntHeader(WebSocketUtils.SC_KEY, i); - } - out.flush(); - out.lockOutputStream(); - out.writeCacheTo(delegate); - delegate.flush(); - out.close(); - out = null; - } - public void write(int i) throws IOException { - getOut().write(i); - } - public void close() throws IOException { - send(true); - delegate.close(); - } - public void flush() throws IOException { - send(false); - } - public void write(byte[] b, int off, int len) throws IOException { - getOut().write(b, off, len); - } - public void write(byte[] b) throws IOException { - getOut().write(b); - } - }; + sout = new BufferedServletOutputStream(); } return sout; } + + private final class BufferedServletOutputStream extends ServletOutputStream { + CachedOutputStream out = new CachedOutputStream(); + + OutputStream getOut() { + if (out == null) { + out = new CachedOutputStream(); + } + return out; + } + + void send(boolean complete) throws IOException { + if (out == null) { + return; + } + if (response.getStatus() >= 400) { + int i = response.getStatus(); + response.setStatus(200); + response.addIntHeader(WebSocketUtils.SC_KEY, i); + } + out.flush(); + out.lockOutputStream(); + out.writeCacheTo(delegate); + delegate.flush(); + out.close(); + out = null; + } + + public void write(int i) throws IOException { + getOut().write(i); + } + + public void close() throws IOException { + send(true); + delegate.close(); + } + + public void flush() throws IOException { + send(false); + } + + public void write(byte[] b, int off, int len) throws IOException { + getOut().write(b, off, len); + } + + public void write(byte[] b) throws IOException { + getOut().write(b); + } + } + + } }
