-
Notifications
You must be signed in to change notification settings - Fork 277
deps: replace Jetty with HttpServer #433
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
deps: replace Jetty with HttpServer #433
Conversation
Remove Jetty v8.2 and replace with com.sun.net.httpserver.HttpServer. Jetty has had breaking changes since 8.2 (specifically with version 9.4). This causes with conflicts with newer code using later versions of Jetty. Removing dependency on Jetty resolves this issue. Fixes googleapis#397.
Removing the jetty dependency make this artifact incorrectly named. If you'd like to propose a HttpServer version artifact, we can discuss creating a new artifact like As for #397, it's not a simple as updating the implementation as there may be other dependencies in the ecosystem that updating jetty will break. This is more of a dependency management issue than an implementation issue. |
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.
Agreed that it's a dependency management issue. That's why I suggested it might be easier to remove jetty completely. That this PR manages to do that without changing the public API, so far as I can see, suggests that we don't really need jetty here.
The artifact name is unfortunate, but I don't think it should be a blocker. As written this is a drop in replacement for the existing code.
*Copied from Jetty findFreePort() as referenced by: https://gist.github.com/vorburger/3429822 | ||
*/ | ||
|
||
private int findOpenPort() { |
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.
this could use try with resources
Done.
…On Wed, Feb 19, 2020 at 12:34 PM Elliotte Rusty Harold < ***@***.***> wrote:
***@***.**** approved this pull request.
------------------------------
In
google-oauth-client-jetty/src/main/java/com/google/api/client/extensions/jetty/auth/oauth2/LocalServerReceiver.java
<#433 (comment)>
:
> } catch (Exception e) {
Throwables.propagateIfPossible(e);
throw new IOException(e);
}
- return "https://" + connector.getHost() + ":" + port + callbackPath;
+ return "https://" + this.getHost() + ":" + port + callbackPath;
+ }
+
+ /*
+ *Copied from Jetty findFreePort() as referenced by: https://gist.github.com/vorburger/3429822
+ */
+
+ private int findOpenPort() {
this could use try with resources
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#433?email_source=notifications&email_token=ABVKI2FDHDANR6ZZA2IKVD3RDVUP7A5CNFSM4KXHF632YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCWEOEQQ#pullrequestreview-361292354>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVKI2E4SQJY7QODGHMI77TRDVUP7ANCNFSM4KXHF63Q>
.
--
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Eric H. Raskin
914-765-0500 x120 or *315-338-4461
(direct)*
Professional Advertising Systems Inc.
fax: 914-765-0500 or *315-338-4461 (direct)*
200 Business Park Drive Suite 304
[email protected]
Armonk, NY 10504
http://www.paslists.com
|
server = HttpServer.create(new InetSocketAddress(port != -1 ? port : findOpenPort()), 0); | ||
HttpContext context = server.createContext(callbackPath, new CallbackHandler()); | ||
server.setExecutor(null); | ||
/* |
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.
why is this code commented out?
It should have been removed. It is the Jetty 9.4 code. I left it there
because I wasn't sure which way we are going (updating Jetty or going with
HttpServer). WIll remove it now.
…On Wed, Feb 19, 2020 at 4:49 PM Elliotte Rusty Harold < ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
google-oauth-client-jetty/src/main/java/com/google/api/client/extensions/jetty/auth/oauth2/LocalServerReceiver.java
<#433 (comment)>
:
> @@ -115,28 +133,48 @@ public LocalServerReceiver() {
@OverRide
public String getRedirectUri() throws IOException {
+
+ server = HttpServer.create(new InetSocketAddress(port != -1 ? port : findOpenPort()), 0);
+ HttpContext context = server.createContext(callbackPath, new CallbackHandler());
+ server.setExecutor(null);
+/*
why is this code commented out?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#433?email_source=notifications&email_token=ABVKI2FWKJIY7PD76HDZIYDRDWSN7A5CNFSM4KXHF632YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCWFXYZQ#pullrequestreview-361462886>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVKI2FPMWAUIR3YKA2N2ALRDWSN7ANCNFSM4KXHF63Q>
.
--
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Eric H. Raskin
914-765-0500 x120 or *315-338-4461
(direct)*
Professional Advertising Systems Inc.
fax: 914-765-0500 or *315-338-4461 (direct)*
200 Business Park Drive Suite 304
[email protected]
Armonk, NY 10504
http://www.paslists.com
|
INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/google/http-client/google-http-client-appengine/1.34.2/google-http-client-appengine-1.34.2.jar (18 kB at 901 kB/s) [INFO] There are 1 checkstyle errors. |
} | ||
|
||
/** | ||
* Blocks until the server receives a login result, or the server is stopped | ||
* by {@link #stop()}, to return an authorization code. | ||
* | ||
* @return authorization code if login succeeds; may return {@code null} if the server | ||
* is stopped by {@link #stop()} | ||
* is stopped by {@link #stop()} |
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.
four space indent
* @throws IOException if the server receives an error code (through an HTTP request | ||
* parameter {@code error}) | ||
* parameter {@code error}) |
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.
only four space indent, per google style
} | ||
|
||
/* | ||
*Copied from Jetty findFreePort() as referenced by: https://gist.github.com/vorburger/3429822 |
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.
It might be the Javadoc comment that checkstyle is complaining about; I'm not sure. Try deleting it.
@@ -16,15 +16,19 @@ | |||
|
|||
import com.google.api.client.extensions.java6.auth.oauth2.VerificationCodeReceiver; | |||
import com.google.api.client.util.Throwables; | |||
import com.sun.net.httpserver.*; |
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.
Google style is to never use wildcard imports.
The try statement is line 159 in my file. Checkstyle doesn't allow try with resources? |
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.
I'm not sure why checkstyle is still complaining. I sort of wish we didn't have this as a mandatory check. It all looks fine to me. I'll see if I can find a minute to pull this branch down and figure out what's going on here.
Thank you! I am also searching around to see if anyone else is having this
issue and how they got around it.
…On Thu, Feb 20, 2020 at 9:28 AM Elliotte Rusty Harold < ***@***.***> wrote:
***@***.**** commented on this pull request.
I'm not sure why checkstyle is still complaining. I sort of wish we didn't
have this as a mandatory check. It all looks fine to me. I'll see if I can
find a minute to pull this branch down and figure out what's going on here.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#433?email_source=notifications&email_token=ABVKI2D4J5XCXYX24V4D6BTRD2HQXA5CNFSM4KXHF632YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCWJNJYY#pullrequestreview-361944291>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVKI2GDF663DQ6XS4UJ3YDRD2HQXANCNFSM4KXHF63Q>
.
--
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Eric H. Raskin
914-765-0500 x120 or *315-338-4461
(direct)*
Professional Advertising Systems Inc.
fax: 914-765-0500 or *315-338-4461 (direct)*
200 Business Park Drive Suite 304
[email protected]
Armonk, NY 10504
http://www.paslists.com
|
I also added a Checkstyle plugin to my Intellij editor. It pointed out a
few things, but none of them were the try with resources. I will push the
update, but of course it will fail again.
…On Thu, Feb 20, 2020 at 9:31 AM Eric Raskin ***@***.***> wrote:
Thank you! I am also searching around to see if anyone else is
having this issue and how they got around it.
On Thu, Feb 20, 2020 at 9:28 AM Elliotte Rusty Harold <
***@***.***> wrote:
> ***@***.**** commented on this pull request.
>
> I'm not sure why checkstyle is still complaining. I sort of wish we
> didn't have this as a mandatory check. It all looks fine to me. I'll see if
> I can find a minute to pull this branch down and figure out what's going on
> here.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#433?email_source=notifications&email_token=ABVKI2D4J5XCXYX24V4D6BTRD2HQXA5CNFSM4KXHF632YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCWJNJYY#pullrequestreview-361944291>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABVKI2GDF663DQ6XS4UJ3YDRD2HQXANCNFSM4KXHF63Q>
> .
>
--
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Eric H. Raskin
914-765-0500 x120 or *315-338-4461
(direct)*
Professional Advertising Systems Inc.
fax: 914-765-0500 or *315-338-4461 (direct)*
200 Business Park Drive Suite 304
***@***.***
Armonk, NY 10504
http://www.paslists.com
--
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Eric H. Raskin
914-765-0500 x120 or *315-338-4461
(direct)*
Professional Advertising Systems Inc.
fax: 914-765-0500 or *315-338-4461 (direct)*
200 Business Park Drive Suite 304
[email protected]
Armonk, NY 10504
http://www.paslists.com
|
Running
mvn verify
from the command line might reproduce the error locally.
…On Thu, Feb 20, 2020 at 9:57 AM ericraskin ***@***.***> wrote:
I also added a Checkstyle plugin to my Intellij editor. It pointed out a
few things, but none of them were the try with resources. I will push the
update, but of course it will fail again.
On Thu, Feb 20, 2020 at 9:31 AM Eric Raskin ***@***.***> wrote:
> Thank you! I am also searching around to see if anyone else is
> having this issue and how they got around it.
>
> On Thu, Feb 20, 2020 at 9:28 AM Elliotte Rusty Harold <
> ***@***.***> wrote:
>
>> ***@***.**** commented on this pull request.
>>
>> I'm not sure why checkstyle is still complaining. I sort of wish we
>> didn't have this as a mandatory check. It all looks fine to me. I'll
see if
>> I can find a minute to pull this branch down and figure out what's
going on
>> here.
>>
>> —
>> You are receiving this because you authored the thread.
>> Reply to this email directly, view it on GitHub
>> <
#433?email_source=notifications&email_token=ABVKI2D4J5XCXYX24V4D6BTRD2HQXA5CNFSM4KXHF632YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCWJNJYY#pullrequestreview-361944291
>,
>> or unsubscribe
>> <
https://github.com/notifications/unsubscribe-auth/ABVKI2GDF663DQ6XS4UJ3YDRD2HQXANCNFSM4KXHF63Q
>
>> .
>>
>
>
> --
>
>
>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Eric H. Raskin
> 914-765-0500 x120 or *315-338-4461
> (direct)*
>
> Professional Advertising Systems Inc.
> fax: 914-765-0500 or *315-338-4461 (direct)*
>
> 200 Business Park Drive Suite 304
> ***@***.***
>
> Armonk, NY 10504
> http://www.paslists.com
>
>
--
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Eric H. Raskin
914-765-0500 x120 or *315-338-4461
(direct)*
Professional Advertising Systems Inc.
fax: 914-765-0500 or *315-338-4461 (direct)*
200 Business Park Drive Suite 304
***@***.***
Armonk, NY 10504
http://www.paslists.com
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#433?email_source=notifications&email_token=AAHVP2G2DQG6DSIQNCEWDN3RD2K63A5CNFSM4KXHF632YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMONKGA#issuecomment-589092120>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHVP2HCAI6OVNECUGIZVATRD2K63ANCNFSM4KXHF63Q>
.
--
Elliotte Rusty Harold
[email protected]
|
Remove Jetty v8.2 and replace with com.sun.net.httpserver.HttpServer. Jetty has had breaking changes since 8.2 (specifically with version 9.4). This causes conflicts with newer code using later versions of Jetty. Removing dependency on Jetty resolves this issue.
This replaces previous pull request updating Jetty to 9.4.
Fixes #397.