Author: veithen
Date: Sun May 29 14:10:39 2016
New Revision: 1746013

URL: http://svn.apache.org/viewvc?rev=1746013&view=rev
Log:
Merge r1746001 to the 1.7 to unblock SYNAPSE-1027.

Modified:
    axis/axis2/java/core/branches/1_7/   (props changed)
    
axis/axis2/java/core/branches/1_7/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java
    
axis/axis2/java/core/branches/1_7/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LogManager.java

Propchange: axis/axis2/java/core/branches/1_7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun May 29 14:10:39 2016
@@ -1,4 +1,4 @@
 /axis/axis2/java/core/branches/1_6:1295540
 /axis/axis2/java/core/branches/AXIOM-420:1334386-1336397
 
/axis/axis2/java/core/branches/AXIS2-4318:1230452,1295542,1324772,1327468,1329571,1332141,1335355,1335357,1340985
-/axis/axis2/java/core/trunk:1726494,1726509,1726513,1727171,1727174,1727177,1727180,1729891,1730095,1730139,1730180,1730186,1730195,1730197,1730222,1730300,1730308,1730310,1730317,1730322,1730335,1730369,1730427,1730618,1731425,1731441,1731446,1731448,1732354,1733137,1733663,1733713,1733766,1733770,1733773,1733850,1734176,1735331,1735795,1736512,1736543,1737030,1737567,1739001,1739186,1739343,1739346,1739348,1739815,1739826,1740693-1740694,1743824,1745826,1745860,1745869,1745875,1745912,1745924,1745929,1745941
+/axis/axis2/java/core/trunk:1726494,1726509,1726513,1727171,1727174,1727177,1727180,1729891,1730095,1730139,1730180,1730186,1730195,1730197,1730222,1730300,1730308,1730310,1730317,1730322,1730335,1730369,1730427,1730618,1731425,1731441,1731446,1731448,1732354,1733137,1733663,1733713,1733766,1733770,1733773,1733850,1734176,1735331,1735795,1736512,1736543,1737030,1737567,1739001,1739186,1739343,1739346,1739348,1739815,1739826,1740693-1740694,1743824,1745826,1745860,1745869,1745875,1745912,1745924,1745929,1745941,1746001

Modified: 
axis/axis2/java/core/branches/1_7/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_7/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java?rev=1746013&r1=1746012&r2=1746013&view=diff
==============================================================================
--- 
axis/axis2/java/core/branches/1_7/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java
 (original)
+++ 
axis/axis2/java/core/branches/1_7/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java
 Sun May 29 14:10:39 2016
@@ -48,12 +48,16 @@ public class LogAspect {
     public void aroundWriteTo(ProceedingJoinPoint proceedingJoinPoint,
             MessageContext msgContext, OMOutputFormat format, OutputStream 
out, boolean preserve)
             throws Throwable {
-        OutputStream log = LogManager.INSTANCE.createLog("formatter");
-        try {
-            OutputStream tee = new TeeOutputStream(out, log);
-            proceedingJoinPoint.proceed(new Object[] { msgContext, format, 
tee, preserve });
-        } finally {
-            log.close();
+        if (LogManager.INSTANCE.isLoggingEnabled()) {
+            OutputStream log = LogManager.INSTANCE.createLog("formatter");
+            try {
+                OutputStream tee = new TeeOutputStream(out, log);
+                proceedingJoinPoint.proceed(new Object[] { msgContext, format, 
tee, preserve });
+            } finally {
+                log.close();
+            }
+        } else {
+            proceedingJoinPoint.proceed();
         }
     }
     
@@ -61,20 +65,22 @@ public class LogAspect {
         pointcut="call(javax.activation.DataSource 
org.apache.axis2.format.MessageFormatterEx.getDataSource(..))",
         returning="dataSource")
     public void afterGetDataSource(DataSource dataSource) {
-        try {
-            OutputStream out = LogManager.INSTANCE.createLog("formatter");
+        if (LogManager.INSTANCE.isLoggingEnabled()) {
             try {
-                InputStream in = dataSource.getInputStream();
+                OutputStream out = LogManager.INSTANCE.createLog("formatter");
                 try {
-                    IOUtils.copy(in, out);
+                    InputStream in = dataSource.getInputStream();
+                    try {
+                        IOUtils.copy(in, out);
+                    } finally {
+                        in.close();
+                    }
                 } finally {
-                    in.close();
+                    out.close();
                 }
-            } finally {
-                out.close();
+            } catch (Throwable ex) {
+                log.error("Unable to dump message", ex);
             }
-        } catch (Throwable ex) {
-            log.error("Unable to dump message", ex);
         }
     }
     
@@ -83,16 +89,20 @@ public class LogAspect {
             " && args(in, contentType, msgContext)")
     public Object aroundProcessDocument(ProceedingJoinPoint 
proceedingJoinPoint,
             InputStream in, String contentType, MessageContext msgContext) 
throws Throwable {
-        InputStream tee;
-        if (in == null) {
-            tee = null;
+        if (LogManager.INSTANCE.isLoggingEnabled()) {
+            InputStream tee;
+            if (in == null) {
+                tee = null;
+            } else {
+                OutputStream log = LogManager.INSTANCE.createLog("builder");
+                // Note: We can't close the log right after the method 
execution because the
+                //       message builder may use streaming. LogManager will 
take care of closing the
+                //       log for us if anything goes wrong.
+                tee = new TeeInputStream(in, log, true);
+            }
+            return proceedingJoinPoint.proceed(new Object[] { tee, 
contentType, msgContext });
         } else {
-            OutputStream log = LogManager.INSTANCE.createLog("builder");
-            // Note: We can't close the log right after the method execution 
because the
-            //       message builder may use streaming. LogManager will take 
care of closing the
-            //       log for us if anything goes wrong.
-            tee = new TeeInputStream(in, log, true);
+            return proceedingJoinPoint.proceed();
         }
-        return proceedingJoinPoint.proceed(new Object[] { tee, contentType, 
msgContext });
     }
 }

Modified: 
axis/axis2/java/core/branches/1_7/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LogManager.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_7/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LogManager.java?rev=1746013&r1=1746012&r2=1746013&view=diff
==============================================================================
--- 
axis/axis2/java/core/branches/1_7/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LogManager.java
 (original)
+++ 
axis/axis2/java/core/branches/1_7/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LogManager.java
 Sun May 29 14:10:39 2016
@@ -70,6 +70,10 @@ public class LogManager {
         }
     }
     
+    public synchronized boolean isLoggingEnabled() {
+        return testCaseDir != null;
+    }
+    
     public synchronized OutputStream createLog(String name) throws IOException 
{
         testCaseDir.mkdirs();
         OutputStream log = new FileOutputStream(new File(testCaseDir, 
StringUtils.leftPad(String.valueOf(sequence++), 2, '0') + "-" + name + ".log"));


Reply via email to