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

stephen mallette commented on TINKERPOP-1505:
---------------------------------------------

[~pluradj] This looks like it would be a breaking change (tests will fail in 
the suite) to current functionality in that each thread is current getting its 
own listener. If we switch to the code you suggest then that goes away. I would 
admit that the Gremlin Server situation isn't so good though. It might be that 
the solution is to make transaction listener assignments something that happens 
per thread in the thread pool but that's not so easy to implement. Or we commit 
to changing the implementation to not be bound per thread as part of 3.3.x 
where we can take a breaking change. I haven't thought through all the 
implications of changing that though. wdyt?

> Transaction Status listener list gets overwritten
> -------------------------------------------------
>
>                 Key: TINKERPOP-1505
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1505
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: process
>    Affects Versions: 3.1.4, 3.2.2
>            Reporter: Jason Plurad
>
> Transaction status listener is not called when using Gremlin Server
> * Caused by the transaction listener list initialization in 
> [AbstractThreadLocalTransaction|https://github.com/apache/tinkerpop/blob/3.1.4/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractThreadLocalTransaction.java#L54-L59].
>         
>   * There are 2 different threads in action during the Gremlin Server 
> initialization.
>     # The Groovy startup script evaluation which adds the listener
>     # The server itself handles the transaction commit or rollback. Both 
> threads end up calling on the {{ThreadLocal initialValue()}} which returns 
> {{new ArrayList()}} and effectively wipes out the listener.
>     * Fix is to initialize the list once.
> {noformat}
>     protected final ThreadLocal<List<Consumer<Transaction.Status>>> 
> transactionListeners = new ThreadLocal<List<Consumer<Transaction.Status>>>() {
>         private List<Consumer<Transaction.Status>> list = new ArrayList<>();
>         @Override
>         protected List<Consumer<Transaction.Status>> initialValue() {
>             return list;
>         }
>     };
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to