Github user ottobackwards commented on the issue:

    https://github.com/apache/commons-lang/pull/311
  
    the static factory, is pretty straight forward.
    The try with resources, less so.  What ends up happening is you cannot stop 
the watch before visiting the nodes.
    
    For example, this is what you want to do if you are going to time, but 
visit later:
    
    ```java
     @Test
        public void testTryWithResources() {
            final StopWatch stopWatch = new StopWatch();
            
            try(StackWatch<String,String> watch = new 
StackWatch<>("testStackWatch")) {
                watch.start();
                stopWatch.start();
                stopWatch.stop();
            }
            watch.visit(new StackWatch.TimingVisitor<String,String>() {
                @Override
                public void visitTiming(int level, List<String> path, 
StackWatch.Timing<String,String> node) {
                    assertTrue(node.getStopWatch().getNanoTime() > 
stopWatch.getNanoTime());
                }
            });
        }
    ```
    
    but it won't work/compile with try with resources
    



---

Reply via email to