-
Notifications
You must be signed in to change notification settings - Fork 134
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
Add an errorprone check and typed annotation for Javax -> Jakarta #2366
Conversation
There is a certain class of very problematic cases whereby if you have a method such as the following: ``` myJerseyResource.register(/* this is of type Object */ object); ``` Then if you supply a resource which includes any `javax.ws.rs` annotations on it, then those will not be registered if your Jersey version is 3.x or later (and you'll only find this out at runtime). The opposite is also true if you try to supply resources annotated with `jakarta.ws.rs` to Jersey 2.x. To address this, this commit attempts to add an errorprone check which lets implementors add an annotation `@ForbidJavax` to methods which have been knowingly migrated to Jakarta EE9 and cannot accept legacy javax types.
Generate changelog in
|
…seline into mglazer/require-jaxrs * 'mglazer/require-jaxrs' of github.com:palantir/gradle-baseline: Add generated changelog entries
baseline-error-prone-annotations/src/main/java/com/palantir/errorprone/ForbidJavax.java
Outdated
Show resolved
Hide resolved
...ine-error-prone/src/main/java/com/palantir/baseline/errorprone/ForbidJavaxParameterType.java
Outdated
Show resolved
Hide resolved
...ine-error-prone/src/main/java/com/palantir/baseline/errorprone/ForbidJavaxParameterType.java
Outdated
Show resolved
Hide resolved
When the CJR change goes through it should also resolve the error that I'm currently getting where I'm not publishing the annotations correctly somehow. |
...ine-error-prone/src/main/java/com/palantir/baseline/errorprone/ForbidJavaxParameterType.java
Outdated
Show resolved
Hide resolved
...error-prone/src/test/java/com/palantir/baseline/errorprone/ForbidJavaxParameterTypeTest.java
Show resolved
Hide resolved
Add ForbidJavax Annotation To address: palantir/gradle-baseline#2366
Added a couple of more tests, one to handle the case where you're supplying a resource which extends from a JaxRS annotated interface, and another to assert that this errorprone check is not perfect, and can't handle the case where there is no type information at all on the ingress types. |
...ine-error-prone/src/main/java/com/palantir/baseline/errorprone/ForbidJavaxParameterType.java
Outdated
Show resolved
Hide resolved
baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/MoreMatchers.java
Outdated
Show resolved
Hide resolved
...ine-error-prone/src/main/java/com/palantir/baseline/errorprone/ForbidJavaxParameterType.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
👍 |
###### _excavator_ is a bot for automating changes across repositories. Changes produced by the roomba/latest-baseline-oss check. # Release Notes ## 4.154.0 | Type | Description | Link | | ---- | ----------- | ---- | | Improvement | The JUnits reports plugin is no longer applied by default. Test reports now use the standard output locations from Gradle conventions. | palantir/gradle-baseline#2355 | ## 4.155.0 _Automated release, no documented user facing changes_ ## 4.156.0 | Type | Description | Link | | ---- | ----------- | ---- | | Fix | Fix BaselineJavaVersion checkstyle configuration on gradle < 7.5 | palantir/gradle-baseline#2360 | ## 4.157.0 | Type | Description | Link | | ---- | ----------- | ---- | | Improvement | Make task initialization lazier in the `junit-reports` plugin. | palantir/gradle-baseline#2364 | ## 4.158.0 | Type | Description | Link | | ---- | ----------- | ---- | | Fix | Make the `checkUnusedDependencies` tasks added by `baseline-exact-dependencies` compatible with Gradle's configure-on-demand feature. | palantir/gradle-baseline#2363 | ## 4.159.0 | Type | Description | Link | | ---- | ----------- | ---- | | Improvement | Add an errorprone check and typed annotation for Javax -> Jakarta<br><br>There is a certain class of very problematic cases whereby if you have<br>a method such as the following:<br><br>```<br>myJerseyResource.register(/* this is of type Object */ object);<br>```<br><br>Then if you supply a resource which includes any `javax.ws.rs`<br>annotations on it, then those will not be registered if your Jersey<br>version is 3.x or later (and you'll only find this out at runtime).<br><br>The opposite is also true if you try to supply resources annotated<br>with `jakarta.ws.rs` to Jersey 2.x.<br><br>To address this, this commit attempts to add an errorprone check<br>which lets implementors add an annotation `@ForbidJavax` to methods<br>which have been knowingly migrated to Jakarta EE9 and cannot<br>accept legacy javax types. | palantir/gradle-baseline#2366 | ## 4.160.0 | Type | Description | Link | | ---- | ----------- | ---- | | Fix | Workaround to IDEA-301084 | palantir/gradle-baseline#2368 | ## 4.161.0 | Type | Description | Link | | ---- | ----------- | ---- | | Fix | Reverts a change introduced to baseline-java-version 4.160.0, which was causing failures on multi-project builds. | palantir/gradle-baseline#2369 | To enable or disable this check, please contact the maintainers of Excavator.
Before this PR
Legacy javax.ws.rs types could be submitted to methods which only accept jakarta.ws.rs types at runtime.
After this PR
==COMMIT_MSG==
Add an errorprone check and typed annotation for Javax -> Jakarta
There is a certain class of very problematic cases whereby if you have
a method such as the following:
Then if you supply a resource which includes any
javax.ws.rs
annotations on it, then those will not be registered if your Jersey
version is 3.x or later (and you'll only find this out at runtime).
The opposite is also true if you try to supply resources annotated
with
jakarta.ws.rs
to Jersey 2.x.To address this, this commit attempts to add an errorprone check
which lets implementors add an annotation
@ForbidJavax
to methodswhich have been knowingly migrated to Jakarta EE9 and cannot
accept legacy javax types.
==COMMIT_MSG==
Possible downsides?