Skip to content

Commit

Permalink
Ensure that custom MessageBodyReader classes work properly in native …
Browse files Browse the repository at this point in the history
…mode

Fixes: quarkusio#27167
  • Loading branch information
geoand committed Aug 8, 2022
1 parent b08a139 commit 4785d84
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,9 @@ public void serverSerializers(ResteasyReactiveRecorder recorder,

@BuildStep
public void additionalReflection(BeanArchiveIndexBuildItem beanArchiveIndexBuildItem,
SetupEndpointsResultBuildItem setupEndpointsResult, List<MessageBodyWriterBuildItem> messageBodyWriterBuildItems,
SetupEndpointsResultBuildItem setupEndpointsResult,
List<MessageBodyReaderBuildItem> messageBodyReaderBuildItems,
List<MessageBodyWriterBuildItem> messageBodyWriterBuildItems,
BuildProducer<ReflectiveClassBuildItem> producer) {
List<ResourceClass> resourceClasses = setupEndpointsResult.getResourceClasses();
IndexView index = beanArchiveIndexBuildItem.getIndex();
Expand All @@ -737,6 +739,25 @@ public void additionalReflection(BeanArchiveIndexBuildItem beanArchiveIndexBuild
break;
}
}
if (!serializersRequireResourceReflection) {
for (var reader : messageBodyReaderBuildItems) {
if (reader.isBuiltin()) {
continue;
}
if ((reader.getRuntimeType() != null) && (reader.getRuntimeType() == RuntimeType.CLIENT)) {
continue;
}
ClassInfo writerClassInfo = index.getClassByName(DotName.createSimple(reader.getClassName()));
if (writerClassInfo == null) {
continue;
}
List<DotName> interfaceNames = writerClassInfo.interfaceNames();
if (!interfaceNames.contains(ResteasyReactiveServerDotNames.SERVER_MESSAGE_BODY_READER)) {
serializersRequireResourceReflection = true;
break;
}
}
}
if (serializersRequireResourceReflection) {
producer.produce(ReflectiveClassBuildItem
.builder(resourceClasses.stream().map(ResourceClass::getClassName).toArray(String[]::new)).fields(false)
Expand Down

0 comments on commit 4785d84

Please sign in to comment.