This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-reqanalyzer.git

commit 0aec958a908b36de831d90ad1ed5d1980c42b176
Author: Felix Meschberger <[email protected]>
AuthorDate: Wed Jan 4 13:04:38 2017 +0000

    SLING-6433 Request Processing Analyzer throws IOOB due to old format 
assumptions of RequestProgressTracker output
    
    Apply patch by Krystian Nowak (thanks a lot)
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1777305 
13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 10 +++++
 .../reqanalyzer/impl/gui/RequestTableModel.java    |  5 +--
 .../impl/gui/RequestTableModelTest.java            | 51 ++++++++++++++++++++++
 src/test/resources/requesttracker.txt              |  7 +++
 4 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 52e307a..72d61ee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,6 +82,16 @@
                                  </signature>
                                </configuration>
                        </plugin>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <!--  text test resources -->
+                        <exclude>src/test/resources/*.txt</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
diff --git 
a/src/main/java/org/apache/sling/reqanalyzer/impl/gui/RequestTableModel.java 
b/src/main/java/org/apache/sling/reqanalyzer/impl/gui/RequestTableModel.java
index 078bdbe..27f69a2 100644
--- a/src/main/java/org/apache/sling/reqanalyzer/impl/gui/RequestTableModel.java
+++ b/src/main/java/org/apache/sling/reqanalyzer/impl/gui/RequestTableModel.java
@@ -30,11 +30,10 @@ public class RequestTableModel implements TableModel {
     private long previousStamp;
     
     void addRow(String row) {
-        // split row: "%1$7d (%2$tF %2$tT) %3$s%n
+        // split row: "%1$7d %3$s%n
         
         final String stampS = row.substring(0, 7);
-        final int endTimeStamp = row.indexOf(')');
-        final String message = row.substring(endTimeStamp+2); 
+        final String message = row.substring(7); 
         
         long stamp = Long.parseLong(stampS.trim());
         long delta = stamp - this.previousStamp;
diff --git 
a/src/test/java/org/apache/sling/reqanalyzer/impl/gui/RequestTableModelTest.java
 
b/src/test/java/org/apache/sling/reqanalyzer/impl/gui/RequestTableModelTest.java
new file mode 100644
index 0000000..1bac9b3
--- /dev/null
+++ 
b/src/test/java/org/apache/sling/reqanalyzer/impl/gui/RequestTableModelTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.sling.reqanalyzer.impl.gui;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.junit.Test;
+
+public class RequestTableModelTest {
+
+    private RequestTableModel rtm = new RequestTableModel();
+
+    @Test
+    public final void testAddRow() throws IOException {
+
+        BufferedReader r = new BufferedReader(
+                new 
InputStreamReader(getClass().getResourceAsStream("/requesttracker.txt")));
+
+        String line;
+        while ((line = r.readLine()) != null) {
+            if (line.charAt(0) == '!') {
+                rtm.addRow(line.substring(1));
+            }
+        }
+
+        r.close();
+
+        assertTrue(rtm.getRowCount() > 0);
+    }
+
+}
diff --git a/src/test/resources/requesttracker.txt 
b/src/test/resources/requesttracker.txt
new file mode 100644
index 0000000..a94a31f
--- /dev/null
+++ b/src/test/resources/requesttracker.txt
@@ -0,0 +1,7 @@
+:1483519553437:3:GET:/libs/mylib/data.json:application/json; 
charset=ISO-8859-1:200
+!      0 TIMER_START{Request Processing}
+!      2 COMMENT timer_end format is {<elapsed microseconds>,<timer name>} 
<optional message>
+!     11 LOG Method=GET, PathInfo=/libs/mylib/data.json
+!  16431 LOG Including resource MyResource, type=my/ohmy/type, superType=null, 
path=/libs/mylib:foo (SlingRequestPathInfo: path='/libs/mylib:foo', 
selectorString='null', extension='json', suffix='/my/my.html')
+! 925338 TIMER_START{resolveServlet(/my/servlet)}
+! 925353 TIMER_END{13,resolveServlet(/my/servlet)} Using servlet 
/libs/mylib/mylib.jsp

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to