You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2011/08/14 11:04:33 UTC

svn commit: r1157501 - in /axis/axis2/java/core/trunk/modules: parent/ saaj/ transport/http/ transport/http/src/org/apache/axis2/transport/http/ transport/http/test-resources/ transport/http/test-resources/org/ transport/http/test-resources/org/apache/...

Author: veithen
Date: Sun Aug 14 09:04:32 2011
New Revision: 1157501

URL: http://svn.apache.org/viewvc?rev=1157501&view=rev
Log:
AXIS2-5093: Properly release the HTTP connection if the server response is a 404 or another error where we don't process the response content.

Added:
    axis/axis2/java/core/trunk/modules/transport/http/test/
    axis/axis2/java/core/trunk/modules/transport/http/test-resources/
    axis/axis2/java/core/trunk/modules/transport/http/test-resources/org/
    axis/axis2/java/core/trunk/modules/transport/http/test-resources/org/apache/
    axis/axis2/java/core/trunk/modules/transport/http/test-resources/org/apache/axis2/
    axis/axis2/java/core/trunk/modules/transport/http/test-resources/org/apache/axis2/transport/
    axis/axis2/java/core/trunk/modules/transport/http/test-resources/org/apache/axis2/transport/http/
    axis/axis2/java/core/trunk/modules/transport/http/test-resources/org/apache/axis2/transport/http/axis2.xml   (with props)
    axis/axis2/java/core/trunk/modules/transport/http/test/org/
    axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/
    axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/
    axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/
    axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/
    axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java   (with props)
Modified:
    axis/axis2/java/core/trunk/modules/parent/pom.xml
    axis/axis2/java/core/trunk/modules/saaj/pom.xml
    axis/axis2/java/core/trunk/modules/transport/http/pom.xml
    axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java

Modified: axis/axis2/java/core/trunk/modules/parent/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/parent/pom.xml?rev=1157501&r1=1157500&r2=1157501&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/parent/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/parent/pom.xml Sun Aug 14 09:04:32 2011
@@ -919,6 +919,13 @@
                 <artifactId>commons-cli</artifactId>
                 <version>${commons.cli.version}</version>
             </dependency>
+            
+            <!-- Jetty is used by some of the unit tests -->
+            <dependency>
+                <groupId>jetty</groupId>
+                <artifactId>jetty</artifactId>
+                <version>5.1.10</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 

Modified: axis/axis2/java/core/trunk/modules/saaj/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/saaj/pom.xml?rev=1157501&r1=1157500&r2=1157501&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/saaj/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/saaj/pom.xml Sun Aug 14 09:04:32 2011
@@ -81,7 +81,6 @@
         <dependency>
             <groupId>jetty</groupId>
             <artifactId>jetty</artifactId>
-            <version>5.1.10</version>
             <scope>test</scope>
         </dependency>
         <dependency>

Modified: axis/axis2/java/core/trunk/modules/transport/http/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/pom.xml?rev=1157501&r1=1157500&r2=1157501&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/pom.xml Sun Aug 14 09:04:32 2011
@@ -40,6 +40,11 @@
     <build>
         <sourceDirectory>src</sourceDirectory>
         <testSourceDirectory>test</testSourceDirectory>
+        <testResources>
+            <testResource>
+                <directory>test-resources</directory>
+            </testResource>
+        </testResources>
         <plugins>
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
@@ -100,5 +105,10 @@
             <groupId>org.apache.httpcomponents</groupId>
             <artifactId>httpcore</artifactId>
         </dependency>
+        <dependency>
+            <groupId>jetty</groupId>
+            <artifactId>jetty</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>

Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java?rev=1157501&r1=1157500&r2=1157501&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java Sun Aug 14 09:04:32 2011
@@ -305,6 +305,8 @@ public class HTTPSender extends Abstract
                          method.getStatusText()));
             }
         } else {
+            // Since we don't process the response, we must release the connection immediately
+            method.releaseConnection();
             throw new AxisFault(Messages.getMessage("transportError",
                                                     String.valueOf(statusCode),
                                                     method.getStatusText()));

Added: axis/axis2/java/core/trunk/modules/transport/http/test-resources/org/apache/axis2/transport/http/axis2.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/test-resources/org/apache/axis2/transport/http/axis2.xml?rev=1157501&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/test-resources/org/apache/axis2/transport/http/axis2.xml (added)
+++ axis/axis2/java/core/trunk/modules/transport/http/test-resources/org/apache/axis2/transport/http/axis2.xml Sun Aug 14 09:04:32 2011
@@ -0,0 +1,160 @@
+<?xml version="1.0"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<axisconfig name="AxisJava2.0">
+    <parameter name="hotdeployment">false</parameter>
+    <parameter name="hotupdate">false</parameter>
+    <parameter name="enableMTOM">false</parameter>
+    <parameter name="disableREST">true</parameter>
+    
+    <messageReceivers>
+        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+                         class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+                         class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+        <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
+                         class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+        <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
+                         class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+    </messageReceivers>
+
+    <messageFormatters>
+        <messageFormatter contentType="application/x-www-form-urlencoded"
+                         class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
+        <messageFormatter contentType="multipart/form-data"
+                         class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
+        <messageFormatter contentType="application/xml"
+                         class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
+        <messageFormatter contentType="text/xml"
+                         class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
+        <messageFormatter contentType="application/soap+xml"
+                         class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
+    </messageFormatters>
+
+    <messageBuilders>
+        <messageBuilder contentType="application/xml"
+                         class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
+        <messageBuilder contentType="application/x-www-form-urlencoded"
+                         class="org.apache.axis2.builder.XFormURLEncodedBuilder"/>
+    </messageBuilders>
+
+    <transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+        <parameter name="PROTOCOL">HTTP/1.1</parameter>
+        <parameter name="Transfer-Encoding">chunked</parameter>
+    </transportSender>
+
+    <!-- ================================================= -->
+    <!-- Phases  -->
+    <!-- ================================================= -->
+    <phaseOrder type="InFlow">
+        <!--  System pre-defined phases       -->
+         <phase name="Transport">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
+                <order phase="Transport"/>
+            </handler>
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
+                <order phase="Transport"/>
+            </handler>
+         </phase>
+        <phase name="Addressing">
+            <handler name="AddressingBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
+                <order phase="Addressing"/>
+            </handler>
+        </phase>
+        <phase name="Security"/>
+        <phase name="PreDispatch"/>
+        <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
+            <handler name="RequestURIOperationDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
+            <handler name="SOAPMessageBodyBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
+
+            <handler name="HTTPLocationBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
+        </phase>
+        <!--  System pre defined phases       -->
+        <phase name="RMPhase"/>
+        <phase name="OpPhase"/>
+        <!--   After Postdispatch phase module author or or service author can add any phase he want      -->
+        <phase name="OperationInPhase"/>
+    </phaseOrder>
+    <phaseOrder type="OutFlow">
+        <phase name="RMPhase"/>
+        <phase name="OpPhase"/>
+        <!--      user can add his own phases to this area  -->
+        <phase name="OperationOutPhase"/>
+        <!--system predefined phase-->
+        <!--these phase will run irrespective of the service-->
+        <phase name="PolicyDetermination"/>
+        <phase name="MessageOut"/>
+	    <phase name="Security"/>
+    </phaseOrder>
+    <phaseOrder type="InFaultFlow">
+        <phase name="Transport">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
+                <order phase="Transport"/>
+            </handler>
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
+                <order phase="Transport"/>
+            </handler>
+        </phase>
+        <phase name="Addressing">
+             <handler name="AddressingBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
+                 <order phase="Addressing"/>
+            </handler>
+        </phase>
+        <phase name="Security"/>
+        <phase name="PreDispatch"/>
+        <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
+            <handler name="RequestURIOperationDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
+            <handler name="SOAPMessageBodyBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
+
+            <handler name="HTTPLocationBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
+        </phase>
+        <phase name="RMPhase"/>
+        <phase name="OpPhase"/>
+        <!--      user can add his own phases to this area  -->
+        <phase name="OperationInFaultPhase"/>
+    </phaseOrder>
+    <phaseOrder type="OutFaultFlow">
+        <!--      user can add his own phases to this area  -->
+        <phase name="OperationOutFaultPhase"/>
+        <phase name="RMPhase"/>
+        <phase name="PolicyDetermination"/>
+        <phase name="MessageOut"/>
+        <phase name="Security"/>
+    </phaseOrder>
+</axisconfig>
\ No newline at end of file

Propchange: axis/axis2/java/core/trunk/modules/transport/http/test-resources/org/apache/axis2/transport/http/axis2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java?rev=1157501&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java (added)
+++ axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java Sun Aug 14 09:04:32 2011
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.transport.http;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.junit.Test;
+import org.mortbay.http.SocketListener;
+import org.mortbay.jetty.Server;
+
+public class CommonsHTTPTransportSenderTest {
+    /**
+     * Tests that HTTP connections are properly released when the server returns a 404 error. This
+     * is a regression test for AXIS2-5093.
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void test() throws Exception {
+        // Create a Jetty server instance without any contexts. It will always return HTTP 404.
+        Server server = new Server();
+        SocketListener listener = new SocketListener();
+        server.addListener(listener);
+        server.start();
+        try {
+            ConfigurationContext configurationContext =
+                    ConfigurationContextFactory.createConfigurationContextFromURIs(
+                            CommonsHTTPTransportSenderTest.class.getResource("axis2.xml"), null);
+            ServiceClient serviceClient = new ServiceClient(configurationContext, null);
+            Options options = serviceClient.getOptions();
+            options.setTo(new EndpointReference("http://localhost:" + listener.getPort() + "/nonexisting"));
+            OMElement request = OMAbstractFactory.getOMFactory().createOMElement(new QName("urn:test", "test"));
+            // If connections are not properly released then we will end up with a
+            // ConnectionPoolTimeoutException here.
+            for (int i=0; i<200; i++) {
+                try {
+                    serviceClient.sendReceive(request);
+                } catch (AxisFault ex) {
+                    // Check that this is a 404 error
+                    assertNull(ex.getCause());
+                    assertTrue(ex.getMessage().contains("404"));
+                }
+                serviceClient.cleanupTransport();
+            }
+        } finally {
+            server.stop();
+        }
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native