Author: andy
Date: Wed Jul 23 13:30:04 2014
New Revision: 1612831

URL: http://svn.apache.org/r1612831
Log:
Protect against broken prefix table.

Modified:
    
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java

Modified: 
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
URL: 
http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java?rev=1612831&r1=1612830&r2=1612831&view=diff
==============================================================================
--- 
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
 (original)
+++ 
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
 Wed Jul 23 13:30:04 2014
@@ -28,6 +28,7 @@ import java.util.Set ;
 import org.apache.jena.atlas.iterator.Iter ;
 import org.apache.jena.atlas.lib.ColumnMap ;
 import org.apache.jena.atlas.lib.Tuple ;
+import org.apache.jena.atlas.logging.Log ;
 
 import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.graph.NodeFactory ;
@@ -165,15 +166,24 @@ public class DatasetPrefixesTDB implemen
     @Override
     public synchronized Map<String, String> readPrefixMap(String graphName)
     {
+        Map<String, String> map = new HashMap<>() ;
+        // One class of problem from mangled databases
+        // (non-trasnactional, not shutdown cleanly)
+        // ends up with NPE access the node table from
+        // prefix index. As prefixes are "nice extras"
+        
         Node g = NodeFactory.createURI(graphName) ;
         Iterator<Tuple<Node>> iter = nodeTupleTable.find(g, null, null) ;
-        Map<String, String> map = new HashMap<>() ;
         for ( ; iter.hasNext() ; )
         {
-            Tuple<Node> t = iter.next();
-            String prefix = t.get(1).getLiteralLexicalForm() ;
-            String uri = t.get(2).getURI() ;
-            map.put(prefix, uri) ;
+            try {
+                Tuple<Node> t = iter.next();
+                String prefix = t.get(1).getLiteralLexicalForm() ;
+                String uri = t.get(2).getURI() ;
+                map.put(prefix, uri) ;
+            } catch (Exception ex) { 
+                Log.warn(this, "Manged prefix map: graph name="+graphName, ex) 
;
+            }
         }
         Iter.close(iter) ;
         return map ;


Reply via email to