Adding ClientFactory abstraction to allow alternate JAXRS implementations to be used#340
Adding ClientFactory abstraction to allow alternate JAXRS implementations to be used#340jskjons wants to merge 7 commits intospotify:masterfrom
Conversation
Current coverage is 62.78% (diff: 75.78%)@@ master #340 diff @@
==========================================
Files 130 81 -49
Lines 4331 2940 -1391
Methods 0 0
Messages 0 0
Branches 635 403 -232
==========================================
- Hits 2007 1846 -161
+ Misses 2134 1094 -1040
+ Partials 190 0 -190
|
| @@ -57,11 +57,7 @@ | |||
| import org.apache.http.conn.ssl.SSLConnectionSocketFactory; | |||
| import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; | |||
| import org.glassfish.hk2.api.MultiException; | |||
There was a problem hiding this comment.
It seems this code is still dependent on org.glassfish.hk2.api.MultiException and org.glassfish.jersey.internal.util.Base64. Are you sure that this client still works when glassfish has completely vanished from the classpath? And that the exception handling works well if glassfish is replaced with resteasy?
There was a problem hiding this comment.
MultiException is in hk2-api which doesn't seem to conflict with RESTEasy anyways so I don't think I need to worry about getting rid of the reference, although explicitly adding the maven dependency rather than using it transitively would be good. I'll make that change.
Base64 I didn't notice and I assume would've failed if I tried to use it with registry authentication. Any objections to switching that to commons-codec?
There was a problem hiding this comment.
We could also switch to Java8 and use Base64.getEncoder()
On Mon, 2 May 2016 at 18:19 Jeff Skjonsby notifications@github.com wrote:
In src/main/java/com/spotify/docker/client/DefaultDockerClient.java
#340 (comment):@@ -57,11 +57,7 @@
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.glassfish.hk2.api.MultiException;MultiException is in hk2-api which doesn't seem to conflict with RESTEasy
anyways so I don't think I need to worry about getting rid of the
reference, although explicitly adding the maven dependency rather than
using it transitively would be good. I'll make that change.Base64 I didn't notice and I assume would've failed if I tried to use it
with registry authentication. Any objections to switching that to
commons-codec?—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/spotify/docker-client/pull/340/files/f540f50f336c198eca7ea006a9f59e5a5f0f0e30#r61761412
There was a problem hiding this comment.
yeah that was the first thing I thought of but thought it might be a bit presumptuous to update the jdk version in this PR :)
There was a problem hiding this comment.
But resteasy does not throw hk2-exceptions, but jax-rs exceptions, so that is different right?
There was a problem hiding this comment.
The only place the MultiException is used is in an multi-catch with ExecutionException which is what gets thrown by either implementation from what I can tell in the .get() call because it's async. In my tests it seems to propagate exceptions just fine. They get dealt with by the line
} else if (cause instanceof WebApplicationException) {...
There was a problem hiding this comment.
Ah, missed that statement. Exception handlig should be fine then! 👍
|
Great work! The PR looks quite good. There are a few remarks from my side (as a contributor, not maintainer). It seems the code is still dependent on I would love to see a few additions:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.16.Final</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>(In fact, this should also be done with the
|
|
ping @grexe |
eddee9f to
4d878f6
Compare
|
I can add the optional dependencies but I'm not sure if it really adds much value since the user still has to add those dependencies themselves anyway. Unless you're going to fully support multiple JAXRS implementations I'm not sure how much value there is in kinda-sorta supporting it. I mainly wanted to clear the roadblock preventing usage of anything else. If you want to full on support multiple implementations I think ideally there should be a few more breaking changes like extracting the dependencies and factories into separate modules. I'm happy to add an example usage of using RESTEasy with this, should that go in user_manual.md? |
|
The dependencies should be included anyway in order to be able to test the Resteasy client. My opinion is still that this should be tested properly, including timeout and exception behaviour. So I would like to see the integration tests to be ran on both client implementations. The optional inclusion would mostly be a cosmetic feature indicating it can be used with other clients. |
|
fair enough, I'll make that change today. |
|
Allright. I can have a look on Thursday to maybe add some tests if you'd like :) |
|
I added the ResteasyClientFactory implementation as well as deps + docs. It turned out there was a few of the features that we were using (streaming stuff in particular) that was a bit of a pain to get working in RESTEasy but the integration tests are passing now. The Events stuff currently directly relies on jersey so it would be more difficult to get working so I just left it for now and documented that fact. |
|
Whoa, great work! Will defenitely start using our fork 😄 Any idea on the last failing test case?
|
| * [Exec Resize](#exec-resize) | ||
| * [Exec Inspect](#exec-inspect) | ||
| * [Mounting volumes in a container](#mounting-volumes-in-a-container) | ||
| * [Using RESTEasy instead of Jersey]#(resteasy) |
There was a problem hiding this comment.
Seems that the #( should be flipped to (# (preview)
|
that last test was failing because the events stuff doesn't work with resteasy so I needed to add
to all of those tests and missed one. Should be good now. |
|
Great! Waiting on response from the maintainers then. |
|
That test failure on 1.10.3 is caused by the same problem as #412. That issue (or at least the test that failed because of the issue) was fixed in #415. Rebase this PR on master and that issue should go away. |
…lementations to be used
This required: - adding a few annotations - adding resteasy dependencies - adding hackery to make streaming work with RESTEasy - switching to Parameterized JUnit tests - documentation for how to use it
|
+1 |
|
Any updates on this? |
|
I haven't had time to keep the branch up to date with master and I haven't heard anything from the maintainers so it appears this isn't a priority or not a direction the maintainers want to go it. We're still internally using this branch so it still works. |
|
I am having trouble to use the library under Glassfish / Payara due to Jersey conflicts - this might be the solution. |
Rebasing the existing fork from current master branch proved too tedious for the purpose of this pull request. I need to test that the addition of the Ulimit builder will work with tenzing scripts and shipyard client. If this proves to be successful perhaps I can revisit merging all components of the master branch into this fork, but as this work is blocking another teammate, I want to free them up ASAP.
Adding Ulimit Builder object in HostConfig Builder.
|
+1, i'd like to use CXF and JSONB instead of jackson, using portable API is really important |
We use RESTEasy in most of our applications/tooling and because the docker client currently uses the standard JAXRS client api it's hard to control which implementation gets used and it's impossible to customize the client if Resteasy gets picked. This abstractions allows us to just create RESTEasy clients and then only have 1 JAXRS implementation on our classpath. I've tested it with both Jersey and RESTEasy (not included) implementations and everything seems to work.
I also switched the JerseyClientFactory to directly use the JerseyClientBuilder so that it'll still use Jersey even if there's an alternate JAXRS implementation on the classpath.