RFR: 8236859: WebSocket over authenticating proxy fails with NPE

2020-01-13 Thread Daniel Fuchs

Hi,

Please find below a fix for:
8236859: WebSocket over authenticating proxy fails with NPE
https://bugs.openjdk.java.net/browse/JDK-8236859


http://cr.openjdk.java.net/~dfuchs/webrev_8236859/webrev.00/

It happens when we have a TLS tunnel and authentication with the server 
fails: in that case the TLS tunnel is not established. The WS logic 
tries to get the RawChannel to close it (as it should) but the debug 
trace gets in the way and causes a NPE.

If the debug trace is fixed, the NPE occurs later (in connectFlows()).
The solution is to avoid creating the rawChannel for the sole purpose of 
closing the connection. A new method added to RawChannel.Provider 
(internal API) does the trick.


While investigating this issue I stumbled over several other problems:
an assertion was occurring in the HTTP/1.1 connection pool, because
the failed connection was wrongly returned to the pool instead of
being closed. This will be fixed here two.

Then I stumbled on another issue when both the proxy and the server
required credentials: the proxy credentials were not added to the cache
but requested every time because the 407 was followed by a 401, and
that caused 407 to be returned again at the next round trip, causing
the request to eventually fail with "too many retries".
This is now fixed in AuthenticationFilter.

The WebSocketProxyTest.java is now updated to test wss: and to test
both proxy and server authentication in the same request.

best regards,

-- daniel


RFR[8236105]: Behaviors of DatagramSocket/DatagramChannel::socket send methods are not always consistent

2020-01-13 Thread Patrick Concannon

Hi,

Could someone please review my fix and CSR for issue JDK-8236105 
'Behaviors of DatagramSocket/DatagramChannel::socket send methods are 
not always consistent' ?


The behaviour of the send methods for DatagramSocket, MulticastSocket, 
DatagramChannel and DatagramSocketAdaptor are not consistent when given 
a DatagramPacket with invalid details. This fix adds a check to ensure 
that the exceptions thrown by the send method of DatagramSocket and 
MulticastSocket match the exception thrown by DatagramChannel and 
DatagramSocketAdaptor i.e. IllegalArgumentException



bug: https://bugs.openjdk.java.net/browse/JDK-8236105

CSR: https://bugs.openjdk.java.net/browse/JDK-8236940
webrev: http://cr.openjdk.java.net/~pconcannon/8236105/webrevs/webrev.00/


Kind regards,

Patrick


Draft JEP: 8235674: Reimplement the Legacy DatagramSocket API

2020-01-13 Thread Daniel Fuchs

Hi,

For some time now we've been considering replacing the
implementation of DatagramSocket and MulticastSocket with
something more modern, based on NIO, much similar to what
was done for Socket and ServerSocket in JEP 353 [1].

We have been doing some prototyping, and finally got a
draft JEP written:
8235674: Reimplement the Legacy DatagramSocket API [2]

We also have a prototype implementation (work in progress)
in the `JDK-8230211-branch` of the JDK Sandbox:

hg clone http://hg.openjdk.java.net/jdk/sandbox
hg update -r JDK-8230211-branch

The draft JEP explains the motivation and also lists a
couple of alternatives we have considered/prototyped
before reaching the current proposal.
A side effect of this JEP will be to obsolete the
DatagramSocketImpl and DatagramSocketImpl factory - which
we are considering deprecating (either before, after, or
as part of the JEP). Feedback on this JEP before submission
would be very welcome.


best regards,

-- daniel

[1] https://openjdk.java.net/jeps/353
[2] https://bugs.openjdk.java.net/browse/JDK-8235674