I have a rule that refers to the local var $connHandlerFuture on its body:
RULE retrieve ConnectionHandlerFactory Future CLASS org.jboss.remoting3.EndpointImpl METHOD doConnect HELPER org.jboss.remoting3.test.racecondition.FutureHelper AT INVOKE org.jboss.remoting3.spi.ConnectionProvider.connect IF TRUE DO debug("retrieving ConnectionHandlerFactory"), trackFuture(org.jboss.remoting3.test.racecondition.FutureHelper.CONNECTION_HANDLER_FACTORY, $connHandlerFuture.getIoFuture()) ENDRULE
This rule is part of CancelOpeningChannelTestCase and, while the rule above works if I run the test isolated, the rule stops from working if I run all tests in a batch, with mvn test.
After some investigation, I realized the failure is related with the previous test in the batch, CloseConnectingEndpointTestCase. Such test contains a rule that is applied to the same EndpointImpl.doConnect method:
RULE doConnect calls resourceUntick CLASS org.jboss.remoting3.EndpointImpl METHOD doConnect AFTER INVOKE org.jboss.remoting3.EndpointImpl.resourceUntick IF TRUE DO debug("ResourceUntick invoked by doConnect... waking closeAction"), signalWake("resourceUntick for connection", true), debug("ResourceUntick waiting for closeAction to complete before proceeding"), # waitFor should expire if connect and closeAction are correctly synchronized, otherwise this test will hang waitFor("connections to Array", 100) ENDRULE
Debugging showed me that, somehow, on the first attempt to transform the bytecodes of EndpointImpl, for CloseConnectingEndpointTestCase, all local variables are accounted for (org.jboss.byteman.agent.adapter.RuleMethodAdapter.visitLocalVariable is invoked during the EndpointImpl bytecode visit process). But, when transformation for the problematic CancelOpeningChannelTestCase begins, no local variable is visited, and that's why my rule is not being applied to EndpointImpl.doConnect.
Could the retransformation process, performed to revert the transformation in the end of CloseConnectingEndpointTestCase execution, be erasing the local var info from the class? This is the impression I get while debugging, that the EndpointImpl.doConnect bytecodes are lacking the local var info when Byteman attempts to transform EndpointImpl for CancelOpeningChannelTestCase.