Showing
1 changed file
with
14 additions
and
2 deletions
... | ... | @@ -320,17 +320,29 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ |
320 | 320 | boolean hasNext = true; |
321 | 321 | AlarmSeverity highestSeverity = null; |
322 | 322 | AlarmQuery query; |
323 | - while (hasNext && AlarmSeverity.CRITICAL != highestSeverity) { | |
323 | + while (hasNext) { | |
324 | 324 | query = new AlarmQuery(entityId, nextPageLink, alarmSearchStatus, alarmStatus, false, null); |
325 | 325 | PageData<AlarmInfo> alarms = alarmDao.findAlarms(tenantId, query); |
326 | + | |
327 | + if(alarms.getData().isEmpty()) { | |
328 | + return null; | |
329 | + } | |
326 | 330 | if (alarms.hasNext()) { |
327 | 331 | nextPageLink = nextPageLink.nextPageLink(); |
332 | + } else { | |
333 | + hasNext = false; | |
328 | 334 | } |
335 | + | |
329 | 336 | AlarmSeverity severity = detectHighestSeverity(alarms.getData()); |
330 | 337 | if (severity == null) { |
331 | 338 | continue; |
332 | 339 | } |
333 | - if (severity == AlarmSeverity.CRITICAL || highestSeverity == null) { | |
340 | + | |
341 | + if(severity == AlarmSeverity.CRITICAL) { | |
342 | + return severity; | |
343 | + } | |
344 | + | |
345 | + if (highestSeverity == null) { | |
334 | 346 | highestSeverity = severity; |
335 | 347 | } else { |
336 | 348 | highestSeverity = highestSeverity.compareTo(severity) < 0 ? highestSeverity : severity; | ... | ... |