-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameter name lost during Gradle's incremental compilation #5236
Comments
Perhaps this ticket should be moved to https://github.com/micronaut-projects/micronaut-gradle-plugin/? If someone could confirm that this is indeed a bug, then I would be happy to contribute a fix. |
Seems to be a bug in Java 8, works with JDK 11 |
Thanks for checking Graeme! I'm not sure what the guarantees for incremental annotation processing are, so this could be a bug in Java 8 or it could be Micronaut depending on unspecified behavior. Either way, does it make sense for Micronaut to run parameter validation on classes which are already compiled? E.g. if I incrementally compile only B.java, then should Micronaut validate the already-compiled A.class? If not, then perhaps this bug could be solved by simply not running validation on already-compiled classes? |
I'm not sure it is possible to know from the perspective of an annotation processor whether an element is compiled or not. I suspect what is happening is that Java is loading a |
that could be configured here micronaut-core/validation/src/main/java/io/micronaut/validation/routes/RouteValidationVisitor.java Line 114 in c13193f
|
@graemerocher I tried to create a fix in 5850bf9. Is it worth opening a PR, or are you working on a change yourself already? |
I haven't started yet, so go ahead an open a PR. The change looks good. |
Thanks for the contribution! |
Task List
Steps to Reproduce
git clone https://github.com/MartijnDwars/mn-test
cd mn-test
./gradlew compileJava
src/main/java/mn/test/ByeController.java
the text"Bye $n"
to"Byte $n+1"
../gradlew compileJava
The first
compileJava
runs fine, but the secondcompileJava
fails with the following error:For what it's worth, if you run
compileJava
a third time it would succeed. Also, if you runclean compileJava
you do not run into this problem, so this seems specific to some incremental compilation. I stumbled upon this issue when building through IntelliJ, which internally delegates to Gradle'scompileJava
.Expected Behaviour
Both
compileJava
tasks should succeed.Actual Behaviour
The second
compileJava
fails with the following error:The route declares a uri variable named [id], but no corresponding method argument is present
. I believe the following is happening:ByeController.java
, so incremental compilation triggers only the recompilation ofByeController.java
.HelloController.class
file.HelloController
(even though this class is already compiled and not changed).MissingParameterRule
is unable to match thearg0
parameter to the route and produces an error.Environment Information
Example Application
See https://github.com/martijndwars/mn-test
The text was updated successfully, but these errors were encountered: