marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wik...@apache.org
Subject [1/2] marmotta git commit: debugging possible ClassCastException on old kiwi databases
Date Fri, 28 Nov 2014 08:40:15 GMT
Repository: marmotta
Updated Branches:
  refs/heads/develop adea1f5a4 -> eda8f1831


debugging possible ClassCastException on old kiwi databases


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/eda8f183
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/eda8f183
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/eda8f183

Branch: refs/heads/develop
Commit: eda8f18318dd0a7a2cf1978a3b924b2d27afeda4
Parents: a950234
Author: Sergio Fernández <wikier@apache.org>
Authored: Fri Nov 28 09:39:53 2014 +0100
Committer: Sergio Fernández <wikier@apache.org>
Committed: Fri Nov 28 09:40:01 2014 +0100

----------------------------------------------------------------------
 .../commons/sesame/model/LiteralCommons.java    |  5 +---
 .../marmotta/kiwi/model/rdf/KiWiNode.java       |  7 -----
 .../kiwi/persistence/KiWiConnection.java        | 27 +++++++-------------
 3 files changed, 10 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/eda8f183/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/LiteralCommons.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/LiteralCommons.java
b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/LiteralCommons.java
index cfb1637..25e6e3c 100644
--- a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/LiteralCommons.java
+++ b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/LiteralCommons.java
@@ -40,7 +40,6 @@ public class LiteralCommons {
 
     private static final int HASH_BITS=128;
 
-
     private static DatatypeFactory dtf;
     static {
         try {
@@ -50,7 +49,6 @@ public class LiteralCommons {
         }
     }
 
-    
     /**
 	 * Create a cache key for a literal with the given content, locale and type
 	 *
@@ -75,8 +73,6 @@ public class LiteralCommons {
         return createCacheKey(content, language != null ? language.getLanguage() : null,
type);
     }
 
-
-
     /**
      * Create a cache key for the date literal with the given date. Converts the date
      * to a XMLGregorianCalendar with UTC timezone and then calls the method above.
@@ -162,4 +158,5 @@ public class LiteralCommons {
     private LiteralCommons() {
         // static access only
     }
+
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/eda8f183/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiNode.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiNode.java
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiNode.java
index 7e5c448..ae65ea3 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiNode.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiNode.java
@@ -34,9 +34,6 @@ import java.util.Date;
  */
 public abstract class KiWiNode implements Value, Serializable {
 
-    /**
-     *
-     */
     private static final long serialVersionUID = 4652575123005436645L;
 
     /**
@@ -45,13 +42,11 @@ public abstract class KiWiNode implements Value, Serializable {
      */
     private long id = -1L;
 
-
     /**
      * The creation date of the KiWiNode.
      **/
     private Date created;
 
-
     protected KiWiNode() {
         this(new Date());
     }
@@ -60,7 +55,6 @@ public abstract class KiWiNode implements Value, Serializable {
         this.created   = created;
     }
 
-
     /**
      * Return the database ID of this node. Can be used to refer to the node in the context
of one triple store
      * instance, but should not be exposed outside.
@@ -71,7 +65,6 @@ public abstract class KiWiNode implements Value, Serializable {
         return id;
     }
 
-
     /**
      * Update the database id of the node.
      *

http://git-wip-us.apache.org/repos/asf/marmotta/blob/eda8f183/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
index dba0c0e..650892d 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
@@ -79,13 +79,11 @@ public class KiWiConnection implements AutoCloseable {
      */
     private Map<Long,KiWiTriple> tripleCache;
 
-
     /**
      * Cache URI resources by uri
      */
     private Map<String,KiWiUriResource> uriCache;
 
-
     /**
      * Cache BNodes by BNode ID
      */
@@ -96,7 +94,6 @@ public class KiWiConnection implements AutoCloseable {
      */
     private Map<String,KiWiLiteral> literalCache;
 
-
     /**
      * Look up namespaces by URI
      */
@@ -131,7 +128,6 @@ public class KiWiConnection implements AutoCloseable {
     private ReentrantLock uriLock;
     private ReentrantLock bnodeLock;
 
-
     // this set keeps track of all statements that have been deleted in the active transaction
of this connection
     // this is needed to be able to determine if adding the triple again will merely undo
a deletion or is a
     // completely new addition to the triple store
@@ -604,7 +600,6 @@ public class KiWiConnection implements AutoCloseable {
         }
     }
 
-
     /**
      * Load a KiWiAnonResource by anonymous ID. The method will first look in the node cache
for
      * cached nodes. If no cache entry is found, it will run a database query ('load.bnode_by_anonid')
@@ -626,7 +621,6 @@ public class KiWiConnection implements AutoCloseable {
 
         requireJDBCConnection();
 
-
         bnodeLock.lock();
 
         try {
@@ -844,7 +838,7 @@ public class KiWiConnection implements AutoCloseable {
      */
     public KiWiDoubleLiteral loadLiteral(double value) throws SQLException {
         // look in cache
-        KiWiLiteral element = literalCache.get(LiteralCommons.createCacheKey(Double.toString(value),(String)null,Namespaces.NS_XSD
+ "double"));
+        KiWiLiteral element = literalCache.get(LiteralCommons.createCacheKey(Double.toString(value),
(String)null,Namespaces.NS_XSD + "double"));
         if(element != null && element instanceof KiWiDoubleLiteral) {
             return (KiWiDoubleLiteral)element;
         }
@@ -864,17 +858,21 @@ public class KiWiConnection implements AutoCloseable {
             // otherwise prepare a query, depending on the parameters given
             PreparedStatement query = getPreparedStatement("load.literal_by_dv");
             query.setDouble(1, value);
-            query.setLong(2,ltype.getId());
+            query.setLong(2, ltype.getId());
 
             // run the database query and if it yields a result, construct a new node; the
method call will take care of
             // caching the constructed node for future calls
             ResultSet result = query.executeQuery();
+            KiWiNode kiWiNode = null;
             try {
-                if(result.next()) {
-                    return (KiWiDoubleLiteral)constructNodeFromDatabase(result);
+                if (result.next()) {
+                    return (KiWiDoubleLiteral) constructNodeFromDatabase(result);
                 } else {
                     return null;
                 }
+            } catch (RuntimeException e) {
+                log.error("Unable to create KiWiDoubleLiteral for node value '{}' (id={}):
{}", value, kiWiNode.getId(), e.getMessage(), e);
+                throw e;
             } finally {
                 result.close();
             }
@@ -903,7 +901,6 @@ public class KiWiConnection implements AutoCloseable {
             return (KiWiBooleanLiteral)element;
         }
 
-
         requireJDBCConnection();
 
         KiWiUriResource ltype = loadUriResource(Namespaces.NS_XSD + "boolean");
@@ -1177,7 +1174,6 @@ public class KiWiConnection implements AutoCloseable {
         }
     }
 
-
     /**
      * Return the identifier of the triple with the given subject, predicate, object and
context, or null if this
      * triple does not exist. Used for quick existance checks of triples.
@@ -1283,7 +1279,6 @@ public class KiWiConnection implements AutoCloseable {
             }
         });
 
-
     }
 
     /**
@@ -1356,7 +1351,6 @@ public class KiWiConnection implements AutoCloseable {
             }
         });
 
-
     }
 
     /**
@@ -1418,7 +1412,6 @@ public class KiWiConnection implements AutoCloseable {
             }
         });
 
-
     }
 
 
@@ -1443,10 +1436,9 @@ public class KiWiConnection implements AutoCloseable {
         triple.setDeleted(false);
         triple.setDeletedAt(null);
 
-
         synchronized (triple) {
             if(!triple.isDeleted()) {
-                log.warn("attemting to undelete triple that was not deleted: {}",triple);
+                log.warn("attempting to undelete triple that was not deleted: {}",triple);
             }
 
             PreparedStatement undeleteTriple = getPreparedStatement("undelete.triple");
@@ -1460,7 +1452,6 @@ public class KiWiConnection implements AutoCloseable {
 
     }
 
-
     /**
      * List all contexts used in this triple store. See query.contexts .
      * @return


Mime
View raw message