Skip to content

Commit d663fc5

Browse files
AXIS2-6030 Axis2 connections are not returned to connection pool on 1.8.0 with JAXWS
1 parent 23ec15f commit d663fc5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,16 @@
5858
import jakarta.xml.ws.WebServiceException;
5959
import jakarta.xml.ws.WebServiceFeature;
6060
import jakarta.xml.ws.soap.SOAPBinding;
61+
import java.io.InputStream;
6162
import java.lang.reflect.InvocationHandler;
6263
import java.lang.reflect.Method;
6364
import java.lang.reflect.Modifier;
6465
import java.security.PrivilegedActionException;
6566
import java.security.PrivilegedExceptionAction;
6667
import java.util.concurrent.ExecutorService;
6768
import java.util.concurrent.Future;
69+
import java.util.Iterator;
70+
import java.util.Map;
6871

6972
/**
7073
* ProxyHandler is the java.lang.reflect.InvocationHandler implementation. When a JAX-WS client
@@ -567,13 +570,36 @@ protected Object createResponse(Method method, Object[] args, MessageContext res
567570
// Free incoming stream
568571
try {
569572
responseContext.freeInputStream();
573+
closeInputStream(responseContext);
570574
}
571575
catch (Throwable t) {
572576
throw ExceptionFactory.makeWebServiceException(t);
573577
}
574578
}
575579
}
576580

581+
private void closeInputStream(MessageContext responseContext) {
582+
// accessing the input stream is not possible via get
583+
// workaround using entry set
584+
Iterator var2 = responseContext.getMEPContext().entrySet().iterator();
585+
586+
while(var2.hasNext()) {
587+
Object entry = var2.next();
588+
if (entry instanceof Map.Entry && "TRANSPORT_IN".equals(((Map.Entry)entry).getKey())) {
589+
Object prop = ((Map.Entry)entry).getValue();
590+
if (prop instanceof InputStream) {
591+
try {
592+
InputStream inputStream = (InputStream)prop;
593+
inputStream.close();
594+
} catch (Exception var6) {
595+
log.error(var6.getMessage(), var6);
596+
}
597+
}
598+
break;
599+
}
600+
}
601+
}
602+
577603
protected static Throwable getFaultResponse(MessageContext msgCtx,
578604
OperationDescription opDesc) {
579605
Message msg = msgCtx.getMessage();

0 commit comments

Comments
 (0)