Fix null pointer

This commit is contained in:
Christopher Schnick 2022-10-12 18:10:28 +02:00
parent ed073f331d
commit c525741b96
3 changed files with 10 additions and 6 deletions

View file

@ -8,7 +8,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
public class SimpleTupleNode extends TupleNode {
private final List<String> names;
@ -68,11 +67,10 @@ public class SimpleTupleNode extends TupleNode {
@Override
public DataStructureNode clear() {
nodes.clear();
names.clear();
if (names != null) names.clear();
return this;
}
@Override
public int size() {
return nodes.size();
@ -90,13 +88,14 @@ public class SimpleTupleNode extends TupleNode {
public List<KeyValue> getKeyValuePairs() {
var l = new ArrayList<KeyValue>(size());
for (int i = 0; i < size(); i++) {
l.add(new KeyValue(names != null ? getKeyNames().get(i) : null, getNodes().get(i)));
l.add(new KeyValue(
names != null ? getKeyNames().get(i) : null, getNodes().get(i)));
}
return l;
}
public List<String> getKeyNames() {
return Collections.unmodifiableList(names);
return names != null ? Collections.unmodifiableList(names) : Collections.nCopies(size(), null);
}
public List<DataStructureNode> getNodes() {

View file

@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
import java.util.function.Consumer;
public class JacksonMapper {
@ -37,6 +38,10 @@ public class JacksonMapper {
DEFAULT = BASE.copy();
}
public static synchronized void configure(Consumer<ObjectMapper> mapper) {
mapper.accept(INSTANCE);
}
public static synchronized void initClassBased() {
initModularized(null);
}

2
deps

@ -1 +1 @@
Subproject commit 2fe3d49953de977f50540e677f61b2463b1e8b82
Subproject commit 5ec6b963c1fd0b435dddc28b76caed019d7b9c25