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

Bug 328627

Summary: JAXB Externalized Metadata: potential null pointer in finalize properties method in annotations processor
Product: z_Archived Reporter: David McCann <david.mccann>
Component: EclipselinkAssignee: David McCann <david.mccann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 317962    
Attachments:
Description Flags
Proposed fix none

Description David McCann CLA 2010-10-25 12:01:31 EDT
When validating xml-join-nodes in the finalizeProperties method we first try to match the referenced-xml-path of the xml-join-node to an xml-id on the target class; if there's no match we try xml-key properties.  The following code causes a null pointer exception if there are no xml-key properties:

    for (Property xmlkeyProperty : targetInfo.getXmlKeyProperties()) {

Here is the exception:

----------------------------------------------------------
Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.finalizeProperties(AnnotationsProcessor.java:713)
	at org.eclipse.persistence.jaxb.compiler.XMLProcessor.processXML(XMLProcessor.java:339)
	at org.eclipse.persistence.jaxb.compiler.Generator.<init>(Generator.java:145)
	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:244)
	... 23 more
-----------------------------------------------------------

We need to check for non-null xmlKeyProperties on the target property before doing the for loop.
Comment 1 David McCann CLA 2010-10-25 12:41:56 EDT
Created attachment 181660 [details]
Proposed fix
Comment 2 David McCann CLA 2010-10-25 13:10:59 EDT
Reviewed by:  rick.barkhouse@oracle.com
Tests:  all unit tests pass as expected

revision: 8406
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:05:29 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink