Skip to content

Commit 4bac1ab

Browse files
committed
🐛 avoid NPE for empty source strings
1 parent 87885b0 commit 4bac1ab

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/java/dev/ebullient/convert/config/CompendiumConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package dev.ebullient.convert.config;
22

3+
import static dev.ebullient.convert.StringUtil.isPresent;
4+
35
import java.io.IOException;
46
import java.nio.file.Path;
57
import java.util.Arrays;
@@ -210,6 +212,7 @@ public String tagOfRaw(String tag) {
210212
public List<String> resolveBooks() {
211213
// works for 5eTools and pf2eTools
212214
return books.stream()
215+
.filter(x -> isPresent(x))
213216
.map(b -> {
214217
if (b.endsWith(".json")) {
215218
return b;
@@ -226,6 +229,7 @@ public List<String> resolveBooks() {
226229
public List<String> resolveAdventures() {
227230
// works for 5eTools and pf2eTools
228231
return adventures.stream()
232+
.filter(x -> isPresent(x))
229233
.map(a -> {
230234
if (a.endsWith(".json")) {
231235
return a;
@@ -240,6 +244,7 @@ public List<String> resolveAdventures() {
240244
}
241245

242246
public Collection<String> resolveHomebrew() {
247+
homebrew.removeIf(x -> isPresent(x));
243248
return Collections.unmodifiableCollection(homebrew);
244249
}
245250

src/test/java/dev/ebullient/convert/tools/dnd5e/FilterAllTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,16 @@ public static void setupDir() throws Exception {
3535
"book": [
3636
"XGE",
3737
"XMM",
38-
"FRAiF"
38+
"FRAiF",
39+
""
3940
],
4041
"adventure": [
4142
"OotA",
42-
"DIP"
43+
"DIP",
44+
""
45+
],
46+
"homebrew": [
47+
""
4348
],
4449
"reference": [
4550
"*"

0 commit comments

Comments
 (0)