camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject svn commit: r1331294 - in /camel/trunk/components: camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/ camel-gson/src/main/java/org/apache/camel/component/gson/ camel-netty/src/test/java/org/apache/camel/component/netty/ camel-smpp/src/main/...
Date Fri, 27 Apr 2012 08:31:39 GMT
Author: bvahdat
Date: Fri Apr 27 08:31:38 2012
New Revision: 1331294

URL: http://svn.apache.org/viewvc?rev=1331294&view=rev
Log:
Do reuse the IOHelper.buffered() utilities.

Modified:
    camel/trunk/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java
    camel/trunk/components/camel-gson/src/main/java/org/apache/camel/component/gson/GsonDataFormat.java
    camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/UnsharableCodecsConflictsTest.java
    camel/trunk/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java

Modified: camel/trunk/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java?rev=1331294&r1=1331293&r2=1331294&view=diff
==============================================================================
--- camel/trunk/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java
(original)
+++ camel/trunk/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java
Fri Apr 27 08:31:38 2012
@@ -124,7 +124,7 @@ public class BeanIODataFormat extends Se
     }
 
     private void writeModels(OutputStream stream, List<Object> models) {
-        BufferedWriter streamWriter = new BufferedWriter(new OutputStreamWriter(stream, encoding));
+        BufferedWriter streamWriter = IOHelper.buffered(new OutputStreamWriter(stream, encoding));
         BeanWriter out = factory.createWriter(streamName, streamWriter);
 
         for (Object obj : models) {
@@ -137,7 +137,7 @@ public class BeanIODataFormat extends Se
 
     private List<Object> readModels(Exchange exchange, InputStream stream) {
         List<Object> results = new ArrayList<Object>();
-        BufferedReader streamReader = new BufferedReader(new InputStreamReader(stream, encoding));
+        BufferedReader streamReader = IOHelper.buffered(new InputStreamReader(stream, encoding));
 
         BeanReader in = factory.createReader(streamName, streamReader);
 

Modified: camel/trunk/components/camel-gson/src/main/java/org/apache/camel/component/gson/GsonDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gson/src/main/java/org/apache/camel/component/gson/GsonDataFormat.java?rev=1331294&r1=1331293&r2=1331294&view=diff
==============================================================================
--- camel/trunk/components/camel-gson/src/main/java/org/apache/camel/component/gson/GsonDataFormat.java
(original)
+++ camel/trunk/components/camel-gson/src/main/java/org/apache/camel/component/gson/GsonDataFormat.java
Fri Apr 27 08:31:38 2012
@@ -22,7 +22,6 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
-import java.io.Writer;
 import java.util.Map;
 
 import com.google.gson.ExclusionStrategy;
@@ -30,6 +29,7 @@ import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import org.apache.camel.Exchange;
 import org.apache.camel.spi.DataFormat;
+import org.apache.camel.util.IOHelper;
 
 /**
  * A <a href="http://camel.apache.org/data-format.html">data format</a> ({@link
DataFormat})
@@ -82,14 +82,14 @@ public class GsonDataFormat implements D
 
     @Override
     public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception
{
-        Writer writer = new BufferedWriter(new OutputStreamWriter(stream));
+        BufferedWriter writer = IOHelper.buffered(new OutputStreamWriter(stream));
         gson.toJson(graph, writer);
         writer.close();
     }
 
     @Override
     public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
-        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+        BufferedReader reader = IOHelper.buffered(new InputStreamReader(stream));
         Object result = gson.fromJson(reader, this.unmarshalType);
         reader.close();
         return result;

Modified: camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/UnsharableCodecsConflictsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/UnsharableCodecsConflictsTest.java?rev=1331294&r1=1331293&r2=1331294&view=diff
==============================================================================
--- camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/UnsharableCodecsConflictsTest.java
(original)
+++ camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/UnsharableCodecsConflictsTest.java
Fri Apr 27 08:31:38 2012
@@ -18,7 +18,6 @@ package org.apache.camel.component.netty
 
 import java.io.BufferedOutputStream;
 import java.io.IOException;
-import java.io.OutputStream;
 import java.net.Socket;
 import java.util.Arrays;
 
@@ -27,6 +26,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.util.IOHelper;
 import org.jboss.netty.buffer.BigEndianHeapChannelBuffer;
 import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
 import org.junit.Test;
@@ -109,12 +109,12 @@ public class UnsharableCodecsConflictsTe
     }
 
     public static void sendSopBuffer(byte[] buf, Socket server) throws Exception {
-        OutputStream netOut = server.getOutputStream();
-        OutputStream dataOut = new BufferedOutputStream(netOut);
+        BufferedOutputStream dataOut = IOHelper.buffered(server.getOutputStream());
         try {
             dataOut.write(buf, 0, buf.length);
             dataOut.flush();
         } catch (Exception e) {
+            IOHelper.close(dataOut);
             server.close();
             throw e;
         }

Modified: camel/trunk/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java?rev=1331294&r1=1331293&r2=1331294&view=diff
==============================================================================
--- camel/trunk/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java
(original)
+++ camel/trunk/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java
Fri Apr 27 08:31:38 2012
@@ -58,6 +58,7 @@ import javax.net.SocketFactory;
 import javax.net.ssl.SSLSocketFactory;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.util.IOHelper;
 import org.apache.commons.codec.binary.Base64;
 import org.jsmpp.session.connection.Connection;
 import org.jsmpp.session.connection.ConnectionFactory;
@@ -121,7 +122,7 @@ public final class SmppConnectionFactory
 
             int ch = 0;
 
-            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+            BufferedReader reader = IOHelper.buffered(new InputStreamReader(in));
             String response = reader.readLine();
             if (response == null) {
                 throw new RuntimeCamelException("Empty response to CONNECT request to host
" + host + ":" + port);



Mime
View raw message