Skip to content

FIXED unsupported jaxrs-2.1 annotations should not break entire interface - #672

Merged
velo merged 4 commits into
OpenFeign:masterfrom
masc3d:master
May 1, 2018
Merged

FIXED unsupported jaxrs-2.1 annotations should not break entire interface#672
velo merged 4 commits into
OpenFeign:masterfrom
masc3d:master

Conversation

@masc3d

@masc3d masc3d commented Mar 31, 2018

Copy link
Copy Markdown
Contributor

resolving #669

Comment thread jaxrs/pom.xml Outdated
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<artifactId>javax.ws.rs-api</artifactId>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Dangerous thing to do in a minor, changing a dependency like this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how? jax-rs-2.1 is fully backwards compatible down to 1.1.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one way to address this, is to keep the original dependency and add the new one as provided.

For those using jax-rs 2, they would need to explicitly declare the dependency. And for the ones already using jax-rs 1 no need for changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spencergibb how is this a minor btw? I'm actually considering jax-rs-2.x breakage pretty much a major considering there's no applicable workaround and the spec has been around for half a decade by now. In consideration of 2.x being backwards compatible thus applicable as drop-in substitute, would make jsr-311 legacy support pretty much a minor instead.

@velo

velo commented Apr 1, 2018

Copy link
Copy Markdown
Member

Some testing would be nice, but my main concern is breaking for people using Jax RS 1

@kdavisk6

kdavisk6 commented Apr 2, 2018

Copy link
Copy Markdown
Member

Agreed. Changing a dependencies major version may cause users of the client headaches if they aren't prepared when they update.

@masc3d

masc3d commented Apr 2, 2018

Copy link
Copy Markdown
Contributor Author

while I don't share any concerns for breakage technically, I would agree it's formally not appropriate to bump this spec as part of a minor patch.

// masc20180327. parameter with unsupported jax-rs annotations should not be passed as body params.
// this will prevent interfaces from becoming unusable entirely due to single (unsupported) endpoints.
// https://github.com/OpenFeign/feign/issues/669
if (annotationType == Suspended.class || annotationType == Context.class) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a String check here?

annotationType.getClass().equals("javax.ws.rs.container.Suspended")
Why? To prevent class def not found for anyone that still wanna use jax-rs 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that may work, but it's ugly and prone to breakage on maintenance so I won't supply this. I'd rather have feign-jaxrs-2. also I don't see any reason (for anyone) to even include jax-rs-1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you plan to support jax-rs-2 in feign in general?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's ugly and prone to breakage on maintenance
agree

may be a try-catch for the ClassDefNotFound

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@velo is it universally predictable when jvm's throw this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume this is thrown by jvm before processAnnotationsOnParameter is invoked even, but I could be wrong.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a PR with an "example" and the exception as well
https://github.com/masc3d/feign/pull/1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's overkill or not, but you could always use the maven-invoker-plugin to test compatibility.

Comment thread jaxrs/pom.xml Outdated
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<artifactId>javax.ws.rs-api</artifactId>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one way to address this, is to keep the original dependency and add the new one as provided.

For those using jax-rs 2, they would need to explicitly declare the dependency. And for the ones already using jax-rs 1 no need for changes.

@spencergibb

Copy link
Copy Markdown
Contributor

I don't see any reason (for anyone) to even include jax-rs-1.

Except for the people who can't or aren't willing to upgrade.

@masc3d

masc3d commented Apr 8, 2018

Copy link
Copy Markdown
Contributor Author

If it's acceptable to have feign-jaxrs-2 and jsr311-api as a provided dependency in feign-jaxrs-1, JAXRSContract could be derived from to accomplish this while sharing most or even all of the code without string based annotation matching.

@kdavisk6

Copy link
Copy Markdown
Member

@masc3d have you considered creating a feign-jaxrs-2 library? This approach could be more direct and address any concerns others changing the dependencies in feign-jaxrs. If creating a new library just for these changes seems too much, another option could be to release a new major version of feign-jaxrs making the move to 2.x explicit.

Thoughts?

@spencergibb

Copy link
Copy Markdown
Contributor

I think those are the only two options

@masc3d

masc3d commented Apr 11, 2018

Copy link
Copy Markdown
Contributor Author

@kdavisk6 yes I proposed this one comment above, still waiting for feedback.

@masc3d

masc3d commented Apr 11, 2018

Copy link
Copy Markdown
Contributor Author

how do you plan to support jax-rs-2 in feign in general?

if you can agree on a major version bump anytime soon it probably doesn't make sense to spawn a new artifact now.

@kdavisk6

Copy link
Copy Markdown
Member

I'm in the camp of creating a major release of feign-jaxrs.

@spencergibb

Copy link
Copy Markdown
Contributor

It would be the whole project since modules are not released independently

@kdavisk6

Copy link
Copy Markdown
Member

Oh, I was not aware of that.

@masc3d

masc3d commented Apr 19, 2018

Copy link
Copy Markdown
Contributor Author

I decided I won't provide a jsr311 compatible setup. those consumers which are allegedly adversely affected in a way that can't be easily mitigated probably don't even exist.

@kdavisk6

Copy link
Copy Markdown
Member

After reading into this further, it's difficult to say with any confidence how many users of Feign are still using JAX-RS 1.x (jsr311) libraries. With that in mind, my suggestion would be deprecate feign-jaxrs and create a new feign-jarxrs2 library with first class JAX-RS 2.x support and beyond.

This will allow users of the library who are still on JSR-311 to receive core feign updates and those that want to take advantage of JAX-RS 2.0 features the ability to do so. Thoughts?

@velo velo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job, just 2 small pointers, if you can't do then, lemme know and I will

Comment thread httpclient/pom.xml
<scope>test</scope>
</dependency>

<dependency>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is being used, is it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's required for test as jsr311-api is not pulled in transitively any longer. will add scope.

Comment thread jaxrs2/README.md
@@ -0,0 +1,2 @@
# Feign JAXRS 2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just "copy" README from jaxrs?!

@velo
velo merged commit 94ce071 into OpenFeign:master May 1, 2018
velo added a commit that referenced this pull request May 1, 2018
velo pushed a commit that referenced this pull request Oct 7, 2024
…face (#672)

* FIXED unsupported jaxrs-2.1 annotations should not break entire interface, resolving #669

* UPDATED jaxrs: more defensive jaxrs2 support

* ADDED jsr311-api dependency to httpclient (as jsr311 is `provided` in feign-jaxrs now)

* UPDATED httpclient `jsr311-api` scope to test
UPDATED jaxrs readme
velo pushed a commit that referenced this pull request Oct 8, 2024
…face (#672)

* FIXED unsupported jaxrs-2.1 annotations should not break entire interface, resolving #669

* UPDATED jaxrs: more defensive jaxrs2 support

* ADDED jsr311-api dependency to httpclient (as jsr311 is `provided` in feign-jaxrs now)

* UPDATED httpclient `jsr311-api` scope to test
UPDATED jaxrs readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants