Issue Details (XML | Word | Printable)

Key: NUCCORE-1244
Type: Bug Bug
Status: Closed Closed
Resolution: Cannot Reproduce
Priority: Testcase Required Testcase Required
Assignee: Unassigned
Reporter: Alexey Akhunov
Votes: 0
Watchers: 2

If you were logged in you would be able to see more operations.
DataNucleus Core

ClassUtils sometimes confuses and

Created: 13/Aug/14 01:58 PM   Updated: 04/Nov/14 09:01 AM   Resolved: 04/Nov/14 08:36 AM
Component/s: Persistence
Affects Version/s: 3.2.15
Fix Version/s: None

Environment: Red Hat 6, JDK 1.17.0_11

Datastore: HBase
Severity: Production

 Description  « Hide
Occasionally (happens in our production environment about twice a month) we get a ClassCastException from jdoReplaceFields in an enhanced object:

java.lang.ClassCastException: cannot be cast to java.util.Date
        at OUR_ENHANCED_CLASS.jdoReplaceField(
        at org.datanucleus.state.JDOStateManager.replaceField(
        at org.datanucleus.state.JDOStateManager.replaceField(
        at org.datanucleus.state.JDOStateManager.replaceField(
        at org.datanucleus.state.JDOStateManager.wrapSCOField(
        at org.datanucleus.state.JDOStateManager.replacingObjectField(
        at OUR_ENHANCED_CLASS.jdoReplaceField(
        at OUR_ENHANCED_CLASS.jdoReplaceFields(
        at org.datanucleus.state.JDOStateManager.replaceFields(
        at org.datanucleus.state.JDOStateManager.replaceFields(
        at org.datanucleus.state.AbstractStateManager.loadFieldsFromDatastore(
        at org.datanucleus.state.JDOStateManager.validate(
        at org.datanucleus.ExecutionContextImpl.findObject(
        at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(
        at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(

the problem is sticky and can only be solved by a restart.
Investigation showed that the problem arises because ClassUtil.newInstance() method assumes that hashCode() will always return distinct values for different objects. In our case, sometimes and classes have hashCode() returning the same number, in which case one is created instead of another, producing the stack trace above.

Unfortunately, I cannot provide test cases, since it is only reproducible when JVM is in particular state ( ==

Andy Jefferson made changes - 13/Aug/14 02:27 PM
Field Original Value New Value
Priority Major [ 3 ] No Testcase [ 6 ]
Andy Jefferson added a comment - 04/Nov/14 08:36 AM
Can't see this with current code (v4.x)

Andy Jefferson made changes - 04/Nov/14 08:36 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Cannot Reproduce [ 5 ]
Andy Jefferson made changes - 04/Nov/14 09:01 AM
Status Resolved [ 5 ] Closed [ 6 ]