srdc/gitb

messagingContext is null in the second transaction when the 2 transactions have the same handler

Closed this issue · 1 comments

I'm writing a test case where I have 2 transactions based on the same handler SOAPMessaging.

<btxn from="DocumentSource" to="DocumentRepository" txnId="t2" handler="SoapMessaging"/>
        <receive id="soap_output1" desc="Provide and Register Set-b (one Document)" from="DocumentSource" to="DocumentRepository" txnId="t2">
            <config name="soap.version">1.2</config>
        </receive>
        <send id="soap_input1" desc="Send response" from="DocumentRepository" to="DocumentSource" txnId="t2">
            <input name="soap_message" source="$DocRepo_Template" />
            <config name="soap.version">1.2</config>
        </send>
        <etxn txnId="t2"/> 

        <btxn from="DocumentSource" to="DocumentRepository" txnId="t1" handler="SoapMessaging"/>
        <receive id="soap_output2" desc="Provide and Register Set-b (Two Documents)" from="DocumentSource" to="DocumentRepository" txnId="t1" >
            <config name="soap.version">1.2</config>
        </receive>
        <send id="soap_input2" desc="Send response" from="DocumentRepository" to="DocumentSource" txnId="t1">
            <input name="soap_message" source="$DocRepo_Template" />
            <config name="soap.version">1.2</config>
        </send>
        <etxn txnId="t1"/>

The first transaction executes without problem. However when the second transaction starts, the messagingContext is null and I got a NPE, so the second transaction fails.

7:29:05.950 [test-engine-as-akka.actor.default-dispatcher-4] DEBUG c.g.m.l.AbstractTransactionReceiver - Closing socket: Socket[addr=/127.0.0.1,port=56378,localport=8081]
17:29:05.950 [test-engine-as-blocking-processor-dispatcher-16] DEBUG com.gitb.engine.TestbedService - updateStatus ( 2d4f8b24-079a-474f-875d-a02a791a25e4 , 2 , COMPLETED , com.gitb.tr.TAR@17a378fd ) 
17:29:05.950 [TCPListenerThread:8081] DEBUG c.g.m.s.tcp.TCPMessagingServerWorker - Closing server created on: ServerSocket[addr=0.0.0.0/0.0.0.0,localport=8081]
17:29:05.958 [test-engine-as-akka.actor.default-dispatcher-3] ERROR c.g.e.a.p.AbstractTestStepActor - akka://test-engine-as/user/session/2d4f8b24-079a-474f-875d-a02a791a25e4/tc-p/seq-p-9nVK7/begin-txn-p-YFyeL caught an exception
java.lang.NullPointerException: null
    at com.gitb.engine.actors.processors.BeginTransactionStepProcessorActor.start(BeginTransactionStepProcessorActor.java:31) ~[gitb-engine-1.0-SNAPSHOT.jar:na]
    at com.gitb.engine.actors.processors.AbstractTestStepActor.onReceive(AbstractTestStepActor.java:126) ~[gitb-engine-1.0-SNAPSHOT.jar:na]
    at akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(UntypedActor.scala:167) [akka-actor_2.11-2.3.9.jar:na]
    at akka.actor.Actor$class.aroundReceive(Actor.scala:465) [akka-actor_2.11-2.3.9.jar:na]
    at akka.actor.UntypedActor.aroundReceive(UntypedActor.scala:97) [akka-actor_2.11-2.3.9.jar:na]
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) [akka-actor_2.11-2.3.9.jar:na]
    at akka.actor.ActorCell.invoke(ActorCell.scala:487) [akka-actor_2.11-2.3.9.jar:na]
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:254) [akka-actor_2.11-2.3.9.jar:na]
    at akka.dispatch.Mailbox.run(Mailbox.scala:221) [akka-actor_2.11-2.3.9.jar:na]
    at akka.dispatch.Mailbox.exec(Mailbox.scala:231) [akka-actor_2.11-2.3.9.jar:na]
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.11.5.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.11.5.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.11.5.jar:na]
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.11.5.jar:na]
17:29:05.962 [test-engine-as-akka.actor.default-dispatcher-3] ERROR c.g.e.a.p.AbstractTestStepActor - An error status received in []

This was working with the previous release of GITB (rev 2 in the SVN repository).

I guess that having two transactions with the same handler in the same test case does not work as the messagingContext gets cleaned after the first transaction ends. Is there a workaround? I tried to wrap the test steps in the same transaction but the second receive fails.

I need to have a look at this. I will get back to you as soon as I have a fix.