axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@apache.org
Subject svn commit: r380137 - in /webservices/axis/trunk/c: include/axis/ src/common/ src/soap/ src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/
Date Thu, 23 Feb 2006 15:07:02 GMT
Author: dicka
Date: Thu Feb 23 07:06:59 2006
New Revision: 380137

URL: http://svn.apache.org/viewcvs?rev=380137&view=rev
Log:
AXISCPP-937

Resolve problem of leaking Array objects in server.

I have introduced an additional clone method on Axis_Array (and generated derivatives) which
returns a new copy of the current array object (using a deep copy).  The SoapSerializer then
uses this to take a complete copy of the array, which it can manage independently from the
user application.

The generated service wrapper now deletes the array handed into the serializer (which now
takes a copy of it) before returning control to the engine.

Modified:
    webservices/axis/trunk/c/include/axis/AxisUserAPI.hpp
    webservices/axis/trunk/c/src/common/AxisUserAPI.cpp
    webservices/axis/trunk/c/src/soap/SoapSerializer.cpp
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ArrayParamHeaderWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ArrayParamWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/WrapWriter.java

Modified: webservices/axis/trunk/c/include/axis/AxisUserAPI.hpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/include/axis/AxisUserAPI.hpp?rev=380137&r1=380136&r2=380137&view=diff
==============================================================================
--- webservices/axis/trunk/c/include/axis/AxisUserAPI.hpp (original)
+++ webservices/axis/trunk/c/include/axis/AxisUserAPI.hpp Thu Feb 23 07:06:59 2006
@@ -435,6 +435,13 @@
      * @param original array to be cloned into this array.
      */
     void clone(const Axis_Array & original);
+
+    /**
+     * Create a new clone of the current Axis_Array
+     * @return New clone of the current Axis_Array.
+     */
+    virtual Axis_Array * clone() const;
+
     
     /**
      * Populate from a c-style array.

Modified: webservices/axis/trunk/c/src/common/AxisUserAPI.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/common/AxisUserAPI.cpp?rev=380137&r1=380136&r2=380137&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/common/AxisUserAPI.cpp (original)
+++ webservices/axis/trunk/c/src/common/AxisUserAPI.cpp Thu Feb 23 07:06:59 2006
@@ -183,6 +183,11 @@
 {
     set(original.m_Array, original.m_Size, original.m_Type);
 }
+
+Axis_Array * Axis_Array::clone() const
+{
+    return new Axis_Array(*this);
+}
  
 void Axis_Array::set(void** array, int size, XSDTYPE type)
 {

Modified: webservices/axis/trunk/c/src/soap/SoapSerializer.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/soap/SoapSerializer.cpp?rev=380137&r1=380136&r2=380137&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/soap/SoapSerializer.cpp (original)
+++ webservices/axis/trunk/c/src/soap/SoapSerializer.cpp Thu Feb 23 07:06:59 2006
@@ -152,9 +152,22 @@
 {
 	int	iSuccess = AXIS_SUCCESS;
 
-    ArrayBean * pAb = makeArrayBean( nType, (void**) (pArray->m_Array));
+    Axis_Array * pLocalArray = pArray->clone();
+
+    ArrayBean * pAb = makeArrayBean( nType, (void**) (pLocalArray->m_Array));
+
+    pAb->SetDimension(pLocalArray->m_Size);
+
+    /*
+     * We're now finished with the local array object, so it can be deleted
+     * However, we need to de-couple from the internal array, which is now owned
+     * by the ArrayBean.
+     */
+    pLocalArray->m_Array = NULL;
+    pLocalArray->m_Size = 0;
+    delete pLocalArray;
+    pLocalArray = NULL;
 
-    pAb->SetDimension(pArray->m_Size);
 
     Param* pParam = new Param();
 
@@ -190,11 +203,23 @@
 {
 	int	iSuccess = AXIS_SUCCESS;
 
-    ArrayBean* pAb = makeArrayBean( pArray->m_Array, pSZFunct,
+    Axis_Array * pLocalArray = pArray->clone();
+
+    ArrayBean* pAb = makeArrayBean( pLocalArray->m_Array, pSZFunct,
 									 pDelFunct,
 									 pSizeFunct);
 
-    pAb->SetDimension( pArray->m_Size);
+    pAb->SetDimension( pLocalArray->m_Size);
+    
+    /*
+     * We're now finished with the local array object, so it can be deleted
+     * However, we need to de-couple from the internal array, which is now owned
+     * by the ArrayBean.
+     */
+    pLocalArray->m_Array = NULL;
+    pLocalArray->m_Size = 0;
+    delete pLocalArray;
+    pLocalArray = NULL;
 
     Param * pParam = new Param();
 

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ArrayParamHeaderWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ArrayParamHeaderWriter.java?rev=380137&r1=380136&r2=380137&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ArrayParamHeaderWriter.java
(original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ArrayParamHeaderWriter.java
Thu Feb 23 07:06:59 2006
@@ -223,6 +223,7 @@
             writer.write("\t\tvoid set( class " + attribs[0].getTypeName() + "** array, const
int size);\n");
             writer.write("\t\tclass "+ attribs[0].getTypeName() + "** get(int & size)
const;\n");
             writer.write("\t\tvoid clone(const " + classname + " & original);\n");
+            writer.write("\t\tvirtual Axis_Array * clone() const;\n");
             writer.write("\t\tvoid clear();\n");
         }
         catch (IOException e)

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ArrayParamWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ArrayParamWriter.java?rev=380137&r1=380136&r2=380137&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ArrayParamWriter.java
(original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ArrayParamWriter.java
Thu Feb 23 07:06:59 2006
@@ -142,6 +142,11 @@
             writer.write("{\n");
             writer.write("\tset((" + attribs[0].getTypeName() + "**) original.m_Array, original.m_Size);\n");
             writer.write("}\n\n");
+            
+            writer.write("Axis_Array * " + classname + "::clone() const\n");
+            writer.write("{\n");
+            writer.write("\treturn new " + classname + "(*this);\n");
+            writer.write("}\n\n");
         }
         catch (IOException e)
         {

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java?rev=380137&r1=380136&r2=380137&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java Thu
Feb 23 07:06:59 2006
@@ -570,17 +570,19 @@
                     {
                         containedType = CUtils.getclass4qname(qname);
                         writer.write(
-                            "\t\treturn pIWSSZ->addOutputBasicArrayParam(ret,"
+                            "\t\tnStatus = pIWSSZ->addOutputBasicArrayParam(ret,"
                                 + CUtils.getXSDTypeForBasicType(containedType)
                                 + ", \""
                                 + methodName
                                 + "Return\");\n");
+                        writer.write("\t\tdelete ret;\n");
+                        writer.write("\t\t return nStatus;\n");
                     }
                     else
                     {
                         containedType = qname.getLocalPart();
                         writer.write(
-                            "\t\treturn pIWSSZ->addOutputCmplxArrayParam(ret,"
+                            "\t\tnStatus = pIWSSZ->addOutputCmplxArrayParam(ret,"
                                 + "(void*) Axis_Serialize_"
                                 + containedType
                                 + ", (void*) Axis_Delete_"
@@ -592,6 +594,8 @@
                                 + "Return\", Axis_URI_"
                                 + containedType
                                 + ");\n");
+                        writer.write("\t\tdelete ret;\n");
+                        writer.write("\t\treturn nStatus;\n");
                     }
                 }
                 else
@@ -703,6 +707,7 @@
                                         + ", \""
                                         + returnParamName
                                         + "\");\n");
+                                writer.write("\t\tdelete out" + i + ";\n");
                             }
                             else
                             {
@@ -722,6 +727,7 @@
                                         + "\", Axis_URI_"
                                         + containedType
                                         + ");\n");
+                                writer.write("delete out" + i + ";\n");
                             }
                         }
                         else

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/WrapWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/WrapWriter.java?rev=380137&r1=380136&r2=380137&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/WrapWriter.java
(original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/WrapWriter.java
Thu Feb 23 07:06:59 2006
@@ -517,11 +517,13 @@
                     String containedType =
                         CUtils.getclass4qname(retType.getName());
                     writer.write(
-                        "\t\treturn pIWSSZ->addOutputBasicArrayParam(ret, "
+                        "\t\tnStatus = pIWSSZ->addOutputBasicArrayParam(ret, "
                             + CUtils.getXSDTypeForBasicType(containedType)
                             + ", \""
                             + returnParamName
                             + "\");\n");
+                    writer.write("\t\tdelete ret;\n");
+                    writer.write("\t\treturn nStatus;\n");
                 }
                 else
                 {
@@ -558,11 +560,13 @@
                     {
                         containedType = CUtils.getclass4qname(qname);
                         writer.write(
-                            "\t\treturn pIWSSZ->addOutputBasicArrayParam(ret,"
-                                + CUtils.getXSDTypeForBasicType(containedType)
-                                + ", \""
-                                + returnParamName
-                                + "\");\n");
+                                "\t\tnStatus = pIWSSZ->addOutputBasicArrayParam(ret, "
+                                    + CUtils.getXSDTypeForBasicType(containedType)
+                                    + ", \""
+                                    + returnParamName
+                                    + "\");\n");
+                        writer.write("\t\tdelete ret;\n");
+                        writer.write("\t\treturn nStatus;\n");
                     }
                     else
                     {
@@ -571,18 +575,19 @@
                             containedType =
                                 CUtils.getclass4qname(arrayType.getBaseType());
                             writer.write(
-                                "\t\treturn pIWSSZ->addOutputBasicArrayParam(ret,"
-                                    + CUtils.getXSDTypeForBasicType(
-                                        containedType)
-                                    + ", \""
-                                    + returnParamName
-                                    + "\");\n");
+                                    "\t\tnStatus = pIWSSZ->addOutputBasicArrayParam(ret,
"
+                                        + CUtils.getXSDTypeForBasicType(containedType)
+                                        + ", \""
+                                        + returnParamName
+                                        + "\");\n");
+                            writer.write("\t\tdelete ret;\n");
+                            writer.write("\t\treturn nStatus;\n");
                         }
                         else
                         {
                             containedType = qname.getLocalPart();
                             writer.write(
-                                "\t\treturn pIWSSZ->addOutputCmplxArrayParam(ret,"
+                                "\t\tnStatus = pIWSSZ->addOutputCmplxArrayParam(ret,"
                                     + "(void*) Axis_Serialize_"
                                     + containedType
                                     + ", (void*) Axis_Delete_"
@@ -594,6 +599,8 @@
                                     + "\", Axis_URI_"
                                     + containedType
                                     + ");\n");
+                            writer.write("\t\tdelete ret;\n");
+                            writer.write("\t\treturn nStatus;\n");
                         }
                     }
                 }
@@ -745,6 +752,7 @@
                                         + ", \""
                                         + returnParamName
                                         + "\");\n");
+                                writer.write("\tdelete out" + i + ";\n");
                             }
                             else
                             {
@@ -762,6 +770,7 @@
                                             + ", \""
                                             + returnParamName
                                             + "\");\n");
+                                    writer.write("\tdelete out" + i + ";\n");
                                 }
                                 else
                                 {
@@ -781,6 +790,7 @@
                                             + "\", Axis_URI_"
                                             + containedType
                                             + ");\n");
+                                    writer.write("\tdelete out" + i + ";\n");
                                 }
                             }
                         }



Mime
View raw message