Skip to content

Commit

Permalink
Provide a warning when a raw RestResponse return type is used
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Oct 18, 2022
1 parent 518792e commit ed806c8
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,12 @@ private ResourceMethod createResourceMethod(ClassInfo currentClassInfo, ClassInf
Type methodContextReturnTypeOrReturnType = methodContext.containsKey(METHOD_CONTEXT_CUSTOM_RETURN_TYPE_KEY)
? (Type) methodContext.get(METHOD_CONTEXT_CUSTOM_RETURN_TYPE_KEY)
: currentMethodInfo.returnType();
if (REST_RESPONSE.equals(methodContextReturnTypeOrReturnType.name())
&& (methodContextReturnTypeOrReturnType.kind() == Kind.CLASS)) {
log.warn("Method '" + currentMethodInfo.name() + " of Resource class '"
+ currentMethodInfo.declaringClass().name()
+ "' returns RestResponse but does not declare a generic type. It is strongly advised to define the generic type otherwise the behavior could be unpredictable");
}
Type nonAsyncReturnType = getNonAsyncReturnType(methodContextReturnTypeOrReturnType);
addWriterForType(additionalWriters, nonAsyncReturnType);

Expand Down

0 comments on commit ed806c8

Please sign in to comment.