[ 
https://issues.apache.org/jira/browse/JENA-1857?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17056106#comment-17056106
 ] 

Andy Seaborne commented on JENA-1857:
-------------------------------------

The information is there and works inside transactions, sometimes outside.

In {{QuadTableForm}}, on the fast path for listGraphNodes, {{local().get()}} is 
null outside a transaction.

 {{Txn.executeRead(dsg, ()->{});}} after {{dsg.add(q)}} works.  

But a W transaction does not.
{code:java}
  dsg.add(q);
  Txn.executeWrite(dsg, ()->{});
  System.out.println(dsg.size());
{code}

A fix might be:
{code:java}
                @Override
                public Stream<Node> listGraphNodes() {
                    FourTupleMap x = local().get();
                    if ( x == null )
                        x = master().get();
                    return x.entryStream().map(Entry::getKey);
                }
{code}
but it touches two volatiles/AtomicReferences. I _think_ if it is local() then 
master() it is thread safe transactionally. If non-transactional access is 
going on, "doesn't crash" is all we can guarantee and IIUC {{master().get()}} 
is never null.

> DatasetGraphInMemory.listGraphNodes causes exception outside a transaction
> --------------------------------------------------------------------------
>
>                 Key: JENA-1857
>                 URL: https://issues.apache.org/jira/browse/JENA-1857
>             Project: Apache Jena
>          Issue Type: Task
>          Components: TIM
>    Affects Versions: Jena 3.14.0
>            Reporter: Andy Seaborne
>            Priority: Major
>
> Test case: 
> {code:java}
>     public static void main(String ... a) {
>         DatasetGraph dsg = DatasetGraphFactory.createTxnMem();
>         Quad q = SSE.parseQuad("(:g :s :p :o)");
>         dsg.add(q);
>         try {
>             System.out.println(dsg.size());
>         } catch (Exception ex) {
>             ex.printStackTrace();
>         }
>     }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to