You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package org.example;
import com.fasterxml.jackson.annotation.*;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
public class A
{
private final String name;
@Inject
@JsonCreator
A(@JacksonInject X x, @Assisted @JsonProperty("name") String name) {
this.name = name;
}
public String getName() {
return name;
}
}
But valueId, in findInjectableValue, takes the name of the class, which is a string and cannot be converted to a Key, and we get an ClassCastException.
We ended-up creating our own InjectableValues subclass to handle this correctly:
I don't know if the original author of this module is around any more, but if you were able to provide a PR against 2.14 I could merge improvements. I don't know how practical this would be wrt compatibility but if you think it is doable I always try to help get PRs merged.
Looking at the code of GuiceInjectableValues, it seems unable to handle string values, which is what you get by default:
We try to deserialize an object of class A:
But valueId, in findInjectableValue, takes the name of the class, which is a string and cannot be converted to a Key, and we get an ClassCastException.
We ended-up creating our own InjectableValues subclass to handle this correctly:
This is what the main of our small toy program looks like:
Version of guice: 5.1.0
Version of jackson-module-guice: 2.13.3
The text was updated successfully, but these errors were encountered: