You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2009/07/12 19:46:27 UTC
svn commit: r793382 - in /webservices/axis2/trunk/java: ./
modules/adb/src/org/apache/axis2/rpc/receivers/
modules/integration/test/org/apache/axis2/async/
modules/integration/test/org/apache/axis2/engine/
modules/integration/test/org/apache/axis2/jaxr...
Author: gdaniels
Date: Sun Jul 12 17:46:27 2009
New Revision: 793382
URL: http://svn.apache.org/viewvc?rev=793382&view=rev
Log:
Merge over changes to HTTP transport cleanup from the 1.5 branch.
Also a bit of general code cleanup.
Modified:
webservices/axis2/trunk/java/ (props changed)
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncService2Test.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/MultipleInvocationTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jaxrs/TestUtil.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/CallbackReceiver.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
webservices/axis2/trunk/java/modules/transport/http/pom.xml (props changed)
webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java
webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java
Propchange: webservices/axis2/trunk/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jul 12 17:46:27 2009
@@ -1 +1 @@
-/webservices/axis2/branches/java/1_5:745088,749052,749058,751161,751271,760467,765840
+/webservices/axis2/branches/java/1_5:745088,749052,749058,751161,751271,760467,765840,790721
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java Sun Jul 12 17:46:27 2009
@@ -47,7 +47,6 @@
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Collection;
-import java.util.Iterator;
public class RPCUtil {
@@ -169,7 +168,7 @@
IllegalAccessException, InvocationTargetException {
if (inAxisMessage.getElementQName() == null) {
// method accept empty SOAPbody
- return method.invoke(implClass, new Object[0]);
+ return method.invoke(implClass);
} else {
QName elementQName = inAxisMessage.getElementQName();
messageNameSpace = elementQName.getNamespaceURI();
@@ -276,8 +275,8 @@
int size = collection.size();
Object values[] = new Object[size];
int count = 0;
- for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
- values[count] = iterator.next();
+ for (Object aCollection : collection) {
+ values[count] = aCollection;
count++;
}
@@ -330,7 +329,8 @@
* This method is use to to crete the reposne when , the return value is null
*
* @param service Current AxisService
- * @param envelope response enevelop
+ * @param envelope response envelope
+ * @param partName
*/
private static void processNullReturns(AxisService service,
SOAPEnvelope envelope, String partName) {
@@ -419,8 +419,8 @@
int size = collection.size();
Object values[] = new Object[size];
int count = 0;
- for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
- values[count] = iterator.next();
+ for (Object aCollection : collection) {
+ values[count] = aCollection;
count++;
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncService2Test.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncService2Test.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncService2Test.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncService2Test.java Sun Jul 12 17:46:27 2009
@@ -30,8 +30,7 @@
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.client.async.AsyncResult;
-import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.client.async.AxisCallback;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.ServiceContext;
@@ -39,19 +38,18 @@
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.Echo;
import org.apache.axis2.engine.util.TestConstants;
-import org.apache.axis2.integration.TestingUtils;
import org.apache.axis2.integration.UtilServer;
import org.apache.axis2.integration.UtilServerBasedTestCase;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.util.Utils;
import org.apache.axis2.util.threadpool.ThreadPool;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.xml.namespace.QName;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
public class AsyncService2Test extends UtilServerBasedTestCase implements TestConstants {
@@ -61,13 +59,18 @@
EndpointReference targetEPR = new EndpointReference(
"http://127.0.0.1:" + (UtilServer.TESTING_PORT)
// "http://127.0.0.1:" + 5556
- + "/axis2/services/EchoXMLService/echoOMElement");
++ "/axis2/services/EchoXMLService/echoOMElement");
protected AxisConfiguration engineRegistry;
protected MessageContext mc;
protected ServiceContext serviceContext;
protected AxisService service;
- private boolean finish = false;
+ Exception error;
+ // A (synchronized) place to hold the responses
+ final Map<String, String> responses =
+ Collections.synchronizedMap(new HashMap<String, String>());
+
+ protected final String PREFIX_TEXT = "Request number ";
public static Test suite() {
return getTestSetup(new TestSuite(AsyncService2Test.class));
@@ -87,10 +90,8 @@
}
private static final int MILLISECONDS = 1000;
- private static final Integer TIMEOUT = new Integer(
- 200 * MILLISECONDS);
- private int counter = 0;
- private static final int MAX_REQUESTS = 10;
+ private static final Integer TIMEOUT = 200 * MILLISECONDS;
+ private static final int MAX_REQUESTS = 9;
public void testEchoXMLCompleteASyncWithLimitedNumberOfConnections() throws Exception {
AxisService service =
@@ -98,26 +99,10 @@
Echo.class.getName(),
operationName);
- MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
- HttpConnectionManagerParams connectionManagerParams = new HttpConnectionManagerParams();
- // Maximum one socket connection to a specific host
- connectionManagerParams.setDefaultMaxConnectionsPerHost(1);
- connectionManagerParams.setTcpNoDelay(true);
- connectionManagerParams.setStaleCheckingEnabled(true);
- connectionManagerParams.setLinger(0);
- connectionManager.setParams(connectionManagerParams);
-
- HttpClient httpClient = new HttpClient(connectionManager);
-
ConfigurationContext configcontext = UtilServer.createClientConfigurationContext();
// Use max of 3 threads for the async thread pool
configcontext.setThreadPool(new ThreadPool(1, 3));
- configcontext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
- Boolean.TRUE);
- configcontext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT,
- httpClient);
-
OMFactory fac = OMAbstractFactory.getOMFactory();
ServiceClient sender = null;
@@ -133,24 +118,49 @@
options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT);
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIMEOUT);
options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
- Boolean.TRUE);
+ Boolean.TRUE);
options.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION,
- Boolean.TRUE);
+ Boolean.TRUE);
+// options.setProperty(ServiceClient.AUTO_OPERATION_CLEANUP, true);
+ AxisCallback callback = new AxisCallback() {
+
+ public void onMessage(MessageContext msgContext) {
+ final OMElement responseElement =
+ msgContext.getEnvelope().getBody().getFirstElement();
+ assertNotNull(responseElement);
+ String textValue = responseElement.getFirstElement().getText();
+ assertTrue(textValue.startsWith(PREFIX_TEXT));
+ String whichOne = textValue.substring(PREFIX_TEXT.length());
+ assertNull(responses.get(whichOne));
+ responses.put(whichOne, textValue);
+ synchronized (responses) {
+ if (responses.size() == MAX_REQUESTS) {
+ // All done!
+ responses.notifyAll();
+ }
+ }
+ }
+
+ public void onFault(MessageContext msgContext) {
+ // Whoops.
+ synchronized (responses) {
+ if (error != null) return; // Only take first error
+ error = msgContext.getEnvelope().getBody().getFault().getException();
+ responses.notify();
+ }
+ }
- Callback callback = new Callback() {
- public void onComplete(AsyncResult result) {
- TestingUtils.compareWithCreatedOMElement(
- result.getResponseEnvelope().getBody()
- .getFirstElement());
- System.out.println("result = " + result.getResponseEnvelope().getBody()
- .getFirstElement());
- counter++;
+ public void onComplete() {
}
public void onError(Exception e) {
log.info(e.getMessage());
- counter++;
+ synchronized (responses) {
+ if (error != null) return; // Only take first error
+ error = e;
+ responses.notify();
+ }
}
};
@@ -160,20 +170,19 @@
OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
OMElement method = fac.createOMElement("echoOMElement", omNs);
OMElement value = fac.createOMElement("myValue", omNs);
- value.setText("Isaac Asimov, The Foundation Trilogy");
+ value.setText(PREFIX_TEXT + i);
method.addChild(value);
sender.sendReceiveNonBlocking(operationName, method, callback);
- System.out.println("sent the request # : " + i);
+ log.trace("sent the request # : " + i);
}
- System.out.print("waiting");
- int index = 0;
- while (counter < MAX_REQUESTS) {
- System.out.print('.');
- Thread.sleep(1000);
- index++;
- if (index > 60) {
- throw new AxisFault(
- "Server was shutdown as the async response take too long to complete");
+ log.trace("waiting (max 1min)");
+ synchronized (responses) {
+ responses.wait(60 * 1000);
+ // Someone kicked us, so either we have a problem
+ if (responses.size() < MAX_REQUESTS) {
+ if (error != null)
+ throw error;
+ throw new AxisFault("Timeout, did not receive all responses.");
}
}
} finally {
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/MultipleInvocationTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/MultipleInvocationTest.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/MultipleInvocationTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/MultipleInvocationTest.java Sun Jul 12 17:46:27 2009
@@ -78,6 +78,7 @@
options.setTo(targetEPR);
options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ options.setCallTransportCleanup(true);
ConfigurationContext configContext =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jaxrs/TestUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jaxrs/TestUtil.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jaxrs/TestUtil.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jaxrs/TestUtil.java Sun Jul 12 17:46:27 2009
@@ -84,6 +84,7 @@
ArchiveTestOptions=new Options();
ArchiveTestOptions.setTo(new EndpointReference(TestUtil.ToArchiveTestEPR));
ArchiveTestOptions.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
+ ArchiveTestOptions.setCallTransportCleanup(true);
return ArchiveTestOptions;
}
@@ -122,6 +123,7 @@
pojoTestOptions=new Options();
pojoTestOptions.setTo(new EndpointReference(TestUtil.ToPojoTestEPR));
pojoTestOptions.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
+ pojoTestOptions.setCallTransportCleanup(true);
return pojoTestOptions;
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java Sun Jul 12 17:46:27 2009
@@ -134,9 +134,9 @@
XmlSchemaElement xmlSchemaElement = null;
AxisService service = getAxisOperation().getAxisService();
ArrayList schemas = service.getSchema();
- for (Iterator schemaIter = schemas.iterator(); schemaIter.hasNext();){
- xmlSchemaElement = getSchemaElement((XmlSchema) schemaIter.next());
- if (xmlSchemaElement != null){
+ for (Object schema : schemas) {
+ xmlSchemaElement = getSchemaElement((XmlSchema)schema);
+ if (xmlSchemaElement != null) {
break;
}
}
@@ -183,6 +183,7 @@
/**
* This will return a list of WSDLExtensibilityAttribute
+ * @return
*/
public List getExtensibilityAttributes() {
// TODO : Deepal implement this properly.
@@ -250,7 +251,7 @@
}
public Policy calculateEffectivePolicy() {
- PolicySubject policySubject = null;
+ PolicySubject policySubject;
ArrayList<PolicyComponent> policyList = new ArrayList<PolicyComponent>();
// AxisMessage
@@ -309,11 +310,8 @@
// AxisConfiguration
AxisConfiguration axisConfiguration = (axisService == null) ? null
: axisService.getAxisConfiguration();
- if (axisConfiguration != null
- && axisConfiguration.getPolicySubject().getLastUpdatedTime()
- .after(lastPolicyCalcuatedTime)) {
- return true;
- }
- return false;
- }
+ return axisConfiguration != null
+ && axisConfiguration.getPolicySubject().getLastUpdatedTime()
+ .after(lastPolicyCalcuatedTime);
+ }
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java Sun Jul 12 17:46:27 2009
@@ -169,7 +169,7 @@
if (moduleOperations != null) {
Iterator<AxisOperation> moduleOperations_itr = moduleOperations.values().iterator();
while (moduleOperations_itr.hasNext()) {
- AxisOperation operation = (AxisOperation)moduleOperations_itr.next();
+ AxisOperation operation = moduleOperations_itr.next();
service.removeOperation(operation.getName());
}
}
@@ -358,7 +358,7 @@
}
public ModuleConfiguration getModuleConfig(String moduleName) {
- return (ModuleConfiguration)moduleConfigmap.get(moduleName);
+ return moduleConfigmap.get(moduleName);
}
public ArrayList<String> getModuleRefs() {
@@ -486,7 +486,7 @@
result = soapAction;
} else {
if (wsamappingList != null && !wsamappingList.isEmpty()) {
- result = (String)wsamappingList.get(0);
+ result = wsamappingList.get(0);
}
}
return result;
@@ -509,13 +509,13 @@
}
public String getFaultAction(String faultName) {
- return (String)faultActions.get(faultName);
+ return faultActions.get(faultName);
}
public String[] getFaultActionNames() {
Set<String> keys = faultActions.keySet();
String[] faultActionNames = new String[keys.size()];
- faultActionNames = (String[])keys.toArray(faultActionNames);
+ faultActionNames = keys.toArray(faultActionNames);
return faultActionNames;
}
@@ -523,7 +523,7 @@
String result = null;
Iterator<String> iter = faultActions.values().iterator();
if (iter.hasNext()) {
- result = (String)iter.next();
+ result = iter.next();
}
return result;
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java Sun Jul 12 17:46:27 2009
@@ -520,6 +520,8 @@
// method. Have to build the whole envelope including the
// attachments at this stage. Data might get lost if the input
// stream gets closed before building the whole envelope.
+
+ // TODO: Shouldn't need to do this - need to hook up stream closure to Axiom completion
this.envelope = msgContext.getEnvelope();
this.envelope.buildWithAttachments();
}
@@ -530,7 +532,7 @@
* @param msgContext the MessageContext containing the fault.
*/
public void onFault(MessageContext msgContext) {
- error =Utils.getInboundFaultFromMessageContext(msgContext);
+ error = Utils.getInboundFaultFromMessageContext(msgContext);
}
/**
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java Sun Jul 12 17:46:27 2009
@@ -76,6 +76,11 @@
*/
public static SOAPEnvelope createSOAPMessage(MessageContext msgContext,
boolean detach) throws AxisFault {
+// final SOAPEnvelope envelope = msgContext.getEnvelope();
+// if (envelope != null) {
+// if (envelope.isComplete())
+// return envelope;
+// }
try {
InputStream inStream = (InputStream) msgContext
.getProperty(MessageContext.TRANSPORT_IN);
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/CallbackReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/CallbackReceiver.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/CallbackReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/CallbackReceiver.java Sun Jul 12 17:46:27 2009
@@ -66,7 +66,7 @@
* @param callback The callback object.
* @throws AxisFault If the message id was a duplicate.
*/
- private final void putIfAbsent(String msgID, Object callback) throws AxisFault {
+ private void putIfAbsent(String msgID, Object callback) throws AxisFault {
if (callbackStore.putIfAbsent(msgID, callback) == null) {
if (log.isDebugEnabled()) {
log.debug("CallbackReceiver: add callback " + msgID + ", " + callback + " ," + this);
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java Sun Jul 12 17:46:27 2009
@@ -194,6 +194,13 @@
response.addAttachmentPart(ap);
}
}
+
+ try {
+ requestMsgCtx.getTransportOut().getSender().cleanup(requestMsgCtx);
+ } catch (AxisFault axisFault) {
+ // log error
+ }
+
return response;
}
Propchange: webservices/axis2/trunk/java/modules/transport/http/pom.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jul 12 17:46:27 2009
@@ -1 +1,2 @@
-/webservices/axis2/branches/java/1_5/modules/transport/http/pom.xml:765840
+/webservices/axis2/branches/java/1_5/modules/transport/http/pom.xml:765840,790721
+/webservices/axis2/tags/java/v1.5/modules/transport/http/pom.xml:790721
Modified: webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (original)
+++ webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Sun Jul 12 17:46:27 2009
@@ -26,8 +26,10 @@
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.InOutAxisOperation;
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.transport.MessageFormatter;
import org.apache.axis2.transport.OutTransportInfo;
@@ -76,11 +78,14 @@
int connectionTimeout = HTTPConstants.DEFAULT_CONNECTION_TIMEOUT;
public void cleanup(MessageContext msgContext) throws AxisFault {
- HttpMethod httpMethod = (HttpMethod) msgContext
- .getProperty(HTTPConstants.HTTP_METHOD);
+ HttpMethod httpMethod = (HttpMethod) msgContext.getProperty(HTTPConstants.HTTP_METHOD);
if (httpMethod != null) {
+ // TODO : Don't do this if we're not on the right thread! Can we confirm?
+ log.trace("cleanup() releasing connection for " + httpMethod);
+
httpMethod.releaseConnection();
+ msgContext.removeProperty(HTTPConstants.HTTP_METHOD); // guard against multiple calls
}
}
@@ -387,6 +392,14 @@
sender.setHttpVersion(httpVersion);
sender.setFormat(format);
+ final OperationContext opContext = messageContext.getOperationContext();
+ if (opContext.getAxisOperation() instanceof InOutAxisOperation) {
+ // TODO: Kludge to make sure async reply connections get cleaned up. Fix for real?
+
+ // If we're using this sender to send a dual-channel reply, we don't care about
+ // reading the response for now, so make sure we clean up the HTTPMethod.
+ messageContext.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION, true);
+ }
sender.send(messageContext, url, findSOAPAction(messageContext));
} catch (MalformedURLException e) {
log.debug(e);
Modified: webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java Sun Jul 12 17:46:27 2009
@@ -111,6 +111,7 @@
private void cleanup(MessageContext msgContext, HttpMethod method) {
if (msgContext.isPropertyTrue(HTTPConstants.AUTO_RELEASE_CONNECTION)) {
+ log.trace("AutoReleasing " + method);
method.releaseConnection();
}
}
@@ -165,6 +166,9 @@
*/
PostMethod postMethod = new PostMethod();
+ if (log.isTraceEnabled()) {
+ log.trace(Thread.currentThread() + " PostMethod " + postMethod + " / " + httpClient);
+ }
MessageFormatter messageFormatter =
populateCommonProperties(msgContext, url, postMethod, httpClient, soapActionString);
@@ -192,6 +196,11 @@
log.info("Unable to sendViaPost to url[" + url + "]", e);
throw AxisFault.makeFault(e);
} finally {
+ // If we're a dual-channel request, just auto-release the connection so it gets
+ // cleaned up and avoids starvation problems.
+ // TODO: Confirm this is OK with WS-RM, fix if not!
+ if (msgContext.getOptions().isUseSeparateListener())
+ msgContext.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION, true);
cleanup(msgContext, postMethod);
}
}
@@ -259,8 +268,8 @@
*/
private void handleResponse(MessageContext msgContext,
HttpMethodBase method) throws IOException {
-
int statusCode = method.getStatusCode();
+ log.trace("Handling response - " + statusCode);
if (statusCode == HttpStatus.SC_OK) {
processResponse(method, msgContext);
} else if (statusCode == HttpStatus.SC_ACCEPTED) {
Modified: webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java?rev=793382&r1=793381&r2=793382&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java (original)
+++ webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java Sun Jul 12 17:46:27 2009
@@ -59,7 +59,6 @@
final AxisHttpRequest request,
final AxisHttpResponse response,
final MessageContext msgContext) throws HttpException, IOException {
-
ConfigurationContext configurationContext = msgContext.getConfigurationContext();
final String servicePath = configurationContext.getServiceContextPath();
final String contextPath =