[prev in list] [next in list] [prev in thread] [next in thread]
List: logback-dev
Subject: [logback-dev] [Bug 78] New: bad index in extract CallerData
From: bugzilla-daemon () pixie ! qos ! ch
Date: 2007-06-02 15:18:15
Message-ID: bug-78-11 () http ! bugzilla ! qos ! ch/
[Download RAW message or body]
http://bugzilla.qos.ch/show_bug.cgi?id=78
Summary: bad index in extract CallerData
Product: logback-classic
Version: unspecified
Platform: Macintosh
OS/Version: Mac OS
Status: NEW
Severity: blocker
Priority: P1
Component: Other
AssignedTo: logback-dev@qos.ch
ReportedBy: hansm@science.uva.nl
CC: hansm@science.uva.nl
Below is code from CallerData (logback 0.9.7)
This gives an error as shown below.
java.lang.ArrayIndexOutOfBoundsException: -1
at ch.qos.logback.classic.spi.CallerData.extract(CallerData.java:101)
at
ch.qos.logback.classic.spi.LoggingEvent.getCallerData(LoggingEvent.java:246)
In my code (Eclipse RCP) LoggingEvent's are collected by an appender in a
java.util.List.
Then a Jface TableViewer is allocated and the input set to that list. The
processing of the accumulated LoggingEvents now each throw the
ArrayIndexOutOfBoundsException.
After registering the viewer containing object with the appender, new incoming
LoggingEvents are given to the viewer and are processed without problem.
It looks like the "int found" has kept its value of -1, presumably because
the equals in line 88 never becomes true.
I am inclined to consider this a bug, or at least unsafe coding, because
a bad index in certain circumstances can reach the code in line 101.
The code in lines 86-97 does not guarantee that a bad index cannot occur.
78 public static CallerData[] extract(Throwable t, String
fqnOfInvokingClass) {
79 if (t == null) {
80 return null;
81 }
82
83 StackTraceElement[] steArray = t.getStackTrace();
84 CallerData[] callerDataArray;
85
86 int found = -1;
87 for (int i = 0; i < steArray.length; i++) {
88 if(steArray[i].getClassName().equals(fqnOfInvokingClass)) {
89 // the caller is assumed to be the next stack frame, hence the +1.
90 found = i + 1;
91 } else {
92 if(found != -1) {
93 break;
94 }
95 }
96
97 }
98
99 callerDataArray = new CallerData[steArray.length - found];
100 for (int i = found; i < steArray.length; i++) {
101 callerDataArray[i-found] = new CallerData(steArray[i]);
102 }
103 return callerDataArray;
104 }
105
--
Configure bugmail: http://bugzilla.qos.ch/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
_______________________________________________
logback-dev mailing list
logback-dev@qos.ch
http://qos.ch/mailman/listinfo/logback-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic