DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
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 ( ==

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 04/Nov/14 08:36 AM
Can't see this with current code (v4.x)