Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B38709D80 for ; Thu, 22 Dec 2011 20:42:00 +0000 (UTC) Received: (qmail 54167 invoked by uid 500); 22 Dec 2011 20:42:00 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 54125 invoked by uid 500); 22 Dec 2011 20:42:00 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 54118 invoked by uid 99); 22 Dec 2011 20:42:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Dec 2011 20:42:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Dec 2011 20:41:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BA7C623889D7 for ; Thu, 22 Dec 2011 20:41:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1222438 [1/2] - in /camel/branches/camel-2.8.x: ./ camel-core/src/main/java/org/apache/camel/component/file/ camel-core/src/main/java/org/apache/camel/converter/ camel-core/src/main/java/org/apache/camel/converter/jaxp/ camel-core/src/main... Date: Thu, 22 Dec 2011 20:41:33 -0000 To: commits@camel.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111222204135.BA7C623889D7@eris.apache.org> Author: dkulp Date: Thu Dec 22 20:41:32 2011 New Revision: 1222438 URL: http://svn.apache.org/viewvc?rev=1222438&view=rev Log: Merged revisions 1212504 via svnmerge from https://svn.apache.org/repos/asf/camel/trunk ........ r1212504 | davsclaus | 2011-12-09 11:38:31 -0500 (Fri, 09 Dec 2011) | 1 line CAMEL-4687: Wrap streams in buffer when appropiate. Added @Override. Thanks to Babak for the patch. Fixed CS. ........ Modified: camel/branches/camel-2.8.x/ (props changed) camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/DomConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/stream/FileInputStreamCache.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultFactoryFinder.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/ArrayTypeConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/FutureTypeConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/InstanceMethodFallbackTypeConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/InstanceMethodTypeConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/LazyLoadingTypeConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/PropertyEditorTypeConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/StaticMethodFallbackTypeConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/StaticMethodTypeConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/ToStringTypeConverter.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/util/IOHelper.java camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/component/file/GenericFileConverterTest.java camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/CollectionConverterTest.java camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/FutureConverterTest.java camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/IOConverterTest.java camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/ObjectHelperTest.java camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/jaxp/DomConverterTest.java camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateSimpleExpressionIssueTest.java camel/branches/camel-2.8.x/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastInstanceConsumerTest.java Propchange: camel/branches/camel-2.8.x/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Dec 22 20:41:32 2011 @@ -1 +1 @@ -/camel/trunk:1215477,1221565 +/camel/trunk:1212504,1215477,1221565 Propchange: camel/branches/camel-2.8.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java Thu Dec 22 20:41:32 2011 @@ -27,6 +27,7 @@ import org.apache.camel.Exchange; import org.apache.camel.FallbackConverter; import org.apache.camel.TypeConverter; import org.apache.camel.spi.TypeConverterRegistry; +import org.apache.camel.util.IOHelper; /** * A set of converter methods for working with generic file types @@ -67,7 +68,7 @@ public final class GenericFileConverter if (exchange != null) { // use a file input stream if its a java.io.File if (file.getFile() instanceof java.io.File) { - return new FileInputStream((File) file.getFile()); + return IOHelper.buffered(new FileInputStream((File) file.getFile())); } // otherwise ensure the body is loaded as we want the input stream of the body file.getBinding().loadContent(exchange, file); Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java Thu Dec 22 20:41:32 2011 @@ -123,10 +123,9 @@ public final class CollectionConverter { * Converts an {@link Iterable} into a {@link List} */ @Converter - @SuppressWarnings("unchecked") public static List toList(Iterable iterable) { if (iterable instanceof List) { - return (List) iterable; + return (List) iterable; } List result = new LinkedList(); for (T value : iterable) { Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java Thu Dec 22 20:41:32 2011 @@ -16,8 +16,6 @@ */ package org.apache.camel.converter; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayInputStream; @@ -68,12 +66,12 @@ public final class IOConverter { @Converter public static InputStream toInputStream(URL url) throws IOException { - return url.openStream(); + return IOHelper.buffered(url.openStream()); } @Converter public static InputStream toInputStream(File file) throws IOException { - return new BufferedInputStream(new FileInputStream(file)); + return IOHelper.buffered(new FileInputStream(file)); } /** @@ -86,7 +84,7 @@ public final class IOConverter { @Converter public static BufferedReader toReader(File file, Exchange exchange) throws IOException { - return new BufferedReader(new EncodingFileReader(file, getCharsetName(exchange))); + return IOHelper.buffered(new EncodingFileReader(file, IOHelper.getCharsetName(exchange))); } @Converter @@ -96,7 +94,7 @@ public final class IOConverter { @Converter public static OutputStream toOutputStream(File file) throws FileNotFoundException { - return new BufferedOutputStream(new FileOutputStream(file)); + return IOHelper.buffered(new FileOutputStream(file)); } /** @@ -109,7 +107,7 @@ public final class IOConverter { @Converter public static BufferedWriter toWriter(File file, Exchange exchange) throws IOException { - return new BufferedWriter(new EncodingFileWriter(file, getCharsetName(exchange))); + return IOHelper.buffered(new EncodingFileWriter(file, IOHelper.getCharsetName(exchange))); } /** @@ -122,7 +120,7 @@ public final class IOConverter { @Converter public static Reader toReader(InputStream in, Exchange exchange) throws IOException { - return new InputStreamReader(in, getCharsetName(exchange)); + return IOHelper.buffered(new InputStreamReader(in, IOHelper.getCharsetName(exchange))); } /** @@ -135,11 +133,13 @@ public final class IOConverter { @Converter public static Writer toWriter(OutputStream out, Exchange exchange) throws IOException { - return new OutputStreamWriter(out, getCharsetName(exchange)); + return IOHelper.buffered(new OutputStreamWriter(out, IOHelper.getCharsetName(exchange))); } @Converter public static StringReader toReader(String text) { + // no buffering required as the complete string input is already passed + // over as a whole return new StringReader(text); } @@ -225,11 +225,7 @@ public final class IOConverter { @Converter public static byte[] toByteArray(Reader reader, Exchange exchange) throws IOException { - if (reader instanceof BufferedReader) { - return toByteArray((BufferedReader)reader, exchange); - } else { - return toByteArray(new BufferedReader(reader), exchange); - } + return toByteArray(IOHelper.buffered(reader), exchange); } /** @@ -252,11 +248,7 @@ public final class IOConverter { @Converter public static String toString(Reader reader) throws IOException { - if (reader instanceof BufferedReader) { - return toString((BufferedReader)reader); - } else { - return toString(new BufferedReader(reader)); - } + return toString(IOHelper.buffered(reader)); } @Converter @@ -268,13 +260,10 @@ public final class IOConverter { StringBuilder sb = new StringBuilder(1024); char[] buf = new char[1024]; try { - int len = 0; + int len; // read until we reach then end which is the -1 marker - while (len != -1) { - len = reader.read(buf); - if (len != -1) { - sb.append(buf, 0, len); - } + while ((len = reader.read(buf)) != -1) { + sb.append(buf, 0, len); } } finally { IOHelper.close(reader, "reader", LOG); @@ -324,6 +313,8 @@ public final class IOConverter { @Converter public static InputStream toInputStream(byte[] data) { + // no buffering required as the complete byte input is already passed + // over as a whole return new ByteArrayInputStream(data); } @@ -332,7 +323,7 @@ public final class IOConverter { if (stream instanceof ObjectOutput) { return (ObjectOutput) stream; } else { - return new ObjectOutputStream(stream); + return new ObjectOutputStream(IOHelper.buffered(stream)); } } @@ -341,19 +332,18 @@ public final class IOConverter { if (stream instanceof ObjectInput) { return (ObjectInput) stream; } else { - return new ObjectInputStream(stream); + return new ObjectInputStream(IOHelper.buffered(stream)); } } @Converter public static byte[] toBytes(InputStream stream) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - IOHelper.copy(stream, bos); - return bos.toByteArray(); - } finally { - IOHelper.close(bos, "stream", LOG); - } + IOHelper.copy(IOHelper.buffered(stream), bos); + + // no need to close the ByteArrayOutputStream as it's close() + // implementation is noop + return bos.toByteArray(); } @Converter @@ -376,6 +366,8 @@ public final class IOConverter { @Converter public static InputStream toInputStream(ByteArrayOutputStream os) { + // no buffering required as the complete byte array input is already + // passed over as a whole return new ByteArrayInputStream(os.toByteArray()); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java Thu Dec 22 20:41:32 2011 @@ -16,7 +16,6 @@ */ package org.apache.camel.converter; -import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -66,7 +65,7 @@ public final class NIOConverter { InputStream in = null; try { byte[] buf = new byte[(int)file.length()]; - in = new BufferedInputStream(new FileInputStream(file)); + in = IOHelper.buffered(new FileInputStream(file)); int sizeLeft = (int)file.length(); int offset = 0; while (sizeLeft > 0) { Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java Thu Dec 22 20:41:32 2011 @@ -66,9 +66,8 @@ public final class ObjectConverter { /** * Creates an iterator over the value */ - @SuppressWarnings("rawtypes") @Converter - public static Iterator iterator(Object value) { + public static Iterator iterator(Object value) { return ObjectHelper.createIterator(value); } @@ -112,11 +111,10 @@ public final class ObjectConverter { /** * Returns the converted value, or null if the value is null */ - @SuppressWarnings("rawtypes") @Converter - public static Class toClass(Object value, Exchange exchange) { + public static Class toClass(Object value, Exchange exchange) { if (value instanceof Class) { - return (Class) value; + return (Class) value; } else if (value instanceof String) { // prefer to use class resolver API if (exchange != null) { Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/DomConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/DomConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/DomConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/DomConverter.java Thu Dec 22 20:41:32 2011 @@ -104,11 +104,10 @@ public final class DomConverter { return Long.valueOf(s); } - @SuppressWarnings("unchecked") @Converter - public static List toList(NodeList nodeList) { - List answer = new ArrayList(); - Iterator it = ObjectHelper.createIterator(nodeList); + public static List toList(NodeList nodeList) { + List answer = new ArrayList(); + Iterator it = ObjectHelper.createIterator(nodeList); while (it.hasNext()) { answer.add(it.next()); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java Thu Dec 22 20:41:32 2011 @@ -16,6 +16,9 @@ */ package org.apache.camel.converter.jaxp; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; @@ -34,6 +37,7 @@ import javax.xml.transform.Source; import org.apache.camel.Converter; import org.apache.camel.Exchange; import org.apache.camel.converter.IOConverter; +import org.apache.camel.util.IOHelper; /** * A converter of StAX objects @@ -47,12 +51,12 @@ public class StaxConverter { @Converter public XMLEventWriter createXMLEventWriter(OutputStream out, Exchange exchange) throws XMLStreamException { - return getOutputFactory().createXMLEventWriter(out, IOConverter.getCharsetName(exchange)); + return getOutputFactory().createXMLEventWriter(IOHelper.buffered(out), IOHelper.getCharsetName(exchange)); } @Converter public XMLEventWriter createXMLEventWriter(Writer writer) throws XMLStreamException { - return getOutputFactory().createXMLEventWriter(writer); + return getOutputFactory().createXMLEventWriter(IOHelper.buffered(writer)); } @Converter @@ -67,7 +71,7 @@ public class StaxConverter { @Converter public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException { - return getOutputFactory().createXMLStreamWriter(writer); + return getOutputFactory().createXMLStreamWriter(IOHelper.buffered(writer)); } @Converter @@ -80,17 +84,22 @@ public class StaxConverter { */ @Deprecated public XMLStreamReader createXMLStreamReader(InputStream in) throws XMLStreamException { - return getInputFactory().createXMLStreamReader(in); + return getInputFactory().createXMLStreamReader(IOHelper.buffered(in)); } @Converter public XMLStreamReader createXMLStreamReader(InputStream in, Exchange exchange) throws XMLStreamException { - return getInputFactory().createXMLStreamReader(in, IOConverter.getCharsetName(exchange)); + return getInputFactory().createXMLStreamReader(IOHelper.buffered(in), IOHelper.getCharsetName(exchange)); } @Converter - public XMLStreamReader createXMLStreamReader(Reader in) throws XMLStreamException { - return getInputFactory().createXMLStreamReader(in); + public XMLStreamReader createXMLStreamReader(File file, Exchange exchange) throws XMLStreamException, FileNotFoundException { + return getInputFactory().createXMLStreamReader(IOHelper.buffered(new FileInputStream(file)), IOHelper.getCharsetName(exchange)); + } + + @Converter + public XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException { + return getInputFactory().createXMLStreamReader(IOHelper.buffered(reader)); } @Converter @@ -103,22 +112,27 @@ public class StaxConverter { */ @Deprecated public XMLEventReader createXMLEventReader(InputStream in) throws XMLStreamException { - return getInputFactory().createXMLEventReader(in); + return getInputFactory().createXMLEventReader(IOHelper.buffered(in)); } @Converter public XMLEventReader createXMLEventReader(InputStream in, Exchange exchange) throws XMLStreamException { - return getInputFactory().createXMLEventReader(in, IOConverter.getCharsetName(exchange)); + return getInputFactory().createXMLEventReader(IOHelper.buffered(in), IOHelper.getCharsetName(exchange)); } @Converter - public XMLEventReader createXMLEventReader(Reader in) throws XMLStreamException { - return getInputFactory().createXMLEventReader(in); + public XMLEventReader createXMLEventReader(File file, Exchange exchange) throws XMLStreamException, FileNotFoundException { + return getInputFactory().createXMLEventReader(IOHelper.buffered(new FileInputStream(file)), IOHelper.getCharsetName(exchange)); } @Converter - public XMLEventReader createXMLEventReader(XMLStreamReader in) throws XMLStreamException { - return getInputFactory().createXMLEventReader(in); + public XMLEventReader createXMLEventReader(Reader reader) throws XMLStreamException { + return getInputFactory().createXMLEventReader(IOHelper.buffered(reader)); + } + + @Converter + public XMLEventReader createXMLEventReader(XMLStreamReader reader) throws XMLStreamException { + return getInputFactory().createXMLEventReader(reader); } @Converter Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java Thu Dec 22 20:41:32 2011 @@ -53,6 +53,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; + import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; @@ -400,8 +401,8 @@ public class XmlConverter { */ @Converter public SAXSource toSAXSource(File file, Exchange exchange) throws IOException, SAXException, TransformerException { - FileInputStream fis = new FileInputStream(file); - return toSAXSource(fis, exchange); + InputStream is = IOHelper.buffered(new FileInputStream(file)); + return toSAXSource(is, exchange); } /** @@ -412,8 +413,8 @@ public class XmlConverter { */ @Converter public StAXSource toStAXSource(File file, Exchange exchange) throws FileNotFoundException, XMLStreamException { - FileInputStream fis = new FileInputStream(file); - XMLStreamReader r = new StaxConverter().createXMLStreamReader(fis, exchange); + InputStream is = IOHelper.buffered(new FileInputStream(file)); + XMLStreamReader r = new StaxConverter().createXMLStreamReader(is, exchange); return new StAXSource(r); } @@ -596,8 +597,8 @@ public class XmlConverter { @Converter public DOMSource toDOMSource(File file) throws ParserConfigurationException, IOException, SAXException { - FileInputStream fis = new FileInputStream(file); - return toDOMSource(fis); + InputStream is = IOHelper.buffered(new FileInputStream(file)); + return toDOMSource(is); } @Converter @@ -862,6 +863,12 @@ public class XmlConverter { return new InputSource(is); } + @Converter + public InputSource toInputSource(File file, Exchange exchange) throws FileNotFoundException { + InputStream is = IOHelper.buffered(new FileInputStream(file)); + return new InputSource(is); + } + // Properties //------------------------------------------------------------------------- public DocumentBuilderFactory getDocumentBuilderFactory() { Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java Thu Dec 22 20:41:32 2011 @@ -16,7 +16,6 @@ */ package org.apache.camel.converter.stream; -import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -30,6 +29,7 @@ import org.apache.camel.Exchange; import org.apache.camel.StreamCache; import org.apache.camel.impl.SynchronizationAdapter; import org.apache.camel.util.FileUtil; +import org.apache.camel.util.IOHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -207,7 +207,7 @@ public class CachedOutputStream extends LOG.trace("Creating temporary stream cache file: {}", tempFile); try { - currentStream = new BufferedOutputStream(new FileOutputStream(tempFile)); + currentStream = IOHelper.buffered(new FileOutputStream(tempFile)); bout.writeTo(currentStream); } finally { // ensure flag is flipped to file based Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/stream/FileInputStreamCache.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/stream/FileInputStreamCache.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/stream/FileInputStreamCache.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/stream/FileInputStreamCache.java Thu Dec 22 20:41:32 2011 @@ -16,8 +16,6 @@ */ package org.apache.camel.converter.stream; -import java.io.BufferedInputStream; -import java.io.Closeable; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -35,7 +33,7 @@ public class FileInputStreamCache extend public FileInputStreamCache(File file) throws FileNotFoundException { this.file = file; - this.stream = new BufferedInputStream(new FileInputStream(file)); + this.stream = IOHelper.buffered(new FileInputStream(file)); } @Override @@ -51,7 +49,7 @@ public class FileInputStreamCache extend // reset by closing and creating a new stream based on the file close(); // reset by creating a new stream based on the file - stream = new BufferedInputStream(new FileInputStream(file)); + stream = IOHelper.buffered(new FileInputStream(file)); } catch (FileNotFoundException e) { throw new RuntimeCamelException("Cannot reset stream from file " + file, e); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultFactoryFinder.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultFactoryFinder.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultFactoryFinder.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultFactoryFinder.java Thu Dec 22 20:41:32 2011 @@ -142,7 +142,7 @@ public class DefaultFactoryFinder implem // lets load the file BufferedInputStream reader = null; try { - reader = new BufferedInputStream(in); + reader = IOHelper.buffered(in); Properties properties = new Properties(); properties.load(reader); return properties; Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java Thu Dec 22 20:41:32 2011 @@ -74,6 +74,7 @@ public class AnnotationTypeConverterLoad this.resolver = resolver; } + @Override public void load(TypeConverterRegistry registry) throws TypeConverterLoaderException { String[] packageNames; @@ -120,7 +121,7 @@ public class AnnotationTypeConverterLoad } // load all the found classes into the type converter registry - for (Class type : classes) { + for (Class type : classes) { if (LOG.isTraceEnabled()) { LOG.trace("Loading converter class: {}", ObjectHelper.name(type)); } @@ -213,7 +214,7 @@ public class AnnotationTypeConverterLoad // remember we have visited this uri so we wont read it twice visitedURIs.add(path); LOG.debug("Loading file {} to retrieve list of packages, from url: {}", META_INF_SERVICES, url); - BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); + BufferedReader reader = IOHelper.buffered(new InputStreamReader(url.openStream())); try { while (true) { String line = reader.readLine(); Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/ArrayTypeConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/ArrayTypeConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/ArrayTypeConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/ArrayTypeConverter.java Thu Dec 22 20:41:32 2011 @@ -38,7 +38,7 @@ public class ArrayTypeConverter implemen public T convertTo(Class type, Object value) { if (type.isArray()) { if (value instanceof Collection) { - Collection collection = (Collection)value; + Collection collection = (Collection)value; Object array = Array.newInstance(type.getComponentType(), collection.size()); if (array instanceof Object[]) { collection.toArray((Object[])array); @@ -63,7 +63,7 @@ public class ArrayTypeConverter implemen return (T)Arrays.asList((Object[])value); } else if (value.getClass().isArray()) { int size = Array.getLength(value); - List answer = new ArrayList(size); + List answer = new ArrayList(size); for (int i = 0; i < size; i++) { answer.add(Array.get(value, i)); } @@ -74,14 +74,17 @@ public class ArrayTypeConverter implemen return null; } + @Override public T convertTo(Class type, Exchange exchange, Object value) { return convertTo(type, value); } + @Override public T mandatoryConvertTo(Class type, Object value) { return convertTo(type, value); } + @Override public T mandatoryConvertTo(Class type, Exchange exchange, Object value) { return convertTo(type, value); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java Thu Dec 22 20:41:32 2011 @@ -83,14 +83,17 @@ public class AsyncProcessorTypeConverter return null; } + @Override public T convertTo(Class type, Exchange exchange, Object value) { return convertTo(type, value); } + @Override public T mandatoryConvertTo(Class type, Object value) throws NoTypeConversionAvailableException { return convertTo(type, value); } + @Override public T mandatoryConvertTo(Class type, Exchange exchange, Object value) throws NoTypeConversionAvailableException { return convertTo(type, exchange, value); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java Thu Dec 22 20:41:32 2011 @@ -39,7 +39,6 @@ import org.apache.camel.spi.TypeConverte import org.apache.camel.spi.TypeConverterLoader; import org.apache.camel.spi.TypeConverterRegistry; import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.ServiceHelper; import org.apache.camel.util.StopWatch; import org.apache.camel.util.TimeUtils; import org.slf4j.Logger; @@ -88,11 +87,13 @@ public abstract class BaseTypeConverterR return typeConverterLoaders; } + @Override public T convertTo(Class type, Object value) { return convertTo(type, null, value); } @SuppressWarnings("unchecked") + @Override public T convertTo(Class type, Exchange exchange, Object value) { if (!isRunAllowed()) { throw new IllegalStateException(this + " is not started"); @@ -123,11 +124,13 @@ public abstract class BaseTypeConverterR } } + @Override public T mandatoryConvertTo(Class type, Object value) throws NoTypeConversionAvailableException { return mandatoryConvertTo(type, null, value); } @SuppressWarnings("unchecked") + @Override public T mandatoryConvertTo(Class type, Exchange exchange, Object value) throws NoTypeConversionAvailableException { if (!isRunAllowed()) { throw new IllegalStateException(this + " is not started"); @@ -147,8 +150,7 @@ public abstract class BaseTypeConverterR } } - @SuppressWarnings("unchecked") - protected Object doConvertTo(final Class type, final Exchange exchange, final Object value) { + protected Object doConvertTo(final Class type, final Exchange exchange, final Object value) { if (log.isTraceEnabled()) { log.trace("Converting {} -> {} with value: {}", new Object[]{value == null ? "null" : value.getClass().getCanonicalName(), @@ -218,7 +220,7 @@ public abstract class BaseTypeConverterR // not found with that type then if it was a primitive type then try again with the wrapper type if (type.isPrimitive()) { - Class primitiveType = ObjectHelper.convertPrimitiveTypeToWrapperType(type); + Class primitiveType = ObjectHelper.convertPrimitiveTypeToWrapperType(type); if (primitiveType != type) { return convertTo(primitiveType, exchange, value); } @@ -231,6 +233,7 @@ public abstract class BaseTypeConverterR return Void.TYPE; } + @Override public void addTypeConverter(Class toType, Class fromType, TypeConverter typeConverter) { log.trace("Adding type converter: {}", typeConverter); TypeMapping key = new TypeMapping(toType, fromType); @@ -249,6 +252,7 @@ public abstract class BaseTypeConverterR } } + @Override public void addFallbackTypeConverter(TypeConverter typeConverter, boolean canPromote) { log.trace("Adding fallback type converter: {} which can promote: {}", typeConverter, canPromote); @@ -265,10 +269,12 @@ public abstract class BaseTypeConverterR return typeMappings.get(key); } + @Override public Injector getInjector() { return injector; } + @Override public void setInjector(Injector injector) { this.injector = injector; } @@ -319,6 +325,7 @@ public abstract class BaseTypeConverterR return converter; } + @Override public TypeConverter lookup(Class toType, Class fromType) { return doLookup(toType, fromType, false); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java Thu Dec 22 20:41:32 2011 @@ -47,16 +47,19 @@ public class EnumTypeConverter implement return null; } + @Override public T convertTo(Class type, Exchange exchange, Object value) { // ignore exchange return convertTo(type, value); } + @Override public T mandatoryConvertTo(Class type, Object value) { // ignore exchange return convertTo(type, value); } + @Override public T mandatoryConvertTo(Class type, Exchange exchange, Object value) { // ignore exchange return convertTo(type, value); Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/FutureTypeConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/FutureTypeConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/FutureTypeConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/FutureTypeConverter.java Thu Dec 22 20:41:32 2011 @@ -53,7 +53,7 @@ public final class FutureTypeConverter i if (Future.class.isAssignableFrom(value.getClass())) { - Future future = (Future) value; + Future future = (Future) value; if (future.isCancelled()) { // return void to indicate its not possible to convert at this time @@ -86,10 +86,12 @@ public final class FutureTypeConverter i return null; } + @Override public T convertTo(Class type, Object value) { return convertTo(type, null, value); } + @Override public T convertTo(Class type, Exchange exchange, Object value) { try { return doConvertTo(type, exchange, value); @@ -98,10 +100,12 @@ public final class FutureTypeConverter i } } + @Override public T mandatoryConvertTo(Class type, Object value) throws NoTypeConversionAvailableException { return mandatoryConvertTo(type, null, value); } + @Override public T mandatoryConvertTo(Class type, Exchange exchange, Object value) throws NoTypeConversionAvailableException { T answer; try { Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/InstanceMethodFallbackTypeConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/InstanceMethodFallbackTypeConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/InstanceMethodFallbackTypeConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/InstanceMethodFallbackTypeConverter.java Thu Dec 22 20:41:32 2011 @@ -48,6 +48,7 @@ public class InstanceMethodFallbackTypeC return "InstanceMethodFallbackTypeConverter: " + method; } + @Override public T convertTo(Class type, Object value) { return convertTo(type, null, value); } @@ -63,10 +64,12 @@ public class InstanceMethodFallbackTypeC .invokeMethod(method, instance, type, value, registry); } + @Override public T mandatoryConvertTo(Class type, Object value) { return convertTo(type, null, value); } + @Override public T mandatoryConvertTo(Class type, Exchange exchange, Object value) { return convertTo(type, null, value); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/InstanceMethodTypeConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/InstanceMethodTypeConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/InstanceMethodTypeConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/InstanceMethodTypeConverter.java Thu Dec 22 20:41:32 2011 @@ -49,6 +49,7 @@ public class InstanceMethodTypeConverter return "InstanceMethodTypeConverter: " + method; } + @Override public T convertTo(Class type, Object value) { return convertTo(type, null, value); } @@ -71,10 +72,12 @@ public class InstanceMethodTypeConverter .invokeMethod(method, instance, value); } + @Override public T mandatoryConvertTo(Class type, Object value) { return convertTo(type, null, value); } + @Override public T mandatoryConvertTo(Class type, Exchange exchange, Object value) { return convertTo(type, null, value); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/LazyLoadingTypeConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/LazyLoadingTypeConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/LazyLoadingTypeConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/LazyLoadingTypeConverter.java Thu Dec 22 20:41:32 2011 @@ -43,7 +43,7 @@ public class LazyLoadingTypeConverter ex } @Override - protected Object doConvertTo(final Class type, final Exchange exchange, final Object value) { + protected Object doConvertTo(final Class type, final Exchange exchange, final Object value) { Object answer = super.doConvertTo(type, exchange, value); if (answer == null && !loaded.get()) { // okay we could not convert, so try again, but load the converters up front Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/PropertyEditorTypeConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/PropertyEditorTypeConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/PropertyEditorTypeConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/PropertyEditorTypeConverter.java Thu Dec 22 20:41:32 2011 @@ -48,6 +48,7 @@ public class PropertyEditorTypeConverter misses.clear(); } + @Override public T convertTo(Class type, Object value) { // We can't convert null values since we can't figure out a property // editor for it. @@ -107,14 +108,17 @@ public class PropertyEditorTypeConverter } } + @Override public T convertTo(Class type, Exchange exchange, Object value) { return convertTo(type, value); } + @Override public T mandatoryConvertTo(Class type, Object value) { return convertTo(type, value); } + @Override public T mandatoryConvertTo(Class type, Exchange exchange, Object value) { return convertTo(type, value); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/StaticMethodFallbackTypeConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/StaticMethodFallbackTypeConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/StaticMethodFallbackTypeConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/StaticMethodFallbackTypeConverter.java Thu Dec 22 20:41:32 2011 @@ -45,6 +45,7 @@ public class StaticMethodFallbackTypeCon return "StaticMethodFallbackTypeConverter: " + method; } + @Override public T convertTo(Class type, Object value) { return convertTo(type, null, value); } @@ -55,10 +56,12 @@ public class StaticMethodFallbackTypeCon : (T)ObjectHelper.invokeMethod(method, null, type, value, registry); } + @Override public T mandatoryConvertTo(Class type, Object value) { return convertTo(type, null, value); } + @Override public T mandatoryConvertTo(Class type, Exchange exchange, Object value) { return convertTo(type, null, value); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/StaticMethodTypeConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/StaticMethodTypeConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/StaticMethodTypeConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/StaticMethodTypeConverter.java Thu Dec 22 20:41:32 2011 @@ -41,6 +41,7 @@ public class StaticMethodTypeConverter i return "StaticMethodTypeConverter: " + method; } + @Override public T convertTo(Class type, Object value) { return convertTo(type, null, value); } @@ -51,10 +52,12 @@ public class StaticMethodTypeConverter i : (T)ObjectHelper.invokeMethod(method, null, value); } + @Override public T mandatoryConvertTo(Class type, Object value) { return convertTo(type, null, value); } + @Override public T mandatoryConvertTo(Class type, Exchange exchange, Object value) { return convertTo(type, null, value); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/ToStringTypeConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/ToStringTypeConverter.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/ToStringTypeConverter.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/converter/ToStringTypeConverter.java Thu Dec 22 20:41:32 2011 @@ -33,6 +33,7 @@ import org.apache.camel.component.file.G public class ToStringTypeConverter implements TypeConverter { @SuppressWarnings("unchecked") + @Override public T convertTo(Class toType, Object value) { if (value != null) { @@ -63,14 +64,17 @@ public class ToStringTypeConverter imple return null; } + @Override public T convertTo(Class type, Exchange exchange, Object value) { return convertTo(type, value); } + @Override public T mandatoryConvertTo(Class type, Object value) { return convertTo(type, value); } + @Override public T mandatoryConvertTo(Class type, Exchange exchange, Object value) { return convertTo(type, value); } Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java Thu Dec 22 20:41:32 2011 @@ -123,7 +123,7 @@ public class Activator implements Bundle protected void registerComponents(Bundle bundle, List resolvers) { if (checkCompat(bundle, Component.class)) { Map components = new HashMap(); - for (Enumeration e = bundle.getEntryPaths(META_INF_COMPONENT); e != null && e.hasMoreElements();) { + for (Enumeration e = bundle.getEntryPaths(META_INF_COMPONENT); e != null && e.hasMoreElements();) { String path = (String) e.nextElement(); LOG.debug("Found entry: {} in bundle {}", path, bundle.getSymbolicName()); String name = path.substring(path.lastIndexOf("/") + 1); @@ -138,7 +138,7 @@ public class Activator implements Bundle protected void registerLanguages(Bundle bundle, List resolvers) { if (checkCompat(bundle, Language.class)) { Map languages = new HashMap(); - for (Enumeration e = bundle.getEntryPaths(META_INF_LANGUAGE); e != null && e.hasMoreElements();) { + for (Enumeration e = bundle.getEntryPaths(META_INF_LANGUAGE); e != null && e.hasMoreElements();) { String path = (String) e.nextElement(); LOG.debug("Found entry: {} in bundle {}", path, bundle.getSymbolicName()); String name = path.substring(path.lastIndexOf("/") + 1); @@ -147,7 +147,7 @@ public class Activator implements Bundle if (!languages.isEmpty()) { resolvers.add(new BundleLanguageResolver(bundle, languages)); } - for (Enumeration e = bundle.getEntryPaths(META_INF_LANGUAGE_RESOLVER); e != null && e.hasMoreElements();) { + for (Enumeration e = bundle.getEntryPaths(META_INF_LANGUAGE_RESOLVER); e != null && e.hasMoreElements();) { String path = (String) e.nextElement(); LOG.debug("Found entry: {} in bundle {}", path, bundle.getSymbolicName()); String name = path.substring(path.lastIndexOf("/") + 1); @@ -159,7 +159,7 @@ public class Activator implements Bundle protected void registerDataFormats(Bundle bundle, List resolvers) { if (checkCompat(bundle, DataFormat.class)) { Map dataformats = new HashMap(); - for (Enumeration e = bundle.getEntryPaths(META_INF_DATAFORMAT); e != null && e.hasMoreElements();) { + for (Enumeration e = bundle.getEntryPaths(META_INF_DATAFORMAT); e != null && e.hasMoreElements();) { String path = (String) e.nextElement(); LOG.debug("Found entry: {} in bundle {}", path, bundle.getSymbolicName()); String name = path.substring(path.lastIndexOf("/") + 1); @@ -319,7 +319,7 @@ public class Activator implements Bundle // its a FQN class name so load it directly LOG.trace("Loading {} class", pkg); try { - Class clazz = bundle.loadClass(pkg); + Class clazz = bundle.loadClass(pkg); if (test.matches(clazz)) { classes.add(clazz); } @@ -338,7 +338,7 @@ public class Activator implements Bundle String externalName = path.substring(path.charAt(0) == '/' ? 1 : 0, path.indexOf('.')).replace('/', '.'); LOG.trace("Loading {} class", externalName); try { - Class clazz = bundle.loadClass(externalName); + Class clazz = bundle.loadClass(externalName); if (test.matches(clazz)) { classes.add(clazz); } @@ -351,7 +351,7 @@ public class Activator implements Bundle // load the classes into type converter registry LOG.info("Found {} @Converter classes to load", classes.size()); - for (Class type : classes) { + for (Class type : classes) { if (LOG.isTraceEnabled()) { LOG.trace("Loading converter class: {}", ObjectHelper.name(type)); } @@ -419,21 +419,21 @@ public class Activator implements Bundle public abstract void register(); - protected void doRegister(Class type, String key, Collection value) { + protected void doRegister(Class type, String key, Collection value) { doRegister(type, key, value.toArray(new String[value.size()])); } - protected void doRegister(Class type, String key, Object value) { + protected void doRegister(Class type, String key, Object value) { Hashtable props = new Hashtable(); props.put(key, value); doRegister(type, props); } - protected void doRegister(Class type) { + protected void doRegister(Class type) { doRegister(type, null); } - protected void doRegister(Class type, Dictionary props) { + protected void doRegister(Class type, Dictionary props) { reg = bundle.getBundleContext().registerService(type.getName(), this, props); } @@ -446,7 +446,7 @@ public class Activator implements Bundle Properties properties = new Properties(); BufferedInputStream reader = null; try { - reader = new BufferedInputStream(url.openStream()); + reader = IOHelper.buffered(url.openStream()); properties.load(reader); } catch (IOException e) { throw new RuntimeException(e); @@ -456,7 +456,7 @@ public class Activator implements Bundle return properties; } - protected static boolean checkCompat(Bundle bundle, Class clazz) { + protected static boolean checkCompat(Bundle bundle, Class clazz) { // Check bundle compatibility try { if (bundle.loadClass(clazz.getName()) != clazz) { @@ -473,7 +473,7 @@ public class Activator implements Bundle if (resource != null) { BufferedReader reader = null; try { - reader = new BufferedReader(new InputStreamReader(resource.openStream())); + reader = IOHelper.buffered(new InputStreamReader(resource.openStream())); while (true) { String line = reader.readLine(); if (line == null) { Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/util/IOHelper.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/util/IOHelper.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/util/IOHelper.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/util/IOHelper.java Thu Dec 22 20:41:32 2011 @@ -16,11 +16,17 @@ */ package org.apache.camel.util; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.Reader; import java.io.UnsupportedEncodingException; +import java.io.Writer; import java.nio.charset.Charset; import java.nio.charset.UnsupportedCharsetException; @@ -67,6 +73,66 @@ public final class IOHelper { } /** + * Wraps the passed in into a {@link BufferedInputStream} + * object and returns that. If the passed in is already an + * instance of {@link BufferedInputStream} returns the same passed + * in reference as is (avoiding double wrapping). + * + * @param in the wrapee to be used for the buffering support + * @return the passed in decorated through a + * {@link BufferedInputStream} object as wrapper + */ + public static BufferedInputStream buffered(InputStream in) { + ObjectHelper.notNull(in, "in"); + return (in instanceof BufferedInputStream) ? (BufferedInputStream)in : new BufferedInputStream(in); + } + + /** + * Wraps the passed out into a {@link BufferedOutputStream} + * object and returns that. If the passed out is already an + * instance of {@link BufferedOutputStream} returns the same passed + * out reference as is (avoiding double wrapping). + * + * @param out the wrapee to be used for the buffering support + * @return the passed out decorated through a + * {@link BufferedOutputStream} object as wrapper + */ + public static BufferedOutputStream buffered(OutputStream out) { + ObjectHelper.notNull(out, "out"); + return (out instanceof BufferedOutputStream) ? (BufferedOutputStream)out : new BufferedOutputStream(out); + } + + /** + * Wraps the passed reader into a {@link BufferedReader} object + * and returns that. If the passed reader is already an + * instance of {@link BufferedReader} returns the same passed + * reader reference as is (avoiding double wrapping). + * + * @param reader the wrapee to be used for the buffering support + * @return the passed reader decorated through a + * {@link BufferedReader} object as wrapper + */ + public static BufferedReader buffered(Reader reader) { + ObjectHelper.notNull(reader, "reader"); + return (reader instanceof BufferedReader) ? (BufferedReader)reader : new BufferedReader(reader); + } + + /** + * Wraps the passed writer into a {@link BufferedWriter} object + * and returns that. If the passed writer is already an + * instance of {@link BufferedWriter} returns the same passed + * writer reference as is (avoiding double wrapping). + * + * @param writer the wrapee to be used for the buffering support + * @return the passed writer decorated through a + * {@link BufferedWriter} object as wrapper + */ + public static BufferedWriter buffered(Writer writer) { + ObjectHelper.notNull(writer, "writer"); + return (writer instanceof BufferedWriter) ? (BufferedWriter)writer : new BufferedWriter(writer); + } + + /** * A factory method which creates an {@link IOException} from the given * exception and message * Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Thu Dec 22 20:41:32 2011 @@ -26,7 +26,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.net.URL; import java.nio.channels.ReadableByteChannel; import java.nio.charset.Charset; @@ -120,7 +119,7 @@ public final class ObjectHelper { * types between the left and right values. This allows you to equal test eg String and Integer as * Camel will be able to coerce the types */ - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) public static int typeCoerceCompare(TypeConverter converter, Object leftValue, Object rightValue) { // if both values is numeric then compare using numeric @@ -226,7 +225,7 @@ public final class ObjectHelper { * @param b the second object * @param ignoreCase ignore case for string comparison */ - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) public static int compare(Object a, Object b, boolean ignoreCase) { if (a == b) { return 0; @@ -428,14 +427,14 @@ public final class ObjectHelper { */ public static boolean contains(Object collectionOrArray, Object value) { if (collectionOrArray instanceof Collection) { - Collection collection = (Collection)collectionOrArray; + Collection collection = (Collection)collectionOrArray; return collection.contains(value); } else if (collectionOrArray instanceof String && value instanceof String) { String str = (String)collectionOrArray; String subStr = (String)value; return str.contains(subStr); } else { - Iterator iter = createIterator(collectionOrArray); + Iterator iter = createIterator(collectionOrArray); while (iter.hasNext()) { if (equal(value, iter.next())) { return true; @@ -478,9 +477,9 @@ public final class ObjectHelper { if (value == null) { return Collections.emptyList().iterator(); } else if (value instanceof Iterator) { - return (Iterator)value; + return (Iterator)value; } else if (value instanceof Iterable) { - return ((Iterable)value).iterator(); + return ((Iterable)value).iterator(); } else if (value.getClass().isArray()) { // TODO we should handle primitive array types? List list = Arrays.asList((Object[])value); @@ -547,7 +546,7 @@ public final class ObjectHelper { * @return true if the first element is a boolean and its value * is true or if the list is non empty */ - public static boolean matches(List list) { + public static boolean matches(List list) { if (!list.isEmpty()) { Object value = list.get(0); if (value instanceof Boolean) { @@ -1040,7 +1039,7 @@ public final class ObjectHelper { if (toType == boolean.class) { return (T)cast(Boolean.class, value); } else if (toType.isPrimitive()) { - Class newType = convertPrimitiveTypeToWrapperType(toType); + Class newType = convertPrimitiveTypeToWrapperType(toType); if (newType != toType) { return (T)cast(newType, value); } @@ -1085,9 +1084,9 @@ public final class ObjectHelper { /** * Does the given class have a default public no-arg constructor. */ - public static boolean hasDefaultPublicNoArgConstructor(Class type) { + public static boolean hasDefaultPublicNoArgConstructor(Class type) { // getConstructors() returns only public constructors - for (Constructor ctr : type.getConstructors()) { + for (Constructor ctr : type.getConstructors()) { if (ctr.getParameterTypes().length == 0) { return true; } @@ -1143,7 +1142,7 @@ public final class ObjectHelper { return list.getLength() > 0; } else if (value instanceof Collection) { // is it an empty collection - Collection col = (Collection) value; + Collection col = (Collection) value; return col.size() > 0; } return value != null; @@ -1301,7 +1300,7 @@ public final class ObjectHelper { * @param name the name of the field to lookup * @return the value of the constant field, or null if not found */ - public static String lookupConstantFieldValue(Class clazz, String name) { + public static String lookupConstantFieldValue(Class clazz, String name) { if (clazz == null) { return null; } Modified: camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/component/file/GenericFileConverterTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/component/file/GenericFileConverterTest.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/component/file/GenericFileConverterTest.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/component/file/GenericFileConverterTest.java Thu Dec 22 20:41:32 2011 @@ -16,8 +16,8 @@ */ package org.apache.camel.component.file; +import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; import java.io.Serializable; @@ -157,7 +157,7 @@ public class GenericFileConverterTest ex @Override public void process(Exchange exchange) throws Exception { Object body = exchange.getIn().getBody(); - assertIsInstanceOf(FileInputStream.class, body); + assertIsInstanceOf(BufferedInputStream.class, body); } }) .to("mock:result"); @@ -165,9 +165,11 @@ public class GenericFileConverterTest ex }); context.start(); + // a file input stream is wrapped in a buffered so its faster + MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - mock.message(0).body().isInstanceOf(FileInputStream.class); + mock.message(0).body().isInstanceOf(BufferedInputStream.class); mock.message(0).body(String.class).isEqualTo("Hello World"); template.sendBodyAndHeader("file://target/gf", "Hello World", Exchange.FILE_NAME, "hello.txt"); Modified: camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/CollectionConverterTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/CollectionConverterTest.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/CollectionConverterTest.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/CollectionConverterTest.java Thu Dec 22 20:41:32 2011 @@ -19,7 +19,6 @@ package org.apache.camel.converter; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; -import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -27,12 +26,12 @@ import java.util.Properties; import java.util.Set; import junit.framework.TestCase; + import org.apache.camel.util.CaseInsensitiveMap; /** * Test cases for {@link CollectionConverter} */ -@SuppressWarnings("unchecked") public class CollectionConverterTest extends TestCase { private static final List SMURFS = Arrays.asList("Papa smurf", "Smurfette", "Hefty smurf", "Jokey smurf"); @@ -42,13 +41,13 @@ public class CollectionConverterTest ext } public void testIterableToList() throws Exception { - assertSmurfs(CollectionConverter.toList(new Iterable() { - public Iterator iterator() { + assertSmurfs(CollectionConverter.toList(new Iterable() { + public Iterator iterator() { return SMURFS.iterator(); } })); // no conversion should occur for the list itself - assertSame(SMURFS, CollectionConverter.toList((Iterable) SMURFS)); + assertSame(SMURFS, CollectionConverter.toList((Iterable) SMURFS)); } private void assertSmurfs(Collection result) { @@ -65,36 +64,36 @@ public class CollectionConverterTest ext } public void testToList() { - List out = CollectionConverter.toList(SMURFS); + List out = CollectionConverter.toList(SMURFS); assertEquals(4, out.size()); } public void testToSet() { - Map map = new HashMap(); + Map map = new HashMap(); map.put("foo", "bar"); - Set out = CollectionConverter.toSet(map); + Set> out = CollectionConverter.toSet(map); assertEquals(1, out.size()); } public void testToHashMap() { - Map map = new CaseInsensitiveMap(); + Map map = new CaseInsensitiveMap(); map.put("foo", "bar"); - HashMap out = CollectionConverter.toHashMap(map); + Map out = CollectionConverter.toHashMap(map); assertEquals(1, out.size()); } public void testToHashtable() { - Map map = new CaseInsensitiveMap(); + Map map = new CaseInsensitiveMap(); map.put("foo", "bar"); - Hashtable out = CollectionConverter.toHashtable(map); + Map out = CollectionConverter.toHashtable(map); assertEquals(1, out.size()); } public void testToProperties() { - Map map = new HashMap(); + Map map = new HashMap(); map.put("foo", "bar"); Properties prop = CollectionConverter.toProperties(map); Modified: camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/FutureConverterTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/FutureConverterTest.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/FutureConverterTest.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/FutureConverterTest.java Thu Dec 22 20:41:32 2011 @@ -31,14 +31,14 @@ import org.apache.camel.impl.DefaultExch public class FutureConverterTest extends ContextTestSupport { public void testConvertFuture() { - Future future = template.asyncRequestBody("direct:foo", "Hello World"); + Future future = template.asyncRequestBody("direct:foo", "Hello World"); String out = context.getTypeConverter().convertTo(String.class, future); assertEquals("Bye World", out); } public void testConvertMandatoryFuture() throws Exception { - Future future = template.asyncRequestBody("direct:foo", "Hello World"); + Future future = template.asyncRequestBody("direct:foo", "Hello World"); String out = context.getTypeConverter().mandatoryConvertTo(String.class, future); assertEquals("Bye World", out); @@ -46,7 +46,7 @@ public class FutureConverterTest extends public void testConvertMandatoryFutureWithExchange() throws Exception { Exchange exchange = new DefaultExchange(context); - Future future = template.asyncRequestBody("direct:foo", "Hello World"); + Future future = template.asyncRequestBody("direct:foo", "Hello World"); String out = context.getTypeConverter().mandatoryConvertTo(String.class, exchange, future); assertEquals("Bye World", out); @@ -54,7 +54,7 @@ public class FutureConverterTest extends public void testConvertMandatoryFutureWithExchangeFailed() throws Exception { Exchange exchange = new DefaultExchange(context); - Future future = template.asyncRequestBody("direct:foo", "Hello World"); + Future future = template.asyncRequestBody("direct:foo", "Hello World"); try { context.getTypeConverter().mandatoryConvertTo(Timestamp.class, exchange, future); @@ -66,14 +66,14 @@ public class FutureConverterTest extends public void testConvertFutureWithExchangeFailed() throws Exception { Exchange exchange = new DefaultExchange(context); - Future future = template.asyncRequestBody("direct:foo", "Hello World"); + Future future = template.asyncRequestBody("direct:foo", "Hello World"); Timestamp out = context.getTypeConverter().convertTo(Timestamp.class, exchange, future); assertNull(out); } public void testConvertFutureCancelled() { - Future future = template.asyncRequestBody("direct:foo", "Hello World"); + Future future = template.asyncRequestBody("direct:foo", "Hello World"); future.cancel(true); Object out = context.getTypeConverter().convertTo(String.class, future); @@ -82,7 +82,7 @@ public class FutureConverterTest extends } public void testConvertFutureCancelledThenOkay() { - Future future = template.asyncRequestBody("direct:foo", "Hello World"); + Future future = template.asyncRequestBody("direct:foo", "Hello World"); future.cancel(true); Object out = context.getTypeConverter().convertTo(String.class, future); Modified: camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/IOConverterTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/IOConverterTest.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/IOConverterTest.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/IOConverterTest.java Thu Dec 22 20:41:32 2011 @@ -16,7 +16,10 @@ */ package org.apache.camel.converter; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -76,7 +79,7 @@ public class IOConverterTest extends Con File file = new File("target/test/hello.txt"); OutputStream os = IOConverter.toOutputStream(file); - assertNotNull(os); + assertIsInstanceOf(BufferedOutputStream.class, os); os.close(); } @@ -85,12 +88,12 @@ public class IOConverterTest extends Con File file = new File("target/test/hello.txt"); Writer writer = IOConverter.toWriter(file, null); - assertNotNull(writer); + assertIsInstanceOf(BufferedWriter.class, writer); writer.close(); } public void testToReader() throws Exception { - Reader reader = IOConverter.toReader("Hello"); + StringReader reader = IOConverter.toReader("Hello"); assertEquals("Hello", IOConverter.toString(reader)); } @@ -123,7 +126,7 @@ public class IOConverterTest extends Con Exchange exchange = new DefaultExchange(context); exchange.setProperty(Exchange.CHARSET_NAME, ObjectHelper.getDefaultCharacterSet()); - BufferedReader br = new BufferedReader(new StringReader("Hello World")); + BufferedReader br = IOHelper.buffered(new StringReader("Hello World")); InputStream is = IOConverter.toInputStream(br, exchange); assertNotNull(is); } @@ -138,21 +141,21 @@ public class IOConverterTest extends Con } public void testToStringBufferReader() throws Exception { - BufferedReader br = new BufferedReader(new StringReader("Hello World")); + BufferedReader br = IOHelper.buffered(new StringReader("Hello World")); String s = IOConverter.toString(br); assertNotNull(s); assertEquals("Hello World", s); } public void testToByteArrayBufferReader() throws Exception { - BufferedReader br = new BufferedReader(new StringReader("Hello World")); + BufferedReader br = IOHelper.buffered(new StringReader("Hello World")); byte[] bytes = IOConverter.toByteArray(br, null); assertNotNull(bytes); assertEquals(11, bytes.length); } public void testToByteArrayReader() throws Exception { - Reader br = new BufferedReader(new StringReader("Hello World")); + Reader br = IOHelper.buffered(new StringReader("Hello World")); byte[] bytes = IOConverter.toByteArray(br, null); assertNotNull(bytes); assertEquals(11, bytes.length); @@ -186,7 +189,7 @@ public class IOConverterTest extends Con public void testToInputStreamUrl() throws Exception { URL url = ObjectHelper.loadResourceAsURL("log4j.properties"); InputStream is = IOConverter.toInputStream(url); - assertNotNull(is); + assertIsInstanceOf(BufferedInputStream.class, is); } public void testStringUrl() throws Exception { @@ -199,7 +202,7 @@ public class IOConverterTest extends Con BufferedReader reader = null; assertNull(IOConverter.toString(reader)); - BufferedReader br = new BufferedReader(new StringReader("Hello World")); + BufferedReader br = IOHelper.buffered(new StringReader("Hello World")); assertEquals("Hello World", IOConverter.toString(br)); } Modified: camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java Thu Dec 22 20:41:32 2011 @@ -35,7 +35,7 @@ public class ObjectConverterTest extends } public void testIterator() { - Iterator it = ObjectConverter.iterator("Claus,Jonathan"); + Iterator it = ObjectConverter.iterator("Claus,Jonathan"); assertEquals("Claus", it.next()); assertEquals("Jonathan", it.next()); assertEquals(false, it.hasNext()); Modified: camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/ObjectHelperTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/ObjectHelperTest.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/ObjectHelperTest.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/ObjectHelperTest.java Thu Dec 22 20:41:32 2011 @@ -38,7 +38,7 @@ public class ObjectHelperTest extends Te public void testArrayAsIterator() throws Exception { String[] data = {"a", "b"}; - Iterator iter = ObjectHelper.createIterator(data); + Iterator iter = ObjectHelper.createIterator(data); assertTrue("should have next", iter.hasNext()); Object a = iter.next(); assertEquals("a", "a", a); @@ -69,21 +69,21 @@ public class ObjectHelperTest extends Te } public void testIteratorWithComma() { - Iterator it = ObjectHelper.createIterator("Claus,Jonathan"); + Iterator it = ObjectHelper.createIterator("Claus,Jonathan"); assertEquals("Claus", it.next()); assertEquals("Jonathan", it.next()); assertEquals(false, it.hasNext()); } public void testIteratorWithOtherDelimiter() { - Iterator it = ObjectHelper.createIterator("Claus#Jonathan", "#"); + Iterator it = ObjectHelper.createIterator("Claus#Jonathan", "#"); assertEquals("Claus", it.next()); assertEquals("Jonathan", it.next()); assertEquals(false, it.hasNext()); } public void testIteratorEmpty() { - Iterator it = ObjectHelper.createIterator(""); + Iterator it = ObjectHelper.createIterator(""); assertEquals(false, it.hasNext()); it = ObjectHelper.createIterator(" "); @@ -94,7 +94,7 @@ public class ObjectHelperTest extends Te } public void testIteratorIdempotentNext() { - Iterator it = ObjectHelper.createIterator("a"); + Iterator it = ObjectHelper.createIterator("a"); assertTrue(it.hasNext()); assertTrue(it.hasNext()); it.next(); @@ -113,7 +113,7 @@ public class ObjectHelperTest extends Te } }; - Iterator it = ObjectHelper.createIterator(nodeList); + Iterator it = ObjectHelper.createIterator(nodeList); assertTrue(it.hasNext()); assertTrue(it.hasNext()); it.next(); Modified: camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/jaxp/DomConverterTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/jaxp/DomConverterTest.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/jaxp/DomConverterTest.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/jaxp/DomConverterTest.java Thu Dec 22 20:41:32 2011 @@ -62,11 +62,11 @@ public class DomConverterTest extends Co Document document = context.getTypeConverter().convertTo(Document.class, "" + "Hello WorldBye Camel"); - List list = DomConverter.toList(document.getElementsByTagName("foo")); + List list = DomConverter.toList(document.getElementsByTagName("foo")); assertEquals(1, list.size()); NodeList nl = assertIsInstanceOf(NodeList.class, list.get(0)); - List sub = DomConverter.toList(nl); + List sub = DomConverter.toList(nl); assertEquals(2, sub.size()); assertEquals("Hello World", new DomConverter().toString((NodeList) sub.get(0), null)); Modified: camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java?rev=1222438&r1=1222437&r2=1222438&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java Thu Dec 22 20:41:32 2011 @@ -30,6 +30,7 @@ import org.apache.camel.impl.DefaultExch import org.apache.camel.impl.DefaultUnitOfWork; import org.apache.camel.spi.UnitOfWork; import org.apache.camel.util.CollectionStringBuffer; +import org.apache.camel.util.IOHelper; public class CachedOutputStreamTest extends ContextTestSupport { private static final String TEST_STRING = "This is a test string and it has enough" @@ -51,7 +52,7 @@ public class CachedOutputStreamTest exte } private static String toString(InputStream input) throws IOException { - BufferedReader reader = new BufferedReader(new InputStreamReader(input)); + BufferedReader reader = IOHelper.buffered(new InputStreamReader(input)); CollectionStringBuffer builder = new CollectionStringBuffer(); while (true) { String line = reader.readLine();