camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject svn commit: r1235027 - in /camel/trunk: components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ components/camel-cache/src/test/java/org/apache/camel/component/cache/ components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi...
Date Mon, 23 Jan 2012 22:13:43 GMT
Author: bvahdat
Date: Mon Jan 23 22:13:42 2012
New Revision: 1235027

URL: http://svn.apache.org/viewvc?rev=1235027&view=rev
Log:
Do reuse the provided IOHelper.buffered() methods which would also prevent possible double-buffering
in some corner cases

Modified:
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java
    camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/CacheProducerTest.java
    camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiFactoryFinder.java
    camel/trunk/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecBoundaryTest.java
    camel/trunk/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecLongTest.java
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HandlerTest.java
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRoundtripHeaderTest.java
    camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTCPAsyncTest.java
    camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyUDPAsyncTest.java
    camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
    camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/RequestReplyExample.java
    camel/trunk/components/camel-script/src/main/java/org/apache/camel/script/osgi/Activator.java
    camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/TestUtil.java
    camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/util/FileUtil.java
    camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
    camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamProducer.java
    camel/trunk/components/camel-tagsoup/src/test/java/org/apache/camel/dataformat/tagsoup/TidyMarkupTestSupport.java
    camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTestSupport.java
    camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java
    camel/trunk/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/DotMojo.java
    camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java

Modified: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java
(original)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java
Mon Jan 23 22:13:42 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.apns.util;
 
-import java.io.BufferedInputStream;
 import java.io.Closeable;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -25,6 +24,8 @@ import java.io.InputStream;
 
 import com.notnoop.exceptions.RuntimeIOException;
 
+import org.apache.camel.util.IOHelper;
+
 public final class ResourceUtils {
 
     private static final String CLASSPATH_PREFIX = "classpath:";
@@ -52,7 +53,7 @@ public final class ResourceUtils {
             }
         } else {
             try {
-                is = new BufferedInputStream(new FileInputStream(path));
+                is = IOHelper.buffered(new FileInputStream(path));
             } catch (FileNotFoundException e) {
                 throw new RuntimeIOException(e);
             }

Modified: camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/CacheProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/CacheProducerTest.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/CacheProducerTest.java
(original)
+++ camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/CacheProducerTest.java
Mon Jan 23 22:13:42 2012
@@ -17,7 +17,6 @@
 
 package org.apache.camel.component.cache;
 
-import java.io.BufferedInputStream;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
@@ -30,7 +29,10 @@ import org.apache.camel.builder.RouteBui
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.IOConverter;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
+
 import org.junit.Test;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -57,8 +59,7 @@ public class CacheProducerTest extends C
         template.send("direct:a", new Processor() {
             public void process(Exchange exchange) throws Exception {
                 // Read from an input stream
-                InputStream is = new BufferedInputStream(
-                        new FileInputStream(path));    // "./src/test/resources/test.txt"));
+                InputStream is = IOHelper.buffered(new FileInputStream(path)); // "./src/test/resources/test.txt"));
 
                 byte buffer[] = IOConverter.toBytes(is);
                 is.close();
@@ -81,7 +82,7 @@ public class CacheProducerTest extends C
 
     private byte[] getFileAsByteArray(String path) throws Exception {
         // Read from an input stream
-        InputStream is = new BufferedInputStream(new FileInputStream(path));
+        InputStream is = IOHelper.buffered(new FileInputStream(path));
 
         byte[] buffer = IOConverter.toBytes(is);
         is.close();

Modified: camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiFactoryFinder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiFactoryFinder.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiFactoryFinder.java
(original)
+++ camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiFactoryFinder.java
Mon Jan 23 22:13:42 2012
@@ -26,6 +26,7 @@ import org.apache.camel.NoFactoryAvailab
 import org.apache.camel.impl.DefaultFactoryFinder;
 import org.apache.camel.spi.ClassResolver;
 import org.apache.camel.util.IOHelper;
+
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 
@@ -57,7 +58,7 @@ public class OsgiFactoryFinder extends D
                 // lets load the file
                 BufferedInputStream reader = null;
                 try {
-                    reader = new BufferedInputStream(in);
+                    reader = IOHelper.buffered(in);
                     Properties properties = new Properties();
                     properties.load(reader);
                     String className = properties.getProperty(propertyPrefix + "class");

Modified: camel/trunk/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecBoundaryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecBoundaryTest.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecBoundaryTest.java
(original)
+++ camel/trunk/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecBoundaryTest.java
Mon Jan 23 22:13:42 2012
@@ -27,6 +27,8 @@ import org.apache.camel.builder.RouteBui
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
+
 import org.junit.Test;
 
 /**
@@ -58,7 +60,7 @@ public class HL7MLLPCodecBoundaryTest ex
 
     @Test 
     public void testSendHL7Message() throws Exception {
-        BufferedReader in = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/mdm_t02-1022.txt")));
+        BufferedReader in = IOHelper.buffered(new InputStreamReader(getClass().getResourceAsStream("/mdm_t02-1022.txt")));
         String line = "";
         String message = "";
         while (line != null) {

Modified: camel/trunk/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecLongTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecLongTest.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecLongTest.java
(original)
+++ camel/trunk/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecLongTest.java
Mon Jan 23 22:13:42 2012
@@ -28,6 +28,8 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
+
 import org.junit.Test;
 
 
@@ -69,7 +71,7 @@ public class HL7MLLPCodecLongTest extend
     @Test
     public void testSendHL7Message() throws Exception {
         // START SNIPPET: e2
-        BufferedReader in = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/mdm_t02.txt")));
+        BufferedReader in = IOHelper.buffered(new InputStreamReader(getClass().getResourceAsStream("/mdm_t02.txt")));
         String line = "";
         String message = "";
         while (line != null) {

Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HandlerTest.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HandlerTest.java
(original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HandlerTest.java
Mon Jan 23 22:13:42 2012
@@ -24,7 +24,10 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.util.IOHelper;
+
 import org.eclipse.jetty.server.handler.StatisticsHandler;
+
 import org.junit.Test;
 
 public class HandlerTest extends BaseJettyTest {
@@ -44,7 +47,7 @@ public class HandlerTest extends BaseJet
         assertEquals(0, statisticsHandler3.getRequests());
         
         InputStream html = (InputStream) template.requestBody("http://localhost:" + port1,
"");
-        BufferedReader br = new BufferedReader(new InputStreamReader(html));
+        BufferedReader br = IOHelper.buffered(new InputStreamReader(html));
         
         assertEquals(htmlResponse, br.readLine());
         assertEquals(1, statisticsHandler1.getRequests());
@@ -60,7 +63,7 @@ public class HandlerTest extends BaseJet
         assertEquals(0, statisticsHandler3.getRequests());
 
         InputStream html = (InputStream) template.requestBody("http://localhost:" + port2,
"");
-        BufferedReader br = new BufferedReader(new InputStreamReader(html));
+        BufferedReader br = IOHelper.buffered(new InputStreamReader(html));
         
         assertEquals(htmlResponse, br.readLine());
         assertEquals(0, statisticsHandler1.getRequests());

Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRoundtripHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRoundtripHeaderTest.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRoundtripHeaderTest.java
(original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRoundtripHeaderTest.java
Mon Jan 23 22:13:42 2012
@@ -29,6 +29,8 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultHeaderFilterStrategy;
+import org.apache.camel.util.IOHelper;
+
 import org.junit.Test;
 
 public class HttpRoundtripHeaderTest extends BaseJettyTest {
@@ -109,7 +111,7 @@ public class HttpRoundtripHeaderTest ext
 
     private String readLastLine(InputStream answer) throws IOException {
         String lastLine = null;
-        BufferedReader reader = new BufferedReader(new InputStreamReader(answer));
+        BufferedReader reader = IOHelper.buffered(new InputStreamReader(answer));
         while (true) {
             String line = reader.readLine();
             if (line == null) {

Modified: camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTCPAsyncTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTCPAsyncTest.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTCPAsyncTest.java
(original)
+++ camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTCPAsyncTest.java
Mon Jan 23 22:13:42 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.netty;
 
-import java.io.BufferedInputStream;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
@@ -29,6 +28,8 @@ import org.apache.camel.ProducerTemplate
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.IOConverter;
+import org.apache.camel.util.IOHelper;
+
 import org.junit.Test;
 
 public class NettyTCPAsyncTest extends BaseNettyTest {
@@ -40,18 +41,17 @@ public class NettyTCPAsyncTest extends B
     private void sendFile(String uri) throws Exception {
         producerTemplate.send(uri, new Processor() {
             public void process(Exchange exchange) throws Exception {
-             // Read from an input stream
-                InputStream is = new BufferedInputStream(
-                    new FileInputStream("./src/test/resources/test.txt"));
+                // Read from an input stream
+                InputStream is = IOHelper.buffered(new FileInputStream("./src/test/resources/test.txt"));
 
                 byte buffer[] = IOConverter.toBytes(is);
                 is.close();
-                
+
                 // Set the property of the charset encoding
                 exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
                 Message in = exchange.getIn();
                 in.setBody(buffer);
-            }            
+            }
         });
     }
 

Modified: camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyUDPAsyncTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyUDPAsyncTest.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyUDPAsyncTest.java
(original)
+++ camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyUDPAsyncTest.java
Mon Jan 23 22:13:42 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.netty;
 
-import java.io.BufferedInputStream;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
@@ -29,6 +28,8 @@ import org.apache.camel.ProducerTemplate
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.IOConverter;
+import org.apache.camel.util.IOHelper;
+
 import org.junit.Test;
 
 public class NettyUDPAsyncTest extends BaseNettyTest {
@@ -41,18 +42,17 @@ public class NettyUDPAsyncTest extends B
     private void sendFile(String uri) throws Exception {
         producerTemplate.send(uri, new Processor() {
             public void process(Exchange exchange) throws Exception {
-             // Read from an input stream
-                InputStream is = new BufferedInputStream(
-                    new FileInputStream("./src/test/resources/test.txt"));
+                // Read from an input stream
+                InputStream is = IOHelper.buffered(new FileInputStream("./src/test/resources/test.txt"));
 
                 byte buffer[] = IOConverter.toBytes(is);
                 is.close();
-                
+
                 // Set the property of the charset encoding
                 exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
                 Message in = exchange.getIn();
                 in.setBody(buffer);
-            }            
+            }
         });
     }
 

Modified: camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
(original)
+++ camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
Mon Jan 23 22:13:42 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.printer;
 
-import java.io.BufferedInputStream;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
@@ -25,6 +24,8 @@ import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
+
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -44,13 +45,12 @@ public class PrinterPrintTest extends Ca
         template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
                 // Read from an input stream
-                InputStream is = new BufferedInputStream(
-                        new FileInputStream("./src/test/resources/test.txt"));
+                InputStream is = IOHelper.buffered(new FileInputStream("./src/test/resources/test.txt"));
 
                 byte buffer[] = new byte[is.available()];
                 int n = is.available();
                 for (int i = 0; i < n; i++) {
-                    buffer[i] = (byte) is.read();
+                    buffer[i] = (byte)is.read();
                 }
 
                 is.close();
@@ -66,13 +66,12 @@ public class PrinterPrintTest extends Ca
         template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
                 // Read from an input stream
-                InputStream is = new BufferedInputStream(
-                        new FileInputStream("./src/test/resources/asf-logo.gif"));
+                InputStream is = IOHelper.buffered(new FileInputStream("./src/test/resources/asf-logo.gif"));
 
                 byte buffer[] = new byte[is.available()];
                 int n = is.available();
                 for (int i = 0; i < n; i++) {
-                    buffer[i] = (byte) is.read();
+                    buffer[i] = (byte)is.read();
                 }
 
                 is.close();
@@ -88,13 +87,12 @@ public class PrinterPrintTest extends Ca
         template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
                 // Read from an input stream
-                InputStream is = new BufferedInputStream(
-                        new FileInputStream("./src/test/resources/asf-logo.JPG"));
+                InputStream is = IOHelper.buffered(new FileInputStream("./src/test/resources/asf-logo.JPG"));
 
                 byte buffer[] = new byte[is.available()];
                 int n = is.available();
                 for (int i = 0; i < n; i++) {
-                    buffer[i] = (byte) is.read();
+                    buffer[i] = (byte)is.read();
                 }
 
                 is.close();

Modified: camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/RequestReplyExample.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/RequestReplyExample.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/RequestReplyExample.java
(original)
+++ camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/RequestReplyExample.java
Mon Jan 23 22:13:42 2012
@@ -36,6 +36,8 @@ import org.apache.camel.component.quickf
 import org.apache.camel.component.quickfixj.examples.transform.QuickfixjMessageJsonTransformer;
 import org.apache.camel.component.quickfixj.examples.util.CountDownLatchDecrementer;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.util.IOHelper;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -103,7 +105,7 @@ public class RequestReplyExample {
         
         URL orderStatusUrl = new URL(orderStatusServiceUrl + "?sessionID=FIX.4.2:TRADER->MARKET&orderID=abc");
         HttpURLConnection connection = (HttpURLConnection) orderStatusUrl.openConnection();
-        BufferedReader orderStatusReply = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+        BufferedReader orderStatusReply = IOHelper.buffered(new InputStreamReader(connection.getInputStream()));
         String line = orderStatusReply.readLine();
         if (!line.equals("\"message\": {")) {
             throw new Exception("Don't appear to be a JSON response");

Modified: camel/trunk/components/camel-script/src/main/java/org/apache/camel/script/osgi/Activator.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-script/src/main/java/org/apache/camel/script/osgi/Activator.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-script/src/main/java/org/apache/camel/script/osgi/Activator.java
(original)
+++ camel/trunk/components/camel-script/src/main/java/org/apache/camel/script/osgi/Activator.java
Mon Jan 23 22:13:42 2012
@@ -30,6 +30,8 @@ import javax.script.ScriptEngineFactory;
 
 import org.apache.camel.impl.osgi.tracker.BundleTracker;
 import org.apache.camel.impl.osgi.tracker.BundleTrackerCustomizer;
+import org.apache.camel.util.IOHelper;
+
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
@@ -37,6 +39,7 @@ import org.osgi.framework.BundleEvent;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -146,7 +149,7 @@ public class Activator implements Bundle
         }
         public ScriptEngine resolveScriptEngine(String name) {
             try {
-                BufferedReader in = new BufferedReader(new InputStreamReader(configFile.openStream()));
+                BufferedReader in = IOHelper.buffered(new InputStreamReader(configFile.openStream()));
                 String className = in.readLine();
                 in.close();
                 Class<?> cls = bundle.loadClass(className);

Modified: camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/TestUtil.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/TestUtil.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/TestUtil.java
(original)
+++ camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/TestUtil.java
Mon Jan 23 22:13:42 2012
@@ -21,6 +21,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 
+import org.apache.camel.util.IOHelper;
+
 public final class TestUtil {
     private TestUtil() {
     }
@@ -28,8 +30,7 @@ public final class TestUtil {
     public static String readStream(InputStream is) throws IOException {
         try {
             StringBuilder sb = new StringBuilder();
-            BufferedReader reader = new BufferedReader(new InputStreamReader(
-                    is, "UTF-8"));
+            BufferedReader reader = IOHelper.buffered(new InputStreamReader(is, "UTF-8"));
             String line;
             while ((line = reader.readLine()) != null) {
                 sb.append(line).append("\n");

Modified: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/util/FileUtil.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/util/FileUtil.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/util/FileUtil.java
(original)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/util/FileUtil.java
Mon Jan 23 22:13:42 2012
@@ -16,7 +16,12 @@
  */
 package org.apache.camel.component.spring.ws.util;
 
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.camel.util.IOHelper;
 
 public final class FileUtil {
 
@@ -27,7 +32,7 @@ public final class FileUtil {
         InputStream is = FileUtil.class.getResourceAsStream(filePath);
         try {
             StringBuilder sb = new StringBuilder();
-            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+            BufferedReader reader = IOHelper.buffered(new InputStreamReader(is, "UTF-8"));
             String line;
             while ((line = reader.readLine()) != null) {
                 sb.append(line).append("\n");

Modified: camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
(original)
+++ camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
Mon Jan 23 22:13:42 2012
@@ -38,6 +38,7 @@ import org.apache.camel.impl.DefaultCons
 import org.apache.camel.impl.DefaultMessage;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -117,7 +118,7 @@ public class StreamConsumer extends Defa
             inputStreamToClose = inputStream;
         }
         Charset charset = endpoint.getCharset();
-        return new BufferedReader(new InputStreamReader(inputStream, charset));
+        return IOHelper.buffered(new InputStreamReader(inputStream, charset));
     }
 
     private void readFromStream() throws Exception {

Modified: camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamProducer.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamProducer.java
(original)
+++ camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamProducer.java
Mon Jan 23 22:13:42 2012
@@ -32,7 +32,9 @@ import java.util.List;
 import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -125,7 +127,7 @@ public class StreamProducer extends Defa
         String s = exchange.getIn().getMandatoryBody(String.class);
         Charset charset = endpoint.getCharset();
         Writer writer = new OutputStreamWriter(outputStream, charset);
-        BufferedWriter bw = new BufferedWriter(writer);
+        BufferedWriter bw = IOHelper.buffered(writer);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Writing as text: {} to {} using encoding: {}", new Object[]{body,
outputStream, charset});
         }

Modified: camel/trunk/components/camel-tagsoup/src/test/java/org/apache/camel/dataformat/tagsoup/TidyMarkupTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-tagsoup/src/test/java/org/apache/camel/dataformat/tagsoup/TidyMarkupTestSupport.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-tagsoup/src/test/java/org/apache/camel/dataformat/tagsoup/TidyMarkupTestSupport.java
(original)
+++ camel/trunk/components/camel-tagsoup/src/test/java/org/apache/camel/dataformat/tagsoup/TidyMarkupTestSupport.java
Mon Jan 23 22:13:42 2012
@@ -31,6 +31,8 @@ import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
+import org.apache.camel.util.IOHelper;
+
 public final class TidyMarkupTestSupport {
     
     private TidyMarkupTestSupport() {
@@ -39,7 +41,7 @@ public final class TidyMarkupTestSupport
     
     public static String loadFileAsString(File file) throws Exception {
         StringBuilder fileContent = new StringBuilder();
-        BufferedReader input = new BufferedReader(new FileReader(file));
+        BufferedReader input = IOHelper.buffered(new FileReader(file));
         try {
             String line = null;
             while ((line = input.readLine()) != null) {

Modified: camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java
(original)
+++ camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java
Mon Jan 23 22:13:42 2012
@@ -34,6 +34,8 @@ import org.apache.camel.Message;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.IOHelper;
+
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.WatchedEvent;
@@ -258,7 +260,7 @@ public class ZooKeeperTestSupport extend
             outstream.write(cmd.getBytes());
             outstream.flush();
 
-            reader = new BufferedReader(new InputStreamReader(sock.getInputStream()));
+            reader = IOHelper.buffered(new InputStreamReader(sock.getInputStream()));
             StringBuffer sb = new StringBuffer();
             String line;
             while ((line = reader.readLine()) != null) {

Modified: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTestSupport.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTestSupport.java
(original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTestSupport.java
Mon Jan 23 22:13:42 2012
@@ -35,7 +35,10 @@ import org.apache.camel.component.mock.M
 import org.apache.camel.component.zookeeper.ZooKeeperMessage;
 import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
 import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.IOHelper;
+
 import org.apache.log4j.Logger;
+
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
@@ -47,8 +50,10 @@ import org.apache.zookeeper.data.Stat;
 import org.apache.zookeeper.server.NIOServerCnxn;
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
+
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.Configuration;
 import static org.ops4j.pax.exam.OptionUtils.combine;
@@ -254,7 +259,7 @@ public class ZookeeperOSGiTestSupport ex
             outstream.write(cmd.getBytes());
             outstream.flush();
 
-            reader = new BufferedReader(new InputStreamReader(sock.getInputStream()));
+            reader = IOHelper.buffered(new InputStreamReader(sock.getInputStream()));
             StringBuffer sb = new StringBuffer();
             String line;
             while ((line = reader.readLine()) != null) {

Modified: camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java
URL: http://svn.apache.org/viewvc/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java
(original)
+++ camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java
Mon Jan 23 22:13:42 2012
@@ -31,6 +31,8 @@ import java.util.Locale;
 import java.util.ResourceBundle;
 import java.util.Set;
 
+import org.apache.camel.util.IOHelper;
+
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.siterenderer.Renderer;
@@ -39,6 +41,7 @@ import org.apache.maven.plugin.logging.L
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.reporting.AbstractMavenReport;
 import org.apache.maven.reporting.MavenReportException;
+
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
@@ -529,7 +532,7 @@ public class DotMojo extends AbstractMav
     private void addFileToBuffer(PrintWriter out, File file) throws MojoExecutionException
{
         BufferedReader reader = null;
         try {
-            reader = new BufferedReader(new FileReader(file));
+            reader = IOHelper.buffered(new FileReader(file));
             while (true) {
                 String line = reader.readLine();
                 if (line == null) {

Modified: camel/trunk/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/DotMojo.java
URL: http://svn.apache.org/viewvc/camel/trunk/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/DotMojo.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/DotMojo.java
(original)
+++ camel/trunk/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/DotMojo.java
Mon Jan 23 22:13:42 2012
@@ -31,6 +31,8 @@ import java.util.Locale;
 import java.util.ResourceBundle;
 import java.util.Set;
 
+import org.apache.camel.util.IOHelper;
+
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.siterenderer.Renderer;
@@ -39,6 +41,7 @@ import org.apache.maven.plugin.logging.L
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.reporting.AbstractMavenReport;
 import org.apache.maven.reporting.MavenReportException;
+
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
@@ -491,7 +494,7 @@ public class DotMojo extends AbstractMav
     private void addFileToBuffer(PrintWriter out, File file) throws MojoExecutionException
{
         BufferedReader reader = null;
         try {
-            reader = new BufferedReader(new FileReader(file));
+            reader = IOHelper.buffered(new FileReader(file));
             while (true) {
                 String line = reader.readLine();
                 if (line == null) {

Modified: camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java
URL: http://svn.apache.org/viewvc/camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java?rev=1235027&r1=1235026&r2=1235027&view=diff
==============================================================================
--- camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java
(original)
+++ camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java
Mon Jan 23 22:13:42 2012
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.maven;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -33,10 +31,13 @@ import org.w3c.dom.Node;
 
 import org.apache.camel.converter.jaxp.XmlConverter;
 import org.apache.camel.dataformat.tagsoup.TidyMarkupDataFormat;
+import org.apache.camel.util.IOHelper;
+
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
+
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
@@ -251,7 +252,7 @@ public class HtmlToPdfMojo extends Abstr
     }
 
     private void storeDummyFile() throws FileNotFoundException {
-        PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(getHTMLFileName())));
+        PrintWriter out = new PrintWriter(IOHelper.buffered(new FileOutputStream(getHTMLFileName())));
         out.println("<html>");
         out.println("<body>Generation of the offline PDF version of the manual failed,
however you could try "
                     + "<a href=\"http://camel.apache.org/book-in-one-page.html\">the
online HTML version</a>.</body>");
@@ -261,7 +262,7 @@ public class HtmlToPdfMojo extends Abstr
     }
 
     private void storeHTMLFile(String content) throws FileNotFoundException {
-        PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(getHTMLFileName())));
+        PrintWriter out = new PrintWriter(IOHelper.buffered(new FileOutputStream(getHTMLFileName())));
         out.println("<html>");
         out.println("<head>");
         out.println("   <base href=\"" + page + "\"/>");
@@ -308,7 +309,7 @@ public class HtmlToPdfMojo extends Abstr
         try {
             TidyMarkupDataFormat dataFormat = new TidyMarkupDataFormat();
             dataFormat.setMethod("html");
-            Node doc = dataFormat.asNodeTidyMarkup(new BufferedInputStream(url.openStream()));
+            Node doc = dataFormat.asNodeTidyMarkup(IOHelper.buffered(url.openStream()));
             XPath xpath = XPathFactory.newInstance().newXPath();
             Node nd = (Node)xpath.evaluate("//div[@class='" + contentDivClass + "']", doc,
XPathConstants.NODE);
             if (nd != null) {



Mime
View raw message