Skip to content

Commit c5c7831

Browse files
committed
Handle null checks for 'comments' in ModuleInfo methods
Added null checks to prevent potential NullPointerExceptions in methods interacting with the 'comments' map. This ensures safer handling of cases where 'comments' might be undefined or uninitialized.
1 parent f2ac0dc commit c5c7831

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/com/chaoticsomeone/ModInfGen/model/ModuleInfo.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ public void expandVariables() {
105105
setExports(getExports().stream().map(variableMapper).toList());
106106
setLegacy(getLegacy().stream().map(variableMapper).toList());
107107

108-
for (String commentKey : comments.keySet()) {
109-
comments.put(commentKey, variableMapper.apply(comments.get(commentKey)));
108+
if (comments != null) {
109+
for (String commentKey : comments.keySet()) {
110+
comments.put(commentKey, variableMapper.apply(comments.get(commentKey)));
111+
}
110112
}
111113

112114
for (OpensDeclaration open : opens) {
@@ -185,6 +187,10 @@ public void setComments(Map<String, String> comments) {
185187
}
186188

187189
public String getComment(String key) {
190+
if (comments == null) {
191+
return null;
192+
}
193+
188194
return comments.get(key);
189195
}
190196

0 commit comments

Comments
 (0)