Issue Details (XML | Word | Printable)

Key: NUCCORE-1244
Type: Bug Bug
Status: Open Open
Priority: Testcase Required Testcase Required
Assignee: Unassigned
Reporter: Alexey Akhunov
Votes: 0
Watchers: 2
Operations

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

ClassUtils sometimes confuses org.datanucleus.store.types.simple.HashSet and org.datanucleus.store.types.simple.Date

Created: 13/Aug/14 01:58 PM   Updated: 13/Aug/14 02:27 PM
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: org.datanucleus.store.types.simple.HashSet cannot be cast to java.util.Date
        at OUR_ENHANCED_CLASS.jdoReplaceField(Node.java)
        at org.datanucleus.state.JDOStateManager.replaceField(JDOStateManager.java:2206)
        at org.datanucleus.state.JDOStateManager.replaceField(JDOStateManager.java:3360)
        at org.datanucleus.state.JDOStateManager.replaceField(JDOStateManager.java:3263)
        at org.datanucleus.store.types.SCOUtils.createSCOWrapper(SCOUtils.java:244)
        at org.datanucleus.store.types.SCOUtils.newSCOInstance(SCOUtils.java:142)
        at org.datanucleus.state.JDOStateManager.wrapSCOField(JDOStateManager.java:3627)
        at org.datanucleus.store.hbase.fieldmanager.FetchFieldManager.fetchObjectField(FetchFieldManager.java:431)
        at org.datanucleus.state.JDOStateManager.replacingObjectField(JDOStateManager.java:2172)
        at OUR_ENHANCED_CLASS.jdoReplaceField(Node.java)
        at OUR_ENHANCED_CLASS.jdoReplaceFields(Node.java)
        at org.datanucleus.state.JDOStateManager.replaceFields(JDOStateManager.java:3418)
        at org.datanucleus.state.JDOStateManager.replaceFields(JDOStateManager.java:3445)
        at org.datanucleus.store.hbase.HBasePersistenceHandler.fetchObject(HBasePersistenceHandler.java:748)
        at org.datanucleus.state.AbstractStateManager.loadFieldsFromDatastore(AbstractStateManager.java:1122)
        at org.datanucleus.state.JDOStateManager.validate(JDOStateManager.java:4743)
        at org.datanucleus.ExecutionContextImpl.findObject(ExecutionContextImpl.java:3700)
        at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1724)
        at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1763)
}}}

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 org.datanucleus.store.types.simple.HashSet and org.datanucleus.store.types.simple.Date 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 (org.datanucleus.store.types.simple.HashSet.hashCode() == org.datanucleus.store.types.simple.Date.hashCode()


Andy Jefferson made changes - 13/Aug/14 02:27 PM
Field Original Value New Value
Priority Major [ 3 ] No Testcase [ 6 ]