Skip to content

Commit

Permalink
fix #646: NullPointerException "errorEventDefinition.getError().getEr…
Browse files Browse the repository at this point in the history
…rorCode()""
  • Loading branch information
nitram509 committed Jan 6, 2024
1 parent e47596b commit 772289e
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/main/java/io/zeebe/monitor/rest/ProcessesViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
import io.zeebe.monitor.rest.dto.ProcessDto;
import io.zeebe.monitor.rest.dto.ProcessInstanceListDto;
import io.zeebe.monitor.rest.dto.TimerDto;
import jakarta.transaction.Transactional;
import java.io.ByteArrayInputStream;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import jakarta.transaction.Transactional;
import org.camunda.bpm.model.xml.instance.ModelElementInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -221,8 +221,7 @@ private List<ElementInstanceState> getElementInstanceStates(final long key) {
Collectors.toMap(
ElementInstanceStatistics::getElementId, ElementInstanceStatistics::getCount));

final List<ElementInstanceState> elementInstanceStates =
elementEnteredStatistics.stream()
return elementEnteredStatistics.stream()
.map(
s -> {
final ElementInstanceState state = new ElementInstanceState();
Expand All @@ -239,7 +238,6 @@ private List<ElementInstanceState> getElementInstanceStates(final long key) {
return state;
})
.collect(Collectors.toList());
return elementInstanceStates;
}

static List<BpmnElementInfo> getBpmnElementInfos(final BpmnModelInstance bpmn) {
Expand Down Expand Up @@ -282,16 +280,16 @@ static List<BpmnElementInfo> getBpmnElementInfos(final BpmnModelInstance bpmn) {
.getEventDefinitions()
.forEach(
eventDefinition -> {
if (eventDefinition instanceof ErrorEventDefinition) {
final var errorEventDefinition = (ErrorEventDefinition) eventDefinition;
final var errorCode = errorEventDefinition.getError().getErrorCode();

info.setInfo("errorCode: " + errorCode);
if (eventDefinition instanceof ErrorEventDefinition errorEventDefinition) {
if (errorEventDefinition.getError() != null) {
info.setInfo("errorCode: " + errorEventDefinition.getError().getErrorCode());
} else {
info.setInfo("errorCode: <null>");
}
infos.add(info);
}

if (eventDefinition instanceof TimerEventDefinition) {
final var timerEventDefinition = (TimerEventDefinition) eventDefinition;
if (eventDefinition instanceof TimerEventDefinition timerEventDefinition) {

Optional.<ModelElementInstance>ofNullable(
timerEventDefinition.getTimeCycle())
Expand Down

0 comments on commit 772289e

Please sign in to comment.