Issue Details (XML | Word | Printable)

Key: XMLBEANS-260
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Wing Yew Poon
Reporter: Luke Peters
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XMLBeans

Calling SchemaType.isSkippedAnonymousType() can throw a NPE

Created: 29/Mar/06 11:41 PM   Updated: Friday 01:19 AM
Return to search
Component/s: XmlObject
Affects Version/s: Version 2.1
Fix Version/s: Version 2.4.1

Time Tracking:
Not Specified

Environment: Java 1.5, Windows XP

Resolution Date: 20/Nov/09 01:19 AM


 Description  « Hide
If isSkippedAnonymousType() is called on a SchemaType instance that does not have _outerSchemaTypeRef set, then a NPE will be thrown. Example:

  MyXmlBean myBean = MyXmlBean.Factory.newInstance();
  boolean isSkipped = myBean.schemaType().isSkippedAnonymousType(); <- throws a NPE

It seems that it should return false in this instance, rather than throw an exception. All this needs to fix is to add a null check. I'm not sure which versions exactly are effected, but it is an issue in 2.1.

Current code:

    public boolean isSkippedAnonymousType()
        { return _outerSchemaTypeRef.get().getBaseType() == this ||
                _outerSchemaTypeRef.get().getContentBasedOnType() == this; }

Potential fix:

    public boolean isSkippedAnonymousType()
        { return _outerSchemaTypeRef == null ? false : _outerSchemaTypeRef.get().getBaseType() == this ||
                _outerSchemaTypeRef.get().getContentBasedOnType() == this; }

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #882294 Thu Nov 19 20:55:44 UTC 2009 wypoon Fix for XMLBEANS-260. Add a test for verification.
Files Changed
ADD /xmlbeans/trunk/test/src/misc/detailed/JiraRegression251_300Test.java
MODIFY /xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java