Skip to content

Commit

Permalink
extra null pointer exception
Browse files Browse the repository at this point in the history
  • Loading branch information
hu0916 committed Dec 25, 2024
1 parent 698cfe8 commit ed158b5
Showing 1 changed file with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,24 @@ public DefaultHandler(ObjectMapper objectMapper, ApplicationEventPublisher publi
}
case 0 -> {//事件
final var data = jsonNode.get("d");
final var extra = data.get("extra");
final var type = extra.get("type").asText();

final List<Event> list = events.stream().filter(it -> it.type().equals(type)).toList();
if (list.isEmpty()) {
LOGGER.warn("未知事件:{}", type);
} else {
list.forEach(it -> {
try {
final Object event = objectMapper.readValue(message, it.klass());
publisher.publishEvent(event);
} catch (JsonProcessingException e) {
LOGGER.error("事件处理失败", e);
}
});
if (data.has("extra")) {
final var extra = data.get("extra");
final var type = extra.get("type").asText();
final List<Event> list = events.stream().filter(it -> it.type().equals(type)).toList();
if (list.isEmpty()) {
LOGGER.warn("未知事件:{}", type);
} else {
list.forEach(it -> {
try {
final Object event = objectMapper.readValue(message, it.klass());
publisher.publishEvent(event);
} catch (JsonProcessingException e) {
LOGGER.error("事件处理失败", e);
}
});
}
}else {
LOGGER.error("事件获取extra失败:{}", jsonNode);
}
}
}
Expand Down

0 comments on commit ed158b5

Please sign in to comment.