Skip to content

Commit

Permalink
read tree node to prevent an infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Goina committed Jan 9, 2023
1 parent b808c50 commit 958dd34
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;

import org.janelia.colormipsearch.model.FileData;

Expand All @@ -17,7 +18,15 @@ public FileData deserialize(JsonParser p, DeserializationContext ctxt) throws IO
} else if (p.getCurrentToken() == JsonToken.VALUE_STRING) {
return FileData.fromString(p.getValueAsString());
} else if (p.getCurrentToken() == JsonToken.START_OBJECT) {
return p.readValueAs(FileData.class);
JsonNode n = p.readValueAsTree();
JsonNode dataTypeNode = n.findValue("dataType");
JsonNode fileNameNode = n.findValue("fileName");
JsonNode entryNameNode = n.findValue("entryName");
return FileData.fromComponents(
dataTypeNode != null ? FileData.FileDataType.valueOf(dataTypeNode.asText()) : FileData.FileDataType.file,
fileNameNode != null ? fileNameNode.asText() : null,
entryNameNode != null ? entryNameNode.asText() : null
);
} else {
return null;
}
Expand Down

0 comments on commit 958dd34

Please sign in to comment.