You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by jo...@apache.org on 2008/11/04 07:56:53 UTC
svn commit: r711192 -
/webservices/axis/trunk/java/src/org/apache/axis/client/Call.java
Author: jochen
Date: Mon Nov 3 22:56:52 2008
New Revision: 711192
URL: http://svn.apache.org/viewvc?rev=711192&view=rev
Log:
Temporary files could be deleted too early, preventing their further processing.
PR: AXIS-2574
Submitted-By: Rodrigo Ruiz <rr...@gridsystems.com>
Modified:
webservices/axis/trunk/java/src/org/apache/axis/client/Call.java
Modified: webservices/axis/trunk/java/src/org/apache/axis/client/Call.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/java/src/org/apache/axis/client/Call.java?rev=711192&r1=711191&r2=711192&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/client/Call.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/client/Call.java Mon Nov 3 22:56:52 2008
@@ -62,6 +62,7 @@
import org.apache.axis.wsdl.toJava.Utils;
import org.apache.commons.logging.Log;
+import javax.activation.DataHandler;
import javax.wsdl.Binding;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
@@ -78,6 +79,7 @@
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.ParameterMode;
+import javax.xml.soap.AttachmentPart;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
@@ -85,6 +87,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
@@ -2663,6 +2666,7 @@
} else {
outParams.put(param.getQName(), value);
outParamsList.add(value);
+ cacheIfAttachment(value);
}
}
@@ -2714,11 +2718,37 @@
if (operation != null && operation.getReturnClass() != null) {
result = JavaUtils.convert(result, operation.getReturnClass());
}
+ cacheIfAttachment(result);
return( result );
}
/**
+ * Prevents Call instances from being garbage collected until all outputs
+ * (parameters and return value) of type "attachment" are finalised.
+ * <p>
+ * See JIRA report AXIS-2574.
+ */
+ private static Map callCache = Collections.synchronizedMap(new WeakHashMap());
+
+ /**
+ * Puts a reference to this Call instance in a cache if the passed
+ * object is an attachment AND depends on a file.
+ * <p>
+ * See JIRA report AXIS 2574.
+ *
+ * @param obj The object to test
+ */
+ private void cacheIfAttachment(Object obj) {
+ if (obj == null) return;
+ if (obj instanceof DataHandler
+ || obj instanceof AttachmentPart
+ || obj instanceof javax.xml.transform.Source) {
+ callCache.put(obj, this);
+ }
+ }
+
+ /**
* Get the javaType for a given parameter.
*
* @param name the QName of the parameter