You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by rm...@apache.org on 2014/03/22 16:23:41 UTC

svn commit: r1580225 - /incubator/sirona/trunk/agent/javaagent/src/main/java/org/apache/sirona/javaagent/SironaTransformer.java

Author: rmannibucau
Date: Sat Mar 22 15:23:40 2014
New Revision: 1580225

URL: http://svn.apache.org/r1580225
Log:
debug only nstrumented classes + syst prop to activate debugging without using javaagent param

Modified:
    incubator/sirona/trunk/agent/javaagent/src/main/java/org/apache/sirona/javaagent/SironaTransformer.java

Modified: incubator/sirona/trunk/agent/javaagent/src/main/java/org/apache/sirona/javaagent/SironaTransformer.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/javaagent/src/main/java/org/apache/sirona/javaagent/SironaTransformer.java?rev=1580225&r1=1580224&r2=1580225&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/javaagent/src/main/java/org/apache/sirona/javaagent/SironaTransformer.java (original)
+++ incubator/sirona/trunk/agent/javaagent/src/main/java/org/apache/sirona/javaagent/SironaTransformer.java Sat Mar 22 15:23:40 2014
@@ -32,7 +32,7 @@ public class SironaTransformer implement
     private final boolean debug;
 
     public SironaTransformer(final boolean debug) {
-        this.debug = debug;
+        this.debug = debug || Boolean.getBoolean("sirona.javaagent.debug");
     }
 
     @Override
@@ -51,22 +51,21 @@ public class SironaTransformer implement
             final SironaClassVisitor advisor = new SironaClassVisitor(writer, className);
             reader.accept(advisor, ClassReader.SKIP_FRAMES);
 
-            final byte[] bytes = writer.toByteArray();
-            if (debug) {
-                final File dump = new File(System.getProperty("java.io.tmpdir"), "sirona-dump/" + className + ".class");
-                dump.getParentFile().mkdirs();
-                FileOutputStream w = null;
-                try {
-                    w = new FileOutputStream(dump);
-                    w.write(bytes);
-                } finally {
-                    if (w != null) {
-                        w.close();
+            if (advisor.wasAdviced()) {
+                final byte[] bytes = writer.toByteArray();
+                if (debug) {
+                    final File dump = new File(System.getProperty("java.io.tmpdir"), "sirona-dump/" + className + ".class");
+                    dump.getParentFile().mkdirs();
+                    FileOutputStream w = null;
+                    try {
+                        w = new FileOutputStream(dump);
+                        w.write(bytes);
+                    } finally {
+                        if (w != null) {
+                            w.close();
+                        }
                     }
                 }
-            }
-
-            if (advisor.wasAdviced()) {
                 return bytes;
             }
             return classfileBuffer;