
| Key: |
CACHE-73
|
| Type: |
Bug
|
| Status: |
Closed
|
| Resolution: |
Fixed
|
| Priority: |
Major
|
| Assignee: |
Unassigned
|
| Reporter: |
Martin Heitz
|
| Votes: |
3
|
| Watchers: |
2
|
|
If you were logged in you would be able to see more operations.
|
|
|
|
Environment:
|
java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)
java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)
|
|
|
In the deserialization of AbstractConcurrentReadCache the "table" variable seems to remain null (although the code looks fine at first glance in readObject()).
(This problem seems to exist already in Version 1.7.5, where I also received a NPex after deserialization.)
Reproduceability with the following simple JUnit test
/**
* tests the serialization and deserialization of OSCache
*
* @throws IOException if test fails
* @throws ClassNotFoundException if test fails
*/
public void testCacheSerialization()
throws IOException, ClassNotFoundException, NeedsRefreshException
{
final Cache written = new Cache(true, false);
written.putInCache("key", "before");
assertEquals("failed to put in cache before serialization", "before", written.getFromCache("key"));
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(written);
final byte[] serialized = baos.toByteArray();
baos.close();
final ByteArrayInputStream bais = new ByteArrayInputStream(serialized);
final ObjectInputStream ois = new ObjectInputStream(bais);
final Cache read = (Cache) ois.readObject();
ois.close();
read.getFromCache("key");
}
...
causes
...
java.lang.NullPointerException
at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.get(AbstractConcurrentReadCache.java:686)
at com.opensymphony.oscache.base.Cache.getCacheEntry(Cache.java:594)
at com.opensymphony.oscache.base.Cache.getFromCache(Cache.java:227)
at com.opensymphony.oscache.base.Cache.getFromCache(Cache.java:180)
at com.claritycontrol.ars.CacheTestCase.testCacheSerialization(CacheTestCase.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: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 junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
Best regards from snowy Black Forest, Germany,
Mattin
|
|
Description
|
In the deserialization of AbstractConcurrentReadCache the "table" variable seems to remain null (although the code looks fine at first glance in readObject()).
(This problem seems to exist already in Version 1.7.5, where I also received a NPex after deserialization.)
Reproduceability with the following simple JUnit test
/**
* tests the serialization and deserialization of OSCache
*
* @throws IOException if test fails
* @throws ClassNotFoundException if test fails
*/
public void testCacheSerialization()
throws IOException, ClassNotFoundException, NeedsRefreshException
{
final Cache written = new Cache(true, false);
written.putInCache("key", "before");
assertEquals("failed to put in cache before serialization", "before", written.getFromCache("key"));
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(written);
final byte[] serialized = baos.toByteArray();
baos.close();
final ByteArrayInputStream bais = new ByteArrayInputStream(serialized);
final ObjectInputStream ois = new ObjectInputStream(bais);
final Cache read = (Cache) ois.readObject();
ois.close();
read.getFromCache("key");
}
...
causes
...
java.lang.NullPointerException
at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.get(AbstractConcurrentReadCache.java:686)
at com.opensymphony.oscache.base.Cache.getCacheEntry(Cache.java:594)
at com.opensymphony.oscache.base.Cache.getFromCache(Cache.java:227)
at com.opensymphony.oscache.base.Cache.getFromCache(Cache.java:180)
at com.claritycontrol.ars.CacheTestCase.testCacheSerialization(CacheTestCase.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: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 junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
Best regards from snowy Black Forest, Germany,
Mattin
|
Show » |
|