jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aaron Smuts (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JCS-56) serialization/deserialization problem across blocks in diskBlockCache
Date Mon, 16 Mar 2009 19:47:50 GMT

    [ https://issues.apache.org/jira/browse/JCS-56?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12682429#action_12682429
] 

Aaron Smuts commented on JCS-56:
--------------------------------

I was able to replicate the problem with a simplified version of the test.

    /**
     * Verify that the block disk cache can handle utf encoded strings.
     * <p>
     * @throws Exception
     */
    public void testUTF8String()
        throws Exception
    {
        String string = "Iñtërnâtiônàlizætiøn";
        StringBuffer sb = new StringBuffer();
        sb.append( string );
        for ( int i = 0; i < 4; i++ )
        {
            sb.append( sb.toString() ); // big string
        }
        string = sb.toString();

        //System.out.println( "The string contains " + string.length() + " characters" );

        String cacheName = "testUTF8String";

        BlockDiskCacheAttributes cattr = new BlockDiskCacheAttributes();
        cattr.setCacheName( cacheName );
        cattr.setMaxKeySize( 100 );
        cattr.setBlockSizeBytes( 100 );
        cattr.setDiskPath( "target/test-sandbox/BlockDiskCacheUnitTest" );
        BlockDiskCache diskCache = new BlockDiskCache( cattr );

        // DO WORK
        diskCache.update( new CacheElement( cacheName, "x", string ) );

        // VERIFY
        assertNotNull( diskCache.get( "x" ) );
        Thread.sleep( 1000 );
        ICacheElement afterElement = diskCache.get( "x" );
        assertNotNull( afterElement );
        System.out.println( "afterElement = " + afterElement );
        String after = (String) afterElement.getVal();

        assertNotNull( after );
        assertEquals( "wrong string after retrieval", string, after );
    }


The error is the log is below:

2009-03-16 15:47:28,837 WARN [CacheEventQueueFactory] - <Could not instantiate custom event
queue [null].  Will use standard single threaded queue.>
2009-03-16 15:47:28,837 INFO [BlockDiskCache] - <Region [testUTF8String] Constructing BlockDiskCache
with attributes 
BlockDiskAttributes 
 DiskPath [target/test-sandbox/BlockDiskCacheUnitTest]
 MaxKeySize [100]
 MaxPurgatorySize [5000]
 BlockSizeBytes [100]
 KeyPersistenceIntervalSeconds [300]>
2009-03-16 15:47:28,837 INFO [BlockDiskCache] - <Region [testUTF8String] Cache file root
directory: [target/test-sandbox/BlockDiskCacheUnitTest]>
2009-03-16 15:47:28,853 INFO [BlockDisk] - <Constructing BlockDisk, blockSizeBytes [100]>
2009-03-16 15:47:28,853 INFO [BlockDiskKeyStore] - <Region [testUTF8String] Cache file
root directory [target/test-sandbox/BlockDiskCacheUnitTest]>
2009-03-16 15:47:28,853 INFO [BlockDiskKeyStore] - <Region [testUTF8String] Key File [C:\dev\jcs\jcs\target\test-sandbox\BlockDiskCacheUnitTest\testUTF8String.key]>
2009-03-16 15:47:28,853 INFO [BlockDiskKeyStore] - <Region [testUTF8String] Set maxKeySize
to: '100'>
2009-03-16 15:47:28,853 WARN [BlockDiskCache] - <Region [testUTF8String] Reseting cache>
2009-03-16 15:47:28,853 INFO [BlockDisk] - <Constructing BlockDisk, blockSizeBytes [100]>
2009-03-16 15:47:28,853 INFO [BlockDiskKeyStore] - <Region [testUTF8String] Set maxKeySize
to: '100'>
2009-03-16 15:47:28,853 INFO [BlockDiskCache] - <Region [testUTF8String] Block Disk Cache
is alive.>
2009-03-16 15:47:28,868 INFO [CacheEventQueue] - <Cache event queue created: CacheEventQueue
[listenerId=282234821, cacheName=testUTF8String]>
2009-03-16 15:47:29,884 ERROR [BlockDiskCache] - <Region [testUTF8String] Failure getting
from disk--IOException, key = x>
java.io.StreamCorruptedException
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1301)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1835)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1759)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)
	at org.apache.jcs.utils.serialization.StandardSerializer.deSerialize(StandardSerializer.java:82)
	at org.apache.jcs.auxiliary.disk.block.BlockDisk.read(BlockDisk.java:265)
	at org.apache.jcs.auxiliary.disk.block.BlockDiskCache.processGet(BlockDiskCache.java:327)
	at org.apache.jcs.auxiliary.AbstractAuxiliaryCacheEventLogging.getWithEventLogging(AbstractAuxiliaryCacheEventLogging.java:91)
	at org.apache.jcs.auxiliary.disk.AbstractDiskCache.doGet(AbstractDiskCache.java:786)
	at org.apache.jcs.auxiliary.disk.AbstractDiskCache.get(AbstractDiskCache.java:290)
	at org.apache.jcs.auxiliary.disk.block.BlockDiskCacheUnitTest.testUTF8String(BlockDiskCacheUnitTest.java:114)
	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:324)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
2009-03-16 15:47:29,884 WARN [BlockDiskCache] - <Region [testUTF8String] Reseting cache>
2009-03-16 15:47:29,884 INFO [BlockDisk] - <Constructing BlockDisk, blockSizeBytes [100]>
2009-03-16 15:47:29,884 INFO [BlockDiskKeyStore] - <Region [testUTF8String] Set maxKeySize
to: '100'>


> serialization/deserialization problem across blocks in diskBlockCache
> ---------------------------------------------------------------------
>
>                 Key: JCS-56
>                 URL: https://issues.apache.org/jira/browse/JCS-56
>             Project: JCS
>          Issue Type: Bug
>    Affects Versions: jcs-1.3
>         Environment: Problem encountered on both xp and linux.
>            Reporter: Robert Fuller
>            Assignee: Aaron Smuts
>         Attachments: cache.ccf, JCSByteArrayTest.java
>
>
> Object containing utf-8 string or byte array may be corrupted on retrieval from disk
cache.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org


Mime
View raw message