Skip to content

Commit

Permalink
fix: guard against NullPointerException in mergeFields, mergeEnums
Browse files Browse the repository at this point in the history
  • Loading branch information
vchudnov-g committed May 30, 2024
1 parent 7ce8f84 commit b8c09ea
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ private void mergeMessages(Map<String, Message> newMessages, Map<String, Message

private void mergeEnums(
Map<String, Message> newMessages, Message oldMessage, Message newMessage) {

if (newMessage == null) {
return;
}

Map<String, Message> newEnumsMap = new HashMap<>();
for (Message nestedEnum : newMessage.getEnums()) {
newEnumsMap.put(nestedEnum.getName(), nestedEnum);
Expand All @@ -99,6 +104,11 @@ private void mergeEnums(

private void mergeFields(
Message newMessage, Message oldMessage, Map<String, Message> newMessages) {

if (newMessage == null) {
return;
}

// Merge fields
Map<String, Field> newFieldsMap =
newMessage.getFields().stream().collect(Collectors.toMap(ProtoElement::getName, f -> f));
Expand Down

0 comments on commit b8c09ea

Please sign in to comment.