ppkarwasz commented on code in PR #3212: URL: https://github.com/apache/logging-log4j2/pull/3212#discussion_r1846202154
########## log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/StackTraceStringResolver.java: ########## @@ -253,13 +253,14 @@ else if (bufferIndex < (endIndex - 12) private static int findLineStartIndex(final CharSequence buffer, final int startIndex, final int endIndex) { char prevChar = '-'; - for (int i = startIndex; i <= endIndex; i++) { + int i = startIndex; + for (; i < endIndex; i++) { if (prevChar == '\n') { return i; } prevChar = buffer.charAt(i); } - return -1; + return prevChar == '\n' ? i : -1; Review Comment: Shouldn't this always return `-1`? We are looking for the first index `i < endIndex` such that `buffer.charAt(i - 1) == '\n'`. Such an index will always be returned by the loop, not the fallback `return` statement. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org