Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-260

Calling SchemaType.isSkippedAnonymousType() can throw a NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Version 2.1
    • Version 2.4.1
    • XmlObject
    • None
    • Java 1.5, Windows XP

    Description

      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; }

      Attachments

        Activity

          People

            wypoon Wing Yew Poon
            movint Luke Peters
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: