[CXF-7029]HttpAuthenticationFaultHandler cause java.lang.IllegalStateException: 
WRITER


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/cacfe5c3
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/cacfe5c3
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/cacfe5c3

Branch: refs/heads/master-jaxrs-2.1
Commit: cacfe5c39b1c28c61d8a5ccb1754f5b89109c0b7
Parents: 071790c
Author: Freeman Fang <[email protected]>
Authored: Mon Aug 29 18:07:20 2016 +0800
Committer: Freeman Fang <[email protected]>
Committed: Mon Aug 29 18:07:20 2016 +0800

----------------------------------------------------------------------
 .../cxf/transport/http/HttpAuthenticationFaultHandler.java     | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/cacfe5c3/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthenticationFaultHandler.java
----------------------------------------------------------------------
diff --git 
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthenticationFaultHandler.java
 
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthenticationFaultHandler.java
index 3167669..3dc2ac1 100644
--- 
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthenticationFaultHandler.java
+++ 
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthenticationFaultHandler.java
@@ -56,8 +56,9 @@ public class HttpAuthenticationFaultHandler extends 
AbstractPhaseInterceptor<Mes
             resp.setHeader("WWW-Authenticate", authenticationType + " 
realm=\"" + realm + "\"");
             resp.setContentType("text/plain");
             try {
-                resp.getWriter().write(ex.getMessage());
-                resp.getWriter().flush();
+                resp.getOutputStream().write(ex.getMessage().getBytes());
+                resp.getOutputStream().flush();
+                message.getInterceptorChain().setFaultObserver(null); //avoid 
return soap fault
                 message.getInterceptorChain().abort();
             } catch (IOException e) {
                 // TODO
@@ -72,4 +73,5 @@ public class HttpAuthenticationFaultHandler extends 
AbstractPhaseInterceptor<Mes
     public void setRealm(String realm) {
         this.realm = realm;
     }
+    
 }

Reply via email to