Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 335654

Summary: NPE, NullPointerException in DirectCollectionChangeRecord.addAdditionChange
Product: z_Archived Reporter: Richard Feezel <rfeezel>
Component: EclipselinkAssignee: Tom Ware <tom.ware>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P2 CC: eclipselink.orm-inbox, gerardg, peter.krogh, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Java Logging Log file of all activity up the NPE event.
none
MySql log file showing all activity up the NPE event. none

Description Richard Feezel CLA 2011-01-28 02:04:52 EST
Build Identifier: 2.3.0-SNAPSHOT   20110126-22

java.lang.NullPointerException
	at org.eclipse.persistence.internal.sessions.DirectCollectionChangeRecord.addAdditionChange(DirectCollectionChangeRecord.java:120)
	at org.eclipse.persistence.internal.sessions.DirectCollectionChangeRecord.mergeRecord(DirectCollectionChangeRecord.java:318)
	at org.eclipse.persistence.internal.sessions.ObjectChangeSet.mergeObjectChanges(ObjectChangeSet.java:679)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet.mergeObjectChanges(UnitOfWorkChangeSet.java:480)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet.mergeUnitOfWorkChangeSet(UnitOfWorkChangeSet.java:497)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:446)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:743)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.performPreQueryFlush(EJBQueryImpl.java:1267)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:431)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:739)

A complete FINEST level log is available.

A corresponding MySql log file is also available.

Reproducible: Always

Steps to Reproduce:
1.Run my database initialization application which writes MANY objects in one large transaction.
Comment 1 Richard Feezel CLA 2011-01-28 02:07:44 EST
Created attachment 187805 [details]
Java Logging Log file of all activity up the NPE event.
Comment 2 Richard Feezel CLA 2011-01-28 02:12:01 EST
Created attachment 187806 [details]
MySql log file showing all activity up the NPE event.
Comment 3 Richard Feezel CLA 2011-01-28 02:15:04 EST
The same error was occurring with version 2.1.2 so I switched to 2.3.0-SNAPSHOT and the problem still occurs.
Comment 4 Tom Ware CLA 2011-01-28 08:27:47 EST
Can you provide any information about what you are doing when this occurs.  

("1.Run my database initialization application which writes MANY objects in one
large transaction." doesn't really help us unless we have the application)

What objects are involved, how are them mapped?  What does the code that triggers this look like?
Comment 5 Richard Feezel CLA 2011-01-28 10:29:04 EST
I did some further debugging this morning, after making the eclipselink source available to Eclipse and found that a null was being added to the commitAddMap somewhere.  Setting breakpoint on all the calls to "put()" and testing to see if the value supplied was NULL I found problem at line 316.

Looking at this code at lines 314-316:
if (!((DirectCollectionChangeRecord)mergeFromRecord).getCommitAddMap().containsKey(added)){
  // we have not recorded a change of this type in this class before so  add it
  this.getCommitAddMap().put(added, ((DirectCollectionChangeRecord)mergeFromRecord).getCommitAddMap().get(added));

it appears that, if the "IF" is TRUE, this will always add a NULL to the commitAddMap for the "added" object.
Comment 6 Tom Ware CLA 2011-02-03 10:40:14 EST
Please provide some instructions about what you are doing so we can recreate the problem.
Comment 7 Tom Ware CLA 2011-02-09 11:12:10 EST
BTW: I agree that the code you have posted on lines 314-316 has an issue - I am asking for any recreation steps you can provide to facilitate writing a test case that reflects your problem so we can guarantee we fix the issue you are seeing when we address this issue.
Comment 8 Tom Ware CLA 2011-02-09 11:15:57 EST
BTW: does setting the persistence unit property eclipselink.weaving.changetracking to false help?
Comment 9 Tom Ware CLA 2011-02-10 09:14:43 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 10 Richard Feezel CLA 2011-02-10 09:45:52 EST
(In reply to comment #8)
> BTW: does setting the persistence unit property
> eclipselink.weaving.changetracking to false help?

It did not appear to make any difference.
Comment 11 Tom Ware CLA 2011-02-10 16:33:53 EST
  The commitAddMap is used to track duplicate entries in a DirectCollection (ElementCollection containing simple types in JPA).  This method is called during a merge, so I am wondering if your problem occurs in some usecase where you merge an object containing duplicates in a DirectCollectionMapping.  If you are looking for database problems it might be a good idea to focus on that kind of issue. 


  My initial look tells me that removing the if statement from the loop is probably not the correct solution.  More likely, the solution is to fix the condition on the if-statement.  It may be as simple as removing the "!", but we would have to recreate the problem and have a look at the results to know for sure.
Comment 12 Peter Krogh CLA 2011-06-20 14:01:34 EDT
moving bug to 3.1
Comment 13 Tom Ware CLA 2011-08-10 15:43:07 EDT
I currently cannot recreate this problem.  Please provide details of what you are doing when you see this issue.  Without more detail, I will have to close this issue due to the fact that I cannot recreate it.
Comment 14 Tom Ware CLA 2011-08-11 09:06:33 EDT
'Any change you are using the same EntityManager in mulple threads?  That could cause this problem and is not supported by JPA.
Comment 15 Tom Ware CLA 2011-08-22 10:27:30 EDT
Closing as INVALID because I cannot recreate.  Please reopen if you can provide a way to recreate the problem.
Comment 16 Eclipse Webmaster CLA 2022-06-09 10:07:33 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink