Skip to content

Commit

Permalink
Merge pull request payara#306 from MeroRai/FISH-1084
Browse files Browse the repository at this point in the history
FISH-1084 NullPointerException when getting monitoring data for JDBC
  • Loading branch information
MeroRai authored Feb 24, 2021
2 parents 9d5c6d1 + d58c963 commit 64e4a55
Showing 1 changed file with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,17 @@ public CountStatistic getNumStatementCacheMiss() {

@ManagedAttribute(id="frequsedsqlqueries")
public ListStatistic getfreqUsedSqlQueries() {
List<SQLTrace> sqlTraces = freqSqlTraceCache.getTopQueries();
freqUsedSqlQueries = new ListStatisticImpl("frequsedsqlqueries", "List", "Most frequently used sql queries");

for (SQLTrace trace : sqlTraces){
CountStatisticImpl stat = new CountStatisticImpl(trace.getQueryName(), "Count", "");
stat.setCount(trace.getNumExecutions());
freqUsedSqlQueries.add(stat);
if (freqSqlTraceCache != null) {
List<SQLTrace> sqlTraces = freqSqlTraceCache.getTopQueries();
freqUsedSqlQueries = new ListStatisticImpl("frequsedsqlqueries", "List", "Most frequently used sql queries");

for (SQLTrace trace : sqlTraces) {
CountStatisticImpl stat = new CountStatisticImpl(trace.getQueryName(), "Count", "");
stat.setCount(trace.getNumExecutions());
freqUsedSqlQueries.add(stat);
}
}

return freqUsedSqlQueries;
}

Expand All @@ -226,12 +228,15 @@ public ListStatistic getSlowSqlQueries() {
//Make sure no data from previous execution is kept
slowSqlQueries.reset();
slowSqlQueries.clear();
//Get slow queries and process them
List<SlowSqlTrace> slowTraces = slowSqlTraceCache.getSlowestSqlQueries();
for (SlowSqlTrace trace: slowTraces){
CountStatisticImpl stat = new CountStatisticImpl(trace.getQueryName(), StatisticImpl.UNIT_MILLISECOND, "Longest execution time");
stat.setCount(trace.getSlowestExecutionTime());
slowSqlQueries.add(stat);

if (slowSqlTraceCache != null) {
//Get slow queries and process them
List<SlowSqlTrace> slowTraces = slowSqlTraceCache.getSlowestSqlQueries();
for (SlowSqlTrace trace : slowTraces) {
CountStatisticImpl stat = new CountStatisticImpl(trace.getQueryName(), StatisticImpl.UNIT_MILLISECOND, "Longest execution time");
stat.setCount(trace.getSlowestExecutionTime());
slowSqlQueries.add(stat);
}
}

return slowSqlQueries;
Expand Down

0 comments on commit 64e4a55

Please sign in to comment.