JSON deserialize different behavior native vs. jar

1,921 views
Skip to first unread message

Brett Tofel

unread,
Feb 10, 2021, 4:49:07 PM2/10/21
to Quarkus Development mailing list

Does this ring a bell for anyone? I am succeeding in deserializing a mounted file when I run this code as a jar, but not when I compile to native and run in the cluster. File seems available in both cases, though that could be the diff, but if so, it's an unexpected error to throw.

This is the error from running native version on the file that worked with jar version:

```bash
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `javautil.manifests.csv.ClusterServiceVersion` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
```
Code lines in question:
```java
File maybeYaml = Paths.get(path.toString()).toFile();
try {
maybeCSV = new ObjectMapper(new YAMLFactory()).readValue(maybeYaml, ClusterServiceVersion.class);
} catch (JsonProcessingException e) {
System.out.println("Failed to deserialize: " + maybeYaml.getName());
e.printStackTrace();
return false;
```
And yes the ClusterServiceVersion class (had to make one custom with jsonschema2pojo as Fabric8 version isn't seeming to work for me with this file) has a constructor. But point being, the same yaml file deserialized fine on the jar version?

Thanks,
Brett

Guillaume Smet

unread,
Feb 10, 2021, 4:56:41 PM2/10/21
to bto...@redhat.com, Quarkus Development mailing list
It's the dead code elimination of GraalVM removing the constructor as it's not explicitly called.


--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/1cbe4648-5f4f-4271-bce2-750b762a2259n%40googlegroups.com.

Brett Tofel

unread,
Feb 10, 2021, 5:11:43 PM2/10/21
to Guillaume Smet, Quarkus Development mailing list
Thanks so much! Will do.

Reply all
Reply to author
Forward
0 new messages