You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by bo...@apache.org on 2016/02/23 03:03:00 UTC

tapestry-5 git commit: Fixed TAP5-2531 (OperationTracker doesn't report path when failing to create exception report files)

Repository: tapestry-5
Updated Branches:
  refs/heads/master 52baacb71 -> 1c2a1ed14


Fixed TAP5-2531 (OperationTracker doesn't report path when failing to
create exception report files)

Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/1c2a1ed1
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/1c2a1ed1
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/1c2a1ed1

Branch: refs/heads/master
Commit: 1c2a1ed1438ac1c8f565c49ca1999ad23e6593d1
Parents: 52baacb
Author: Bob Harner <bo...@gmail.com>
Authored: Tue Feb 16 07:26:37 2016 -0500
Committer: Bob Harner <bo...@gmail.com>
Committed: Tue Feb 16 09:24:04 2016 -0500

----------------------------------------------------------------------
 .../exceptions/ExceptionReporterImpl.java       | 40 +++++++++++++-------
 1 file changed, 27 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1c2a1ed1/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/exceptions/ExceptionReporterImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/exceptions/ExceptionReporterImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/exceptions/ExceptionReporterImpl.java
index af276d0..51d0fcb 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/exceptions/ExceptionReporterImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/exceptions/ExceptionReporterImpl.java
@@ -56,36 +56,50 @@ public class ExceptionReporterImpl implements ExceptionReporter
                 "exception-%tY%<tm%<td-%<tH%<tM%<tS-%<tL.%d.txt", date,
                 uid.getAndIncrement());
 
-        File folder;
+        File folder = getOutputFolder(date);
 
         try
         {
-            if (restrictive)
+            if (! restrictive)
             {
-                // Good luck with this; all exceptions written to a single folder.
-                folder = logDir;
-            } else
-            {
-                String folderName = String.format("%tY-%<tm-%<td/%<tH/%<tM", date);
-                folder = new File(logDir, folderName);
-
                 folder.mkdirs();
             }
-
             File log = new File(folder, fileName);
-
             writeExceptionToFile(exception, log);
 
             logger.warn(String.format("Wrote exception report to %s", toURI(log)));
         } catch (Exception ex)
         {
-            logger.error(String.format("Unable to write exception report %s: %s",
-                    fileName, ExceptionUtils.toMessage(ex)));
+            logger.error(String.format("Unable to write exception report %s at %s: %s",
+                    fileName, folder.getAbsolutePath(), ExceptionUtils.toMessage(ex)));
 
             logger.error("Original exception:", exception);
         }
     }
 
+    /**
+     * Get the path of the directory in which the exception report file(s) should
+     * be written. Except in "restrictive" environments like GAE, this is a
+     * dated sub-directory of the one specified in the
+     * tapestry.exception-reports-dir symbol.
+     * 
+     * @param date the date to be used if a dated directory is needed
+     * @return the File object representing the folder
+     */
+    private File getOutputFolder(Date date)
+    {
+        if (restrictive)
+        {
+            // Good luck with this; all exceptions written to a single folder.
+            return logDir;
+        } else
+        {
+            String folderName = String.format("%tY-%<tm-%<td/%<tH/%<tM", date);
+            return new File(logDir, folderName);
+        }
+
+    }
+
     private String toURI(File file)
     {
         try