Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-505

NPE in the OWL class

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: Jena 2.10.1
    • Fix Version/s: Jena 2.11.0
    • Component/s: Jena
    • Labels:
      None

      Description

      The error happens when you try to load a file using the file manager in Jena 2.10.1, for example

      model = FileManager.get().loadModel("http://example.org","http://example.org","RDF/XML");
      

      The reason is incorrect initialization of variables in the OWL class. In the following code:

          public class OWL {
              private static Model m_model = ModelFactory.createDefaultModel();
              
              public static final String NS = "http://www.w3.org/2002/07/owl#";
              
              public static String getURI() {return NS;}
          
          ...    
              public static final Property sameAs = m_model.createProperty( "http://www.w3.org/2002/07/owl#sameAs" );
          ...
      

      a call to OWL.sameAs will result in a NPE because m_model is null. I guess that if you start with OWL.getURI(), then m_model will be evaluated first and there will be no error, which is why this never occurred before.

      I think that a solution would be to make m_model final as well.

        Attachments

        1. jena-505.zip
          8 kB
          Piotr Hołubowicz

          Activity

            People

            • Assignee:
              andy Andy Seaborne
              Reporter:
              piotrekhol Piotr Hołubowicz

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment