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

Add around (try-finally) with DO action on enter and DO action on finally

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Won't Do
    • Minor
    • None
    • None
    • Trigger Injection
    • None
    • High
    • Undefined

    Description

      It would be very helpfull to inject an action in the entry point of a method, then another in the exit of the method, and share binding variables between both action

      Here is 2 typical usages:

      1/  compute endTime-startTime, and add logs or increments timing statistics
       

      // DO ENTER code {{
      long startTime = System.currentTimeMillis();
      // }}
      try {
         .... the instrumented method
      } finally {
         // DO EXIT code {{
         long elapsedMillis = System.currentTimeMillis() - startTime;
         log.info("executed method, took " + elapsedMillis + " ms");
         // }}
      }
      

      2/ push then pop values in a ThreadLocal object

      // DO ENTER code {{
      ThreadLocal someThreadLocal = ...
      Object prevValue = someThreadLocal.get();
      someThreadLocal.set(somePushedValue);
      // }}
      try {
         .... the instrumented method
      } finally {
         // DO EXIT code {{
         someThreadLocal.set(prevValue );
         // }}
      }
      
      

      In these 2 samples, it is not possible to use 2 different rules with "ENTER" and "EXIT" method, because we have to use a common "BINDING" between 2 blocks of code

      Thank you very much for reading this Feature request, and for your excellent tool

      Attachments

        Activity

          People

            rhn-engineering-adinn Andrew Dinn
            arnaud.nauwynck Arnaud Nauwynck (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: