Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328627 - JAXB Externalized Metadata: potential null pointer in finalize properties method in annotations processor
Summary: JAXB Externalized Metadata: potential null pointer in finalize properties met...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: David McCann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 317962
  Show dependency tree
 
Reported: 2010-10-25 12:01 EDT by David McCann CLA
Modified: 2022-06-09 10:05 EDT (History)
0 users

See Also:


Attachments
Proposed fix (1.29 KB, patch)
2010-10-25 12:41 EDT, David McCann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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