You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Rob Vesse <rv...@dotnetrdf.org> on 2014/07/23 16:21:11 UTC
Re: svn commit: r1612831 -
/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
s/Manged/Mangled
Rob
On 23/07/2014 14:30, "andy@apache.org" <an...@apache.org> wrote:
>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/DatasetPrefixe
>sTDB.java
>
>Modified:
>jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixe
>sTDB.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&v
>iew=diff
>==========================================================================
>====
>---
>jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixe
>sTDB.java (original)
>+++
>jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixe
>sTDB.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 ;
>
>