Integrated: 8272805: Avoid looking up standard charsets

2021-09-02 Thread Sergey Bylokhov
On Sun, 22 Aug 2021 02:53:44 GMT, Sergey Bylokhov  wrote:

> This is the continuation of JDK-8233884, JDK-8271456, and JDK-8272120.
> 
> In many places standard charsets are looked up via their names, for example:
> absolutePath.getBytes("UTF-8");
> 
> This could be done more efficiently(up to x20 time faster) with use of 
> java.nio.charset.StandardCharsets:
> absolutePath.getBytes(StandardCharsets.UTF_8);
> 
> The later variant also makes the code cleaner, as it is known not to throw 
> UnsupportedEncodingException in contrary to the former variant.
> 
> This change includes:
>  * demo/utils
>  * jdk.xx packages
>  * Some places were missed in the previous changes. I have found it by 
> tracing the calls to the Charset.forName() by executing tier1,2,3 and desktop 
> tests.
> 
> Some performance discussion: https://github.com/openjdk/jdk/pull/5063
> 
> Code excluded in this fix: the Xerces library(should be fixed upstream), 
> J2DBench(should be compatible to 1.4), some code in the network(the change 
> there are not straightforward, will do it later).
> 
> Tested by the tier1/tier2/tier3 tests on Linux/Windows/macOS.

This pull request has now been integrated.

Changeset: 7fff22af
Author:Sergey Bylokhov 
URL:   
https://git.openjdk.java.net/jdk/commit/7fff22afe711c8c04dbf4cf5b4938d40632e4987
Stats: 364 lines in 53 files changed: 98 ins; 128 del; 138 mod

8272805: Avoid looking up standard charsets

Reviewed-by: weijun, naoto, dfuchs, azvegint, erikj

-

PR: https://git.openjdk.java.net/jdk/pull/5210


RFR: JDK-8273142 : Remove dependancy of TestHttpServer, HttpTransaction, HttpCallback from open/test/jdk/sun/net/www/protocol/http/ tests

2021-09-02 Thread Mahendra Chhipa
Dependencies of TestHttpServre, HttpTransaction, HttpCallback are removed from 
following tests:
open/test/jdk/sun/net/www/protocol/http/ResponseCacheStream.java
open/test/jdk/sun/net/www/protocol/http/SetChunkedStreamingMode.java
open/test/jdk/sun/net/www/protocol/http/RelativeRedirect.java
open/test/jdk/sun/net/www/protocol/http/B6296310.java

-

Commit messages:
 - JDK-8273142 : Remove dependancy of TestHttpServer, HttpTransaction, 
HttpCallback from open/test/jdk/sun/net/www/protocol/http/ tests

Changes: https://git.openjdk.java.net/jdk/pull/5352/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5352&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8273142
  Stats: 181 lines in 4 files changed: 79 ins; 25 del; 77 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5352.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5352/head:pull/5352

PR: https://git.openjdk.java.net/jdk/pull/5352


Re: RFR: 8273261: Replace 'while' cycles with iterator with enhanced-for in java.base

2021-09-02 Thread Iris Clark
On Wed, 1 Sep 2021 07:37:53 GMT, Andrey Turbanov 
 wrote:

> There are few places in code where manual while loop is used with Iterator to 
> iterate over Collection.
> Instead of manual while cycles it's preferred to use enhanced-for cycle 
> instead: it's less verbose, makes code easier to read and it's less 
> error-prone.
> It doesn't have any performance impact: java compiler generates similar code 
> when compiling enhanced-for cycle.
> 
> Similar cleanups:
> * https://bugs.openjdk.java.net/browse/JDK-8258006
> * https://bugs.openjdk.java.net/browse/JDK-8257912

Marked as reviewed by iris (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/5328


Re: RFR: 8263364: sun/net/www/http/KeepAliveStream/KeepAliveStreamCloseWithWrongContentLength.java wedged in getInputStream [v5]

2021-09-02 Thread Daniel Fuchs
On Wed, 7 Jul 2021 12:55:32 GMT, Ivan Šipka  wrote:

>> @dfuch  could you please review, thank you.
>
> Ivan Šipka has updated the pull request with a new target base due to a merge 
> or a rebase. The pull request now contains seven commits:
> 
>  - 8263364: output
>  - 8263364: removing surplus imports
>  - 8263364: refactor
>  - 8263364: refactor
>  - 8263364: refactor
>  - 8263364: fixed headers
>  - JDK-8263364: initial commit

Ah - I see that there are still problems with this test:


#section:main
--messages:(4/225)--
command: main KeepAliveStreamCloseWithWrongContentLength
reason: User specified action: run main/othervm/timeout=30 
KeepAliveStreamCloseWithWrongContentLength 
Mode: othervm [/othervm specified]
elapsed time (seconds): 0.206
--configuration:(0/0)--
--System.out:(9/153)--
client reads: 49
client reads: 50
client reads: 51
client reads: 52
client reads: 53
client reads: 54
client reads: 55
client reads: 56
client reads: 57
--System.err:(25/1821)--
java.net.SocketException: Connection reset
at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:322)
at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:347)
at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:800)
at java.base/java.net.Socket$SocketInputStream.read(Socket.java:966)
at 
java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:244)
at 
java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
at 
java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:343)
at java.base/sun.net.www.MeteredStream.read(MeteredStream.java:141)
at java.base/java.io.FilterInputStream.read(FilterInputStream.java:132)
at 
java.base/sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3663)
at 
java.base/sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3656)
at 
java.base/sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3644)
at 
KeepAliveStreamCloseWithWrongContentLength.main(KeepAliveStreamCloseWithWrongContentLength.java:144)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at 
com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
at java.base/java.lang.Thread.run(Thread.java:833)

JavaTest Message: Test threw exception: java.net.SocketException: Connection 
reset
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.net.SocketException: Connection reset


That would need to be fixed before integrating.

-

PR: https://git.openjdk.java.net/jdk/pull/4472


Re: RFR: 8238274: (sctp) JDK-7118373 is not fixed for SctpChannel

2021-09-02 Thread Daniel Fuchs
On Fri, 27 Aug 2021 08:37:46 GMT, Masanori Yano  wrote:

> Please review this change to the Unix implementations of 
> sun.nio.ch.sctp.Sctp*ChannelImpl#implCloseSelectableChannel() 
> to be same as SocketChannelImpl at JDK-7118373. (The preClose is missing a 
> check for the ST_KILLED state.)

I have run this change on one of our machines that support SCTP. I did get some 
intermittent failures with the other SCTP tests - they don't seem much stable - 
but the new proposed test was failing all the time. I suspect that using `lsof` 
to figure out whether the file descriptor was closed is not reliable/portable 
enough. I also tried to modify the test to use /othervm - which is probably a 
good idea if you don't want your results to be polluted by whatever other test 
might have run previously in the agent VM - but to no avail: the test was still 
failing 100% of the time.
@masyano could you figure another way to detect whether the file descriptor has 
been released?

-

PR: https://git.openjdk.java.net/jdk/pull/5274


Re: RFR: 8273261: Replace 'while' cycles with iterator with enhanced-for in java.base

2021-09-02 Thread Roger Riggs
On Wed, 1 Sep 2021 07:37:53 GMT, Andrey Turbanov 
 wrote:

> There are few places in code where manual while loop is used with Iterator to 
> iterate over Collection.
> Instead of manual while cycles it's preferred to use enhanced-for cycle 
> instead: it's less verbose, makes code easier to read and it's less 
> error-prone.
> It doesn't have any performance impact: java compiler generates similar code 
> when compiling enhanced-for cycle.
> 
> Similar cleanups:
> * https://bugs.openjdk.java.net/browse/JDK-8258006
> * https://bugs.openjdk.java.net/browse/JDK-8257912

LGTM

For the security related code a second reviewer would be good.

-

Marked as reviewed by rriggs (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/5328


Integrated: 8273243: Fix indentations in java.net.InetAddress methods

2021-09-02 Thread Aleksei Efimov
On Wed, 1 Sep 2021 16:53:50 GMT, Aleksei Efimov  wrote:

> Hi,
> 
> The fix changes indentations in the following `java.net.InetAddress` methods:
> - getAddressesFromNameService
> - getHostFromNameService
> 
> It helps to improve code readability. Can't say the same about 
> `getHostFromNameService` diffs shown in this PR.

This pull request has now been integrated.

Changeset: 0c1b16b7
Author:Aleksei Efimov 
URL:   
https://git.openjdk.java.net/jdk/commit/0c1b16b75a2361431cbf9f4112dcd6049e981a78
Stats: 53 lines in 1 file changed: 9 ins; 11 del; 33 mod

8273243: Fix indentations in java.net.InetAddress methods

Reviewed-by: dfuchs, bpb

-

PR: https://git.openjdk.java.net/jdk/pull/5336


Re: RFR: 8273261: Replace 'while' cycles with iterator with enhanced-for in java.base

2021-09-02 Thread Daniel Fuchs
On Wed, 1 Sep 2021 07:37:53 GMT, Andrey Turbanov 
 wrote:

> There are few places in code where manual while loop is used with Iterator to 
> iterate over Collection.
> Instead of manual while cycles it's preferred to use enhanced-for cycle 
> instead: it's less verbose, makes code easier to read and it's less 
> error-prone.
> It doesn't have any performance impact: java compiler generates similar code 
> when compiling enhanced-for cycle.
> 
> Similar cleanups:
> * https://bugs.openjdk.java.net/browse/JDK-8258006
> * https://bugs.openjdk.java.net/browse/JDK-8257912

Generally this looks like a good improvement as the resulting code becomes more 
readable.
Changes in sun/net or jar index classes look fine. Please obtain approval from 
maintainers of the other areas before integrating.

-

Marked as reviewed by dfuchs (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/5328


Re: RFR: 8273243: Fix indentations in java.net.InetAddress methods [v2]

2021-09-02 Thread Daniel Fuchs
On Wed, 1 Sep 2021 23:11:53 GMT, Aleksei Efimov  wrote:

>> Hi,
>> 
>> The fix changes indentations in the following `java.net.InetAddress` methods:
>> - getAddressesFromNameService
>> - getHostFromNameService
>> 
>> It helps to improve code readability. Can't say the same about 
>> `getHostFromNameService` diffs shown in this PR.
>
> Aleksei Efimov has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   8273243: looks -> looks like

Marked as reviewed by dfuchs (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/5336


Re: RFR: 8273261: Replace 'while' cycles with iterator with enhanced-for in java.base

2021-09-02 Thread Andrey Turbanov
On Wed, 1 Sep 2021 07:37:53 GMT, Andrey Turbanov 
 wrote:

> There are few places in code where manual while loop is used with Iterator to 
> iterate over Collection.
> Instead of manual while cycles it's preferred to use enhanced-for cycle 
> instead: it's less verbose, makes code easier to read and it's less 
> error-prone.
> It doesn't have any performance impact: java compiler generates similar code 
> when compiling enhanced-for cycle.
> 
> Similar cleanups:
> * https://bugs.openjdk.java.net/browse/JDK-8258006
> * https://bugs.openjdk.java.net/browse/JDK-8257912

Tested "tier2" on linux-x86_64-server-fastdebug Ubuntu 21.04

==
Test summary
==
   TEST  TOTAL  PASS  FAIL ERROR   
>> jtreg:test/jdk:tier2   3772  3771 1 0 <<
   jtreg:test/langtools:tier2   1111 0 0   
   jtreg:test/jaxp:tier2   452   452 0 0   
==
TEST FAILURE

Only one test `java/nio/file/FileStore/Basic.java` failed, but it fails without 
my changes too.

--System.out:(46/2591)--

-

PR: https://git.openjdk.java.net/jdk/pull/5328


RFR: 8273261: Replace 'while' cycles with iterator with enhanced-for in java.base

2021-09-02 Thread Andrey Turbanov
There are few places in code where manual while loop is used with Iterator to 
iterate over Collection.
Instead of manual while cycles it's preferred to use enhanced-for cycle 
instead: it's less verbose, makes code easier to read and it's less error-prone.
It doesn't have any performance impact: java compiler generates similar code 
when compiling enhanced-for cycle.

Similar cleanups:
* https://bugs.openjdk.java.net/browse/JDK-8258006
* https://bugs.openjdk.java.net/browse/JDK-8257912

-

Commit messages:
 - [PATCH] Replace while cycles with iterator with enhanced-for in java.base

Changes: https://git.openjdk.java.net/jdk/pull/5328/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5328&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8273261
  Stats: 93 lines in 11 files changed: 1 ins; 50 del; 42 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5328.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5328/head:pull/5328

PR: https://git.openjdk.java.net/jdk/pull/5328