eclipse-ee4j / eclipse-ee4j/jaxb-ri

NPE from marshalling an IDREF that point to a missing ID attribute value

Open
#1,007 4 comments 0 reactions 1 assignee Claimed by @glassfishrobot View on GitHub
Component: runtime Priority: Minor Type: Bug
Dominant language
Java
Stars
222
Forks
131
Avg merge
2d 17h
Merged PRs (30d)
9

Description

NPE is thrown prematurely in case of an id attribute being null instead of a more appropriate validation event (Object "..." is found in an IDREF property but this object doesnt have an ID.). In order to fix this see AttributeProperty.serializeAttributes method that deals with the null correctly.

It seems that other people have had to deal this problem before ([http://stackoverflow.com/questions/10705532/in-jaxb-marshalling-how-to-identify-which-child-element-caused-jaxb-marshallin](http://stackoverflow.com/questions/10705532/in-jaxb-marshalling-how-to-identify-which-child-element-caused-jaxb-marshallin)). I guess that pinpointing of the cause can be quite problematic with the current behavior.

* * StackTrace * *
AttributeProperty.getIdValue(BeanT) line: 128
ClassBeanInfoImpl.getId(BeanT, XMLSerializer) line: 322
TransducedAccessor$IDREFTransducedAccessorImpl.print(BeanT) line: 290
TransducedAccessor$IDREFTransducedAccessorImpl(DefaultTransducedAccessor).writeLeafElement(XMLSerializer, Name, T, String) line: 69
SingleElementLeafProperty.serializeBody(BeanT, XMLSerializer, Object) line: 130
ClassBeanInfoImpl.serializeBody(BeanT, XMLSerializer) line: 361
XMLSerializer.childAsXsiType(Object, String, JaxBeanInfo, boolean) line: 696

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.