Skip to content

Commit

Permalink
add check on empty strings to prevent StringIndexOutOfBoundsException (
Browse files Browse the repository at this point in the history
  • Loading branch information
debbeca authored Oct 25, 2022
1 parent 9bf36e0 commit bee9005
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.qstd.QuickSqlTestData;
import org.springframework.util.StringUtils;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -195,12 +196,14 @@ private void quickPerfProcessing(HttpServletRequest httpServletRequest, HttpServ
}

if (databaseConfig.isSqlDisplayed()) {
infoReport.append(lineSeparator());
infoReport.append("* SQL");
infoReport.append(lineSeparator());
String sqlExecutionsAsString = sqlExecutions.toString();
String sqlExecutionsWithoutThreeLastLineBreaks = sqlExecutionsAsString.substring(0, sqlExecutionsAsString.length() - 3);
infoReport.append(sqlExecutionsWithoutThreeLastLineBreaks);
if(!StringUtils.isEmpty(sqlExecutionsAsString)) {
infoReport.append(lineSeparator());
infoReport.append("* SQL");
infoReport.append(lineSeparator());
String sqlExecutionsWithoutThreeLastLineBreaks = sqlExecutionsAsString.substring(0, sqlExecutionsAsString.length() - 3);
infoReport.append(sqlExecutionsWithoutThreeLastLineBreaks);
}
}

if (databaseConfig.isDatabaseConnectionProfiled()) {
Expand Down

0 comments on commit bee9005

Please sign in to comment.