cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1342531 - in /cxf/branches/2.5.x-fixes: ./ api/src/main/java/org/apache/cxf/message/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/test/java/org/apache/cxf/transport/http/ rt/ws/rm/src/main/java/org...
Date Fri, 25 May 2012 08:52:42 GMT
Author: ay
Date: Fri May 25 08:52:42 2012
New Revision: 1342531

URL: http://svn.apache.org/viewvc?rev=1342531&view=rev
Log:
Merged revisions 1342527 via  svn merge from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1342527 | ay | 2012-05-25 10:35:51 +0200 (Fri, 25 May 2012) | 1 line
  
  [CXF-4248] DocLiteralInInterceptor throws NPE if oneWay operation sends non-empty response
........

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/message/Message.java
    cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/branches/2.5.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
    cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/message/Message.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/message/Message.java?rev=1342531&r1=1342530&r2=1342531&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/message/Message.java (original)
+++ cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/message/Message.java Fri May
25 08:52:42 2012
@@ -69,6 +69,12 @@ public interface Message extends StringM
     String PARTIAL_RESPONSE_MESSAGE = "org.apache.cxf.partial.response";
     String EMPTY_PARTIAL_RESPONSE_MESSAGE = "org.apache.cxf.partial.response.empty";
     String ONE_WAY_REQUEST = "OnewayRequest";
+
+    /**
+     * Boolean property specifying if oneWay response must be processed.
+     */
+    String PROCESS_ONEWAY_REPONSE = "org.apache.cxf.transport.processOneWayResponse";
+    
     
     String ROBUST_ONEWAY = "org.apache.cxf.oneway.robust";
     

Modified: cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=1342531&r1=1342530&r2=1342531&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Fri May 25 08:52:42 2012
@@ -18,7 +18,6 @@
  */
 package org.apache.cxf.transport.http;
 
-
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.io.ByteArrayInputStream;
@@ -1545,6 +1544,15 @@ public class HTTPConduit 
             return exchange != null && exchange.isOneWay();
         }
         
+        private boolean doProcessResponse(Message message) {
+            // 1. Not oneWay
+            if (!isOneway(message.getExchange())) {
+                return true;
+            }
+            // 2. Context property
+            return MessageUtils.getContextualBoolean(message, Message.PROCESS_ONEWAY_REPONSE,
false);
+        }
+
         protected void handleResponseInternal() throws IOException {
             Exchange exchange = outMessage.getExchange();
             int responseCode = connection.getResponseCode();
@@ -1569,7 +1577,7 @@ public class HTTPConduit 
             if (isOneway(exchange) 
                 || HttpURLConnection.HTTP_ACCEPTED == responseCode) {
                 in = ChunkedUtil.getPartialResponse(connection, responseCode);
-                if (in == null) {
+                if ((in == null) || (!doProcessResponse(outMessage))) {
                     // oneway operation or decoupled MEP without 
                     // partial response
                     connection.getInputStream().close();
@@ -1582,6 +1590,9 @@ public class HTTPConduit 
                             cc.handleResponse(null, null);
                         }
                     }
+                    if (in != null) {
+                        in.close();
+                    }
                     return;
                 }
             } else {

Modified: cxf/branches/2.5.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java?rev=1342531&r1=1342530&r2=1342531&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
Fri May 25 08:52:42 2012
@@ -48,7 +48,6 @@ import org.apache.cxf.transport.https.Ht
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
-
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Assert;
@@ -61,7 +60,7 @@ import org.junit.Test;
 public class HTTPConduitURLEasyMockTest extends Assert {
     private static String oldHttpProxyHost;
 
-    private enum ResponseStyle { NONE, BACK_CHANNEL, BACK_CHANNEL_ERROR, DECOUPLED };
+    private enum ResponseStyle { NONE, BACK_CHANNEL, BACK_CHANNEL_ERROR, DECOUPLED, ONEWAY_NONE
};
     private enum ResponseDelimiter { LENGTH, CHUNKED, EOF };
 
     private static final String NOWHERE = "http://nada.nothing.nowhere.null/";
@@ -212,12 +211,13 @@ public class HTTPConduitURLEasyMockTest 
     }
 
     @Test
-    public void testSendOnewayChunkedEmptyPartialResponse() 
+    public void testSendOnewayChunkedEmptyPartialResponseProcessResponse() 
         throws Exception {
         control = EasyMock.createNiceControl();
         HTTPConduit conduit = setUpConduit(true, false);
         Message message = new MessageImpl();
         conduit.prepare(message);
+        message.put(Message.PROCESS_ONEWAY_REPONSE, Boolean.TRUE);
         verifySentMessage(conduit, 
                           message, 
                           ResponseStyle.NONE,
@@ -226,7 +226,23 @@ public class HTTPConduitURLEasyMockTest 
                           "POST");
         finalVerify();
     }
-    
+
+    @Test
+    public void testSendOnewayDoNotProcessResponse() 
+        throws Exception {
+        control = EasyMock.createNiceControl();
+        HTTPConduit conduit = setUpConduit(true, false);
+        Message message = new MessageImpl();
+        conduit.prepare(message);
+        verifySentMessage(conduit, 
+                          message, 
+                          ResponseStyle.ONEWAY_NONE,
+                          ResponseDelimiter.CHUNKED,
+                          true,  // empty response
+                          "POST");
+        finalVerify();
+    }
+
     @Test
     public void testSendTwowayDecoupledEmptyPartialResponse() 
         throws Exception {
@@ -266,9 +282,9 @@ public class HTTPConduitURLEasyMockTest 
         Exchange exchange = control.createMock(Exchange.class);
         message.setExchange(exchange);
         exchange.isOneWay();
-        EasyMock.expectLastCall().andReturn(true);
+        EasyMock.expectLastCall().andReturn(true).anyTimes();
         exchange.isSynchronous();
-        EasyMock.expectLastCall().andReturn(true);
+        EasyMock.expectLastCall().andReturn(true).anyTimes();
         exchange.isEmpty();
         EasyMock.expectLastCall().andReturn(true).anyTimes();
     }
@@ -425,13 +441,13 @@ public class HTTPConduitURLEasyMockTest 
             EasyMock.expectLastCall();
         }
         
-        if (style == ResponseStyle.NONE) {
+        if ((style == ResponseStyle.NONE) || (style == ResponseStyle.ONEWAY_NONE)) {
             setUpOneway(message);
         }
         
         connection.getRequestMethod();
         EasyMock.expectLastCall().andReturn(method).anyTimes();
-        verifyHandleResponse(style, delimiter, conduit);
+        verifyHandleResponse(style, delimiter, emptyResponse, conduit);
 
         control.replay();
         
@@ -439,19 +455,21 @@ public class HTTPConduitURLEasyMockTest 
         wrappedOS.flush();
         wrappedOS.close();
 
-        assertNotNull("expected in message", inMessage);
-        Map<?, ?> headerMap = (Map<?, ?>) inMessage.get(Message.PROTOCOL_HEADERS);
-        assertEquals("unexpected response headers", headerMap.size(), 0);
-        Integer expectedResponseCode = getResponseCode(style);
-        assertEquals("unexpected response code",
-                     expectedResponseCode,
-                     inMessage.get(Message.RESPONSE_CODE));
-        if (!emptyResponse) {
-            assertTrue("unexpected content formats",
-                       inMessage.getContentFormats().contains(InputStream.class));
-            InputStream content = inMessage.getContent(InputStream.class);
-            if (!(content instanceof PushbackInputStream)) {
-                assertSame("unexpected content", is, content);            
+        if (style != ResponseStyle.ONEWAY_NONE) {
+            assertNotNull("expected in message", inMessage);
+            Map<?, ?> headerMap = (Map<?, ?>) inMessage.get(Message.PROTOCOL_HEADERS);
+            assertEquals("unexpected response headers", headerMap.size(), 0);
+            Integer expectedResponseCode = getResponseCode(style);
+            assertEquals("unexpected response code",
+                         expectedResponseCode,
+                         inMessage.get(Message.RESPONSE_CODE));
+            if (!emptyResponse) {
+                assertTrue("unexpected content formats",
+                           inMessage.getContentFormats().contains(InputStream.class));
+                InputStream content = inMessage.getContent(InputStream.class);
+                if (!(content instanceof PushbackInputStream)) {
+                    assertSame("unexpected content", is, content);            
+                }
             }
         }
         
@@ -505,11 +523,6 @@ public class HTTPConduitURLEasyMockTest 
         return wrappedOS;
     }
     
-    private void verifyHandleResponse(ResponseStyle style, ResponseDelimiter delimiter, HTTPConduit
conduit) 
-        throws IOException {
-        verifyHandleResponse(style, delimiter, false, conduit);
-    }
-    
     private void verifyHandleResponse(ResponseStyle style, 
                                       ResponseDelimiter delimiter,
                                       boolean emptyResponse,
@@ -560,7 +573,12 @@ public class HTTPConduitURLEasyMockTest 
         case BACK_CHANNEL_ERROR:
             connection.getErrorStream();
             EasyMock.expectLastCall().andReturn(null);
-            break;    
+            break; 
+            
+        case ONEWAY_NONE:
+            is.close();
+            EasyMock.expectLastCall();
+            break;
             
         default:
             break;

Modified: cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java?rev=1342531&r1=1342530&r2=1342531&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java
Fri May 25 08:52:42 2012
@@ -114,6 +114,11 @@ public class RMOutInterceptor extends Ab
             RMContextUtils.storeRMProperties(msg, rmpsOut, true);
         }
         
+        // Activate process response for oneWay
+        if (msg.getExchange().isOneWay()) {
+            msg.getExchange().put(Message.PROCESS_ONEWAY_REPONSE, true);
+        }
+        
         RMProperties rmpsIn = null;
         Identifier inSeqId = null;
         long inMessageNumber = 0;



Mime
View raw message