quarkus-oidc and scala extension integrations #37979
-
I am trying the https://quarkus.io/guides/security-keycloak-authorization guide on my quarkus scala project. I get the below exception when starting the quarkus application and I would like input for how to proceed in hunting the cause for this. I have no knowledge of vertx. I am using the io.quarkus:quarkus-resteasy-reactive-jackson dependency and have configured the io.quarkus.jackson.ObjectMapperCustomizer with the com.fasterxml.jackson.module.scala.DefaultScalaModule, so my rest endpoints worked (before adding the oidc extension).
|
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 26 replies
-
/cc @pedroigor (oidc), @sberyozkin (oidc) |
Beta Was this translation helpful? Give feedback.
-
@trym-moeller AFAIK Vert.x JsonObject is using Jackson internally and looks like the Scala mapper is interfering. My guess that having a reproducer will help, please create the one. CC @tsegismont @cescoffier |
Beta Was this translation helpful? Give feedback.
-
@trym-moeller You can get the vertx source and debug and see what is going on. My guess is the Scala mapper affects the client side Jackson processing of Vertx Web Client. |
Beta Was this translation helpful? Give feedback.
-
@trym-moeller So it is obvious the Scala serializer is conflicting with what Vertx |
Beta Was this translation helpful? Give feedback.
-
The public static final Function<Buffer, JsonObject> JSON_OBJECT_DECODER = buff -> {
Object val = Json.decodeValue(buff);
if (val == null) {
return null;
}
if (val instanceof JsonObject) {
return (JsonObject) val;
}
throw new DecodeException("Invalid Json Object decoded as " + val.getClass().getName());
}; The contract for this method is to return a /**
* Decode a given JSON buffer.
*
* @param buf the JSON buffer.
*
* @return a JSON element which can be a {@link JsonArray}, {@link JsonObject}, {@link String}, ...etc if the buffer contains an array, object, string, ...etc
* @throws DecodeException when there is a parsing or invalid mapping.
*/
public static Object decodeValue(Buffer buf) throws DecodeException {
return decodeValue(buf, Object.class);
}
/**
* Decode a given JSON buffer to a POJO of the given class type.
* @param buf the JSON buffer.
* @param clazz the class to map to.
* @param <T> the generic type.
* @return an instance of T
* @throws DecodeException when there is a parsing or invalid mapping.
*/
public static <T> T decodeValue(Buffer buf, Class<T> clazz) throws DecodeException {
return CODEC.fromBuffer(buf, clazz);
} To do so, it invokes the This works in all cases with the I'll try to make a reproducer test in Vert.x core and file an issue. I'll keep you informed. |
Beta Was this translation helpful? Give feedback.
-
I would wait before doing that. We could have a solution entirely upstream
Le lun. 8 janv. 2024, 09:50, Trym R. Møller ***@***.***> a
écrit :
… @tsegismont <https://github.com/tsegismont> ,
This seems like the correct solution, thanks for your investigation and
work!
@sberyozkin <https://github.com/sberyozkin> Can I create a feature
request for the io.quarkus.vertx.runtime.jackson.QuarkusJacksonJsonCode to
support the jackson DefaultScalaModule json (de)serializer?
—
Reply to this email directly, view it on GitHub
<#37979 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALOLNV4H337CUGZEGPJ2A3YNOXL5AVCNFSM6AAAAABBKERBPOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DANBVGQYTI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
@trym-moeller can you please try using this module instead of the default Scala module: import com.fasterxml.jackson.module.scala._
import com.fasterxml.jackson.module.scala.deser._
import com.fasterxml.jackson.module.scala.introspect._
class MyScalaModule
extends JacksonModule
with IteratorModule
with EnumerationModule
with OptionModule
with SeqModule
with IterableModule
with TupleModule
with MapModule
with SetModule
with ScalaNumberDeserializersModule
with ScalaObjectDeserializerModule
with ScalaAnnotationIntrospectorModule
with EitherModule
with SymbolModule {
override def getModuleName: String = "MyScalaModule"
}
object MyScalaModule The difference is it doesn't add |
Beta Was this translation helpful? Give feedback.
-
I don't know about the consequences of overriding a processor. Ideally, a contribution to the Scala extension would be better. But then the Scala extension you are using is deprecated, so I don't believe an enhancement PR would be accepted. Maybe @gsmet has some thoughts about this? On using a custom Jackson Scala module, the "This class aggregates all of the feature modules into a single concrete class. Its use is recommended for new users and users who want things to "just work". If more customized support is desired, consult each of the constituent traits." The So I believe you should be fine if you deserialize JSON payloads to your own Scala types (like your |
Beta Was this translation helpful? Give feedback.
-
@tsegismont, major thanks for working with @trym-moeller and finding a solution, apologies I was not replying, I was on PTO |
Beta Was this translation helpful? Give feedback.
I don't know about the consequences of overriding a processor. Ideally, a contribution to the Scala extension would be better. But then the Scala extension you are using is deprecated, so I don't believe an enhancement PR would be accepted.
Maybe @gsmet has some thoughts about this?
On using a custom Jackson Scala module, the
DefaultScalaModule
doc reads:"This class aggregates all of the feature modules into a single concrete class. Its use…