Skip to content

Commit

Permalink
Fix misleading DevUI score for void return types
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand authored and fercomunello committed Aug 31, 2022
1 parent ca2aa9f commit 09780c5
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ public RuntimeResource buildResourceMethod(ResourceClass clazz,
if (mediaType.isWildcardType() || mediaType.isWildcardSubtype()) {
handlers.add(new VariableProducesHandler(serverMediaType, serialisers));
score.add(ScoreSystem.Category.Writer, ScoreSystem.Diagnostic.WriterRunTime);
} else if (rawEffectiveReturnType != Void.class
&& rawEffectiveReturnType != void.class) {
} else if (isNotVoid(rawEffectiveReturnType)) {
List<MessageBodyWriter<?>> buildTimeWriters = serialisers.findBuildTimeWriters(rawEffectiveReturnType,
RuntimeType.SERVER, MediaTypeHelper.toListOfMediaType(method.getProduces()));
if (buildTimeWriters == null) {
Expand Down Expand Up @@ -444,7 +443,8 @@ public RuntimeResource buildResourceMethod(ResourceClass clazz,
score.add(ScoreSystem.Category.Writer, ScoreSystem.Diagnostic.WriterRunTime);
}
} else {
score.add(ScoreSystem.Category.Writer, ScoreSystem.Diagnostic.WriterRunTime);
score.add(ScoreSystem.Category.Writer, isNotVoid(rawEffectiveReturnType) ? ScoreSystem.Diagnostic.WriterRunTime
: ScoreSystem.Diagnostic.WriterNotRequired);
}
} else {
score.add(ScoreSystem.Category.Writer, ScoreSystem.Diagnostic.WriterRunTime);
Expand Down Expand Up @@ -487,6 +487,11 @@ public RuntimeResource buildResourceMethod(ResourceClass clazz,
clazz.resourceExceptionMapper());
}

private static boolean isNotVoid(Class<?> rawEffectiveReturnType) {
return rawEffectiveReturnType != Void.class
&& rawEffectiveReturnType != void.class;
}

private void addResponseHandler(ServerResourceMethod method, List<ServerRestHandler> handlers) {
if (method.getHandlerChainCustomizers().isEmpty()) {
handlers.add(ResponseHandler.NO_CUSTOMIZER_INSTANCE);
Expand Down

0 comments on commit 09780c5

Please sign in to comment.