Uploaded image for project: 'Marmotta (Retired)'
  1. Marmotta (Retired)
  2. MARMOTTA-393

ClassCastException when loading Literal thats stored as a URI

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1-incubating
    • 3.2.0, 3.3.0
    • KiWi Triple Store
    • None

    Description

      When loading a literal value that already exists as a URI the KiWiConnection.loadLiteral throws an ClassCastException as the returned node is a URI.

      Caused by: java.lang.ClassCastException: org.apache.marmotta.kiwi.model.rdf.KiWiUriResource cannot be cast to org.apache.marmotta.kiwi.model.rdf.KiWiLiteral
      	at org.apache.marmotta.kiwi.persistence.KiWiConnection.loadLiteral(KiWiConnection.java:627)
      	at org.apache.marmotta.kiwi.sail.KiWiValueFactory.createLiteral(KiWiValueFactory.java:435)
      	at org.apache.marmotta.kiwi.sail.KiWiValueFactory.createLiteral(KiWiValueFactory.java:350)
      	at org.openrdf.rio.helpers.RDFParserHelper.createLiteral(RDFParserHelper.java:250)
      

      Perhaps KiWiConnection.loadLiteral(String value, String lang, KiWiUriResource ltype) could validate the type and return null e.g.

      From this:

      return (KiWiLiteral)constructNodeFromDatabase(result);
      

      To this:

      KiWiNode node = constructNodeFromDatabase(result);
      KiWiNode kiWiNode = constructNodeFromDatabase(result);
      if(kiWiNode.isLiteral()) {
          return (KiWiLiteral)kiWiNode;
      } else {
          return null;
      }
      

      Attachments

        Activity

          People

            wastl Sebastian Schaffert
            alm Alan
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: