Closed yeikel closed 2 years ago
Note : I am able to run individual recipes. For example mvn rewrite:run -Drewrite.activeRecipes=org.openrewrite.java.cleanup.FinalClass
works as expected
Is this just an outdated log/configuration within OpenRewrite?
it seems that mvn rewrite:run -Drewrite.activeRecipes=org.openrewrite.java.logging.slf4j.ParameterizedLogging
works as expected, but the logs show :
Changes have been made to JsonUtilsTest.java by: [WARNING] org.openrewrite.java.logging.ParameterizedLogging
Which seems to be the source of my error
Thanks @yeikel. You are correct #49 and #50 modified org.openrewrite.java.logging.ParameterizedLogging
such that methodPattern
should be a required argument which would prevent the NPE and provide guidance on how to run the recipe.
Thanks @yeikel. You are correct #49 and #50 modified
org.openrewrite.java.logging.ParameterizedLogging
such thatmethodPattern
should be a required argument which would prevent the NPE and provide guidance on how to run the recipe.
Can we update the log of applied recipes as well? Not sure if your fix did it
As the current message is misleading
Can we update the log of applied recipes as well? Not sure if your fix did it As the current message is misleading
Are you referring to this? https://github.com/openrewrite/rewrite-maven-plugin/issues/326
Can we update the log of applied recipes as well? Not sure if your fix did it As the current message is misleading
Are you referring to this? openrewrite/rewrite-maven-plugin#326
No
I am referring to the fact that it prints :
[WARNING] Changes have been made to Hello.java by:
[WARNING] org.openrewrite.java.logging.ParameterizedLogging
When what it applied is org.openrewrite.java.logging.slf4j.ParameterizedLogging
Ok. That is a case where the org.openrewrite.java.logging.slf4j.ParameterizedLogging is a declarative recipe having org.openrewrite.java.logging.slf4j.ParameterizedLogging. ParameterizedLogging
is logged as a recipe that made changes because is the actual recipe that actually modified the AST. I am not sure how that is related to the NPE defined in this ussue.
Ok. That is a case where the org.openrewrite.java.logging.slf4j.ParameterizedLogging is a declarative recipe having org.openrewrite.java.logging.slf4j.ParameterizedLogging.
ParameterizedLogging
is logged as a recipe that made changes because is the actual recipe that actually modified the AST. I am not sure how that is related to the NPE defined in this ussue.
It is related because I encounter the NPE when tried to apply the recipe directly following what the log said
mvn rewrite:run -Drewrite.activeRecipes=org.openrewrite.java.logging.ParameterizedLogging
My assumption was that I should be able to apply any recipe printed in the logs but that's not the case. Is my assumption incorrect?
Yes, your assumption is incorrect, the logs only print the name of the recipe that made changes not including its associated configuration parameters. The NPE was a result of incomplete recipe validation which allowed the recipe to run with an invalid configuration. Now when you invoke mvn rewrite:run -Drewrite.activeRecipes=org.openrewrite.java.logging.ParameterizedLogging
the logs will inform you that the methodPattern
is null and the recipe will be skipped.
Yes, your assumption is incorrect, the logs only print the name of the recipe that made changes not including its associated configuration parameters. The NPE was a result of incomplete recipe validation which allowed the recipe to run with an invalid configuration. Now when you invoke
mvn rewrite:run -Drewrite.activeRecipes=org.openrewrite.java.logging.ParameterizedLogging
the logs will inform you that themethodPattern
is null and the recipe will be skipped.
What I don't understand is that I do not have any explicit configuration for openrewrite.java.logging.ParameterizedLogging
in my build. What I have is org.openrewrite.java.logging.slf4j.ParameterizedLogging
.
My confusion is that the log says that the recipe openrewrite.java.logging.ParameterizedLogging
is the one that applied the transformations when it was actually org.openrewrite.java.logging.slf4j.ParameterizedLogging
When I then tried to apply openrewrite.java.logging.ParameterizedLogging
, it failed with the NPE as the one I was supposed to run is org.openrewrite.java.logging.slf4j.ParameterizedLogging
instead
Shouldn't the log point out org.openrewrite.java.logging.slf4j.ParameterizedLogging
instead of openrewrite.java.logging.ParameterizedLogging
?
Shouldn't the log point out org.openrewrite.java.logging.slf4j.ParameterizedLogging instead of openrewrite.java.logging.ParameterizedLogging?
That would be a rewrite-core
issue related to how recipes that made changes are identified, it may not be identifying the parent declarative recipe.
Shouldn't the log point out org.openrewrite.java.logging.slf4j.ParameterizedLogging instead of openrewrite.java.logging.ParameterizedLogging?
That would be a
rewrite-core
issue related to how recipes that made changes are identified, it may not be identifying the parent declarative recipe.
Should I create a new issue there instead?
Should I create a new issue there instead?
Sure, it sounds like your request would be for an additional log message which identifies the active recipe to be logged along with the sub-recipes which actually made the change. Something like the following?
before:
[INFO] Using active recipe(s) [org.openrewrite.java.logging.slf4j.ParameterizedLogging]
...
[WARNING] Changes have been made to VetService.java by:
[WARNING] org.openrewrite.java.logging.ParameterizedLogging
after:
[INFO] Using active recipe(s) [org.openrewrite.java.logging.slf4j.ParameterizedLogging]
...
[WARNING] Changes have been made to VetService.java by:
[WARNING] org.openrewrite.java.logging.slf4j.ParameterizedLogging
[WARNING] org.openrewrite.java.logging.ParameterizedLogging
Should I create a new issue there instead?
Sure, it sounds like your request would be for an additional log message which identifies the active recipe to be logged along with the sub-recipes which actually made the change. Something like the following?
before:
[INFO] Using active recipe(s) [org.openrewrite.java.logging.slf4j.ParameterizedLogging] ... [WARNING] Changes have been made to VetService.java by: [WARNING] org.openrewrite.java.logging.ParameterizedLogging
after:
[INFO] Using active recipe(s) [org.openrewrite.java.logging.slf4j.ParameterizedLogging] ... [WARNING] Changes have been made to VetService.java by: [WARNING] org.openrewrite.java.logging.slf4j.ParameterizedLogging [WARNING] org.openrewrite.java.logging.ParameterizedLogging
Would org.openrewrite.java.logging.ParameterizedLogging
be needed in this case?
I would say yes. It would be useful for a number of reasons one being the ability to identify which recipe actually modified the AST when debugging inaccurate results.
I would say yes. It would be useful for a number of reasons one being the ability to identify which recipe actually modified the AST when debugging inaccurate results.
That makes sense
Where should I create the issue? You can probably word it better than me and that would be helpful
Thank you for your support
Sure any time, I will be happy to create the issue. Thanks for your help also :)
Command :
mvn rewrite:run -Drewrite.activeRecipes=org.openrewrite.java.logging.ParameterizedLogging
Simplified logs :
Stacktrace :
Env details :