Uploaded image for project: 'Byteman'
  1. Byteman
  2. BYTEMAN-432

Improve error reporting on rule execution

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 4.0.21
    • None

      I run into this problem often: I code up a rule for Byteman to apply within a JUnit test using BMUnit and @BMRule, I run the test, and when I look at the test case output, I don't see any output from Byteman: neither the results I was expecting, nor any error messages letting me know what has gone wrong. I find that subtle errors in rules can cause a change from expected output to no output whatsoever. 

      Here is a case in point (this code is from wildfly-http-client v 2.0.2.Final)

      This rule text:

      RULE Check agreed protocol version
      CLASS org.wildfly.httpclient.common.EENamespaceInteroperability$HttpConnectionPool$ClientConnectionHolder$EEInteroperableClientExchange
      METHOD setResponseListener
      AT LINE 225
      IF TRUE
      DO traceln("line 255 was called")
      ENDRULE

      leads to this output:

      14:47:46,190 DEBUG [org.wildfly.httpclient.common] (main) *** Sending request: request = ClientRequest{path='/wildfly-services/common/v1/affinity', method=GET, protocol=HTTP/1.1}
      Installed rule using default helper : Check agreed protocol version
      line 255 was called
      14:47:46,243 DEBUG [io.undertow.client.http.HttpClientExchange] (XNIO-1 I/O-1) request terminated for request to /127.0.0.1:8080 /wildfly-services/common/v1/affinity

      and this rule text: 

      RULE Check agreed protocol version
      CLASS org.wildfly.httpclient.common.EENamespaceInteroperability$HttpConnectionPool$ClientConnectionHolder$EEInteroperableClientExchange
      METHOD setResponseListener
      AT LINE 225
      IF TRUE
      DO traceln("value of protocol version = " + $protocolVersion)
      ENDRULE

      leads to this output:

      14:50:50,925 DEBUG [org.wildfly.httpclient.common] (main) *** Sending request: request = ClientRequest{path='/wildfly-services/common/v1/affinity', method=GET, protocol=HTTP/1.1}
      // missing output
      14:50:50,981 DEBUG [io.undertow.client.http.HttpClientExchange] (XNIO-1 I/O-1) request terminated for request to /127.0.0.1:8080 /wildfly-services/common/v1/affinity

      In other words, the targetClass, targetMethod, entry point and condition are the same in both rules, but slightly different action causes all rule-related output that appears in the first rule execution to disappear in the second. This makes finding out what has gone wrong with the rule execution really difficult and time consuming. The private volatile int variable protocolVersion is in scope at line 255.
       
      What can go wrong with a rule? The rule event specification (targetClass, targetMethod, entry point) may not be found in the set of classes loaded; there could be a configuration option to flag rules which never have their rule event specification matched. Or if the rule event specifcation is found, it may not be possible to evaluate the condition and or action expression at that event specification instance. These instances could also be flagged with a reason why they could not be evaluated. Having error messages like these printed to the output that Byteman generates would help in narrowing down what has gone wrong with a rule executuion and reduce the time spent trying to otherwise figure it out
        

            rhn-engineering-adinn Andrew Dinn
            rachmato@redhat.com Richard Achmatowicz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: