You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Babak Vahdat (Commented) (JIRA)" <ji...@apache.org> on 2011/12/01 03:37:39 UTC

[jira] [Commented] (CAMEL-4687) Wrap FileInputStream in BufferedInputStream in the Converter classes to ensure loading from file is faster

    [ https://issues.apache.org/jira/browse/CAMEL-4687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13160597#comment-13160597 ] 

Babak Vahdat commented on CAMEL-4687:
-------------------------------------

IMHO not only reading but also writing should be buffered, so that I attach a potential patch for your consideration:
(the mainly affected classes are by the root packages org.apache.camel.converter.* & org.apache.camel.impl.converter.*)

- InputStream, OutputStream, Reader and Writer io/buffering by IOConverter, StaxConverter and XmlConverter (supported through 4 new utilities by IOHelper)
- removal and fix of @SuppressWarnings usages where possible
- removal of all compiler warnings because of the unused import, raw type usage of generic types, unchecked warnings
- add of the missing @Override annotation (see [1]) in bunch of the places
- updated [2] accordingly to verify the buffering fix
- CS fixes

Running of *all* test on camel-core passed on my box but *not* org.apache.camel.language.TokenPairPredicateTest, however
that seems not to be a side effect of this fix, as after reverting of *all* changes on my workspace that test still continued
to fail, however I didn't look into it in detail as it's out of this ticket's context:

Results :

Failed tests:
  testTokenPairPredicate(org.apache.camel.language.TokenPairPredicateTest): File should not exists target\pair\hello.xml

Tests run: 3945, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25:14.480s
[INFO] Finished at: Thu Dec 01 03:25:48 CET 2011
[INFO] Final Memory: 11M/494M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.8:test (default-test) on project camel-core: There are test failures.

The corresponding stacktrace of the failure is:

{code}
-------------------------------------------------------------------------------
Test set: org.apache.camel.language.TokenPairPredicateTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.086 sec <<< FAILURE!
testTokenPairPredicate(org.apache.camel.language.TokenPairPredicateTest)  Time elapsed: 5.086 sec  <<< FAILURE!
junit.framework.AssertionFailedError: File should not exists target\pair\hello.xml
	at junit.framework.Assert.fail(Assert.java:47)
	at junit.framework.Assert.assertTrue(Assert.java:20)
	at junit.framework.Assert.assertFalse(Assert.java:34)
	at org.apache.camel.language.TokenPairPredicateTest.testTokenPairPredicate(TokenPairPredicateTest.java:46)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at org.apache.camel.TestSupport.runBare(TestSupport.java:59)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:119)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:101)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
	at $Proxy0.invoke(Unknown Source)
	at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
	at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
{code}


[1] http://blogs.oracle.com/ahe/entry/override_snafu 
[2] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/IOConverterTest.java
                
> Wrap FileInputStream in BufferedInputStream in the Converter classes to ensure loading from file is faster
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4687
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4687
>             Project: Camel
>          Issue Type: Task
>          Components: camel-core
>            Reporter: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.9.0
>
>         Attachments: CAMEL-4687.patch
>
>
> We should check the type converters, when creating a new FileInputStream, that the stream gets wrapped in a BufferedInputStream, to ensure the file is loaded faster, as the buffered stream has an internal buffer.
> See CAMEL-4686

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira