Fix for @Default ignored for "contract-first" style controller - #793
Merged
Conversation
Given an interface with a @default on a @QueryParam like: ```java @QueryParam("useMaster") @default("false") boolean useMaster ``` The `@Default("false")` was not being read and applied on the query parameter. This resulted in a null being used and a InvalidPathArgumentException. ``` io.avaje.http.api.InvalidPathArgumentException: path element is null at io.avaje.http.api.PathTypeConversion.checkNull(PathTypeConversion.java:52) at io.avaje.http.api.PathTypeConversion.asBoolean(PathTypeConversion.java:178) at io.avaje.http.api.PathTypeConversion.asBool(PathTypeConversion.java:186) ... ``` The fix has 2 parts: A) Improve ProcessingContext.superMethods() which only matched on name and instead match also on parameter types etc B) Fix MethodReader to use the annotated element [from the super method / interface] as the controller method itself does not have those annotations like @default.
SentryMan
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Given an interface with a
@Defaulton a@QueryParamlike:The
@Default("false")was not being read and applied on the query parameter. This resulted in a null being used and a InvalidPathArgumentException.The fix has 2 parts:
A) Improve ProcessingContext.superMethods() which only matched on name and instead match also on parameter types etc
B) Fix MethodReader to use the annotated element [from the super method / interface] as the controller method itself does not have those annotations like
@Default.In the generated code, with the bug we see the null value like:
... when we expect the default value of "false" like:
Workaround
Copy the annotations from the interface (like
@QueryParam("useMaster") @Default("false")) to the controller method. This duplicates the annotations so not ideal but does mean that the generated code includes the default values as expected.