camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r705356 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/impl/ components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/ components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/ components...
Date Thu, 16 Oct 2008 20:51:57 GMT
Author: davsclaus
Date: Thu Oct 16 13:51:57 2008
New Revision: 705356

URL: http://svn.apache.org/viewvc?rev=705356&view=rev
Log:
CAMEL-980: Closing created resources after usage in the data formats

Added:
    activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java
  (contents, props changed)
      - copied, changed from r705288, activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObject.java
Removed:
    activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObject.java
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SerializationDataFormat.java
    activemq/camel/trunk/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackDataFormat.java
    activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
    activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SerializationDataFormat.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SerializationDataFormat.java?rev=705356&r1=705355&r2=705356&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SerializationDataFormat.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SerializationDataFormat.java
Thu Oct 16 13:51:57 2008
@@ -36,12 +36,28 @@
 
     public void marshal(Exchange exchange, Object graph, OutputStream stream) throws IOException
{
         ObjectOutput out = IOConverter.toObjectOutput(stream);
-        out.writeObject(graph);
-        out.flush();
+        try {
+            out.writeObject(graph);
+        } finally {
+            out.flush();
+            try {
+                out.close();
+            } catch (IOException e) {
+                // ignore
+            }
+        }
     }
 
     public Object unmarshal(Exchange exchange, InputStream stream) throws IOException, ClassNotFoundException
{
         ObjectInput in = IOConverter.toObjectInput(stream);
-        return in.readObject();
+        try {
+            return in.readObject();
+        } finally {
+            try {
+                in.close();
+            } catch (IOException e) {
+                // ignore
+            }
+        }
     }
 }

Modified: activemq/camel/trunk/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackDataFormat.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackDataFormat.java?rev=705356&r1=705355&r2=705356&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackDataFormat.java
(original)
+++ activemq/camel/trunk/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackDataFormat.java
Thu Oct 16 13:51:57 2008
@@ -95,9 +95,13 @@
 
     public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
         InputStreamReader reader = new InputStreamReader(stream);
-        Parser parser = createParser(exchange, reader);
-        DataSet dataSet = parser.parse();
-        return new DataSetList(dataSet);
+        try {
+            Parser parser = createParser(exchange, reader);
+            DataSet dataSet = parser.parse();
+            return new DataSetList(dataSet);
+        } finally {
+            reader.close();
+        }
     }
 
     // Properties

Modified: activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java?rev=705356&r1=705355&r2=705356&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
(original)
+++ activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
Thu Oct 16 13:51:57 2008
@@ -140,10 +140,10 @@
     }
 
     /**
-     * Unmarshals
+     * Unmarshals the given value with the unmarshaller
      *
      * @param unmarshaller  the unmarshaller
-     * @param value  the stream to unarmashal (will close it after use, also if exception
is thrown)
+     * @param value  the stream to unmarshal (will close it after use, also if exception
is thrown)
      * @return  the value
      * @throws JAXBException is thrown if an exception occur while unmarshalling
      */

Modified: activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java?rev=705356&r1=705355&r2=705356&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java
(original)
+++ activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java
Thu Oct 16 13:51:57 2008
@@ -48,12 +48,20 @@
 
     public void marshal(Exchange exchange, Object body, OutputStream stream) throws Exception
{
         HierarchicalStreamWriter writer = createHierarchicalStreamWriter(exchange, body,
stream);
-        getXStream().marshal(body, writer);
+        try {
+            getXStream().marshal(body, writer);
+        } finally {
+            writer.close();
+        }
     }
 
     public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
         HierarchicalStreamReader reader = createHierarchicalStreamReader(exchange, stream);
-        return getXStream().unmarshal(reader);
+        try {
+            return getXStream().unmarshal(reader);
+        } finally {
+            reader.close();
+        }
     }
 
     public XStream getXStream() {

Copied: activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java
(from r705288, activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObject.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java?p2=activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java&p1=activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObject.java&r1=705288&r2=705356&rev=705356&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObject.java
(original)
+++ activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java
Thu Oct 16 13:51:57 2008
@@ -23,7 +23,7 @@
 /**
  * Marhsal tests with domain objects.
  */
-public class MarshalDomainObject extends ContextTestSupport {
+public class MarshalDomainObjectTest extends ContextTestSupport {
 
     public void testMarshalDomainObject() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");

Propchange: activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message