You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/08/10 20:44:22 UTC

svn commit: r1156308 - in /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5: internal/services/RegexpStackTraceElementAnalyzer.java services/TapestryModule.java

Author: hlship
Date: Wed Aug 10 18:44:22 2011
New Revision: 1156308

URL: http://svn.apache.org/viewvc?rev=1156308&view=rev
Log:
TAP5-1603: Tapestry should omit stack frames related to the OperationTracker from exception report

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RegexpStackTraceElementAnalyzer.java
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RegexpStackTraceElementAnalyzer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RegexpStackTraceElementAnalyzer.java?rev=1156308&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RegexpStackTraceElementAnalyzer.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RegexpStackTraceElementAnalyzer.java Wed Aug 10 18:44:22 2011
@@ -0,0 +1,48 @@
+// Copyright 2011 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.internal.services;
+
+import org.apache.tapestry5.services.StackTraceElementAnalyzer;
+
+import java.util.regex.Pattern;
+
+/**
+ * Uses a regular expression to identify which CSS class to apply to a frame. The frame's {@code toString()} is used. Uses
+ * {@link java.util.regex.Matcher#find()} to search for a subsequence of the frame's description.
+ *
+ * @since 5.3
+ */
+public class RegexpStackTraceElementAnalyzer implements StackTraceElementAnalyzer
+{
+    private final Pattern pattern;
+
+    private final String cssClass;
+
+    public RegexpStackTraceElementAnalyzer(Pattern pattern, String cssClass)
+    {
+        this.pattern = pattern;
+        this.cssClass = cssClass;
+    }
+
+    public String classForFrame(StackTraceElement frame)
+    {
+        if (pattern.matcher(frame.toString()).find())
+        {
+            return cssClass;
+        }
+
+        return null;
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=1156308&r1=1156307&r2=1156308&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Wed Aug 10 18:44:22 2011
@@ -2621,6 +2621,8 @@ public final class TapestryModule
      * <dd>Checks for <code>sun.reflect</code> (which are omitted)
      * <dt>TapestryAOP</dt>
      * <dd>Omits stack frames for classes related to Tapestry AOP (such as advice, etc.)</dd>
+     * <dt>OperationTracker</dt>
+     * <dd>Omits stack frames related to {@link OperationTracker}</dd>
      * </dl>
      *
      * @since 5.1.0.0
@@ -2634,6 +2636,7 @@ public final class TapestryModule
         configuration.add("SunReflect", new PrefixCheckStackTraceElementAnalyzer(
                 StackTraceElementClassConstants.OMITTED, "sun.reflect."));
         configuration.addInstance("TapestryAOP", TapestryAOPStackFrameAnalyzer.class, "before:Application");
+        configuration.add("OperationTracker", new RegexpStackTraceElementAnalyzer(Pattern.compile("internal\\.(RegistryImpl|PerThreadOperationTracker|OperationTrackerImpl)\\.invoke\\("), StackTraceElementClassConstants.OMITTED));
     }
 
     /**