Skip to content

Commit

Permalink
Collect providers required for RESTEasy's @PartType annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Jan 4, 2021
1 parent 75510b1 commit b7c5aea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ JaxrsProvidersToRegisterBuildItem setupProviders(BuildProducer<ReflectiveClassBu

boolean needJsonSupport = restJsonSupportNeeded(indexBuildItem, ResteasyDotNames.CONSUMES)
|| restJsonSupportNeeded(indexBuildItem, ResteasyDotNames.PRODUCES)
|| restJsonSupportNeeded(indexBuildItem, ResteasyDotNames.RESTEASY_SSE_ELEMENT_TYPE);
|| restJsonSupportNeeded(indexBuildItem, ResteasyDotNames.RESTEASY_SSE_ELEMENT_TYPE)
|| restJsonSupportNeeded(indexBuildItem, ResteasyDotNames.RESTEASY_PART_TYPE);
if (needJsonSupport) {
LOGGER.warn(
"Quarkus detected the need of REST JSON support but you have not provided the necessary JSON " +
Expand Down Expand Up @@ -483,6 +484,18 @@ private static boolean collectDeclaredProviders(List<RestClientBuildItem> restCl
}
}
}

// handle @PartType: we don't know if it's used for writing or reading so we register both
for (AnnotationInstance partTypeAnnotation : index.getAnnotations(ResteasyDotNames.RESTEASY_PART_TYPE)) {
try {
MediaType partTypeMediaType = MediaType.valueOf(partTypeAnnotation.value().asString());
providersToRegister.addAll(categorizedReaders.getPossible(partTypeMediaType));
providersToRegister.addAll(categorizedWriters.getPossible(partTypeMediaType));
} catch (IllegalArgumentException e) {
// Let's not throw an error, there's a good chance RESTEasy will do it for us
// and if not, this might be valid.
}
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public final class ResteasyDotNames {
.createSimple("org.jboss.resteasy.annotations.jaxrs.MatrixParam");
public static final DotName RESTEASY_SSE_ELEMENT_TYPE = DotName
.createSimple("org.jboss.resteasy.annotations.SseElementType");
public static final DotName RESTEASY_PART_TYPE = DotName
.createSimple("org.jboss.resteasy.annotations.providers.multipart.PartType");
public static final DotName CONFIG_PROPERTY = DotName
.createSimple(ConfigProperty.class.getName());
public static final DotName CDI_INSTANCE = DotName
Expand Down

0 comments on commit b7c5aea

Please sign in to comment.