Integrated: 8287390: Cleanup Map usage in AuthenticationInfo.requestAuthentication

2022-06-01 Thread Andrey Turbanov
On Sat, 30 Apr 2022 10:17:43 GMT, Andrey Turbanov wrote: > `AuthenticationInfo.requestAuthentication` uses separate `HashMap`'s `get` > +`put` calls. > > https://github.com/openjdk/jdk/blob/176bb23de18d9ab448e77e85a9c965a7c02f2c50/src/java.base/share/classes/sun/net/

Re: RFR: 8287390: Cleanup Map usage in AuthenticationInfo.requestAuthentication [v2]

2022-06-01 Thread Andrey Turbanov
Instead we can use the `HashMap.putIfAbsent` to make code a bit easier to > follow. We know that `requests` can contain only non-null values. Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8287390: Cleanup Map usage in Authentication

Re: RFR: 8287390: Cleanup Map usage in AuthenticationInfo.requestAuthentication [v2]

2022-06-01 Thread Andrey Turbanov
On Wed, 1 Jun 2022 04:08:53 GMT, Jaikiran Pai wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8287390: Cleanup Map usage in AuthenticationInfo.requestAuthentication >> remove ob

RFR: 8287390: Cleanup Map usage in AuthenticationInfo.requestAuthentication

2022-05-26 Thread Andrey Turbanov
`AuthenticationInfo.requestAuthentication` uses separate `HashMap`'s `get` +`put` calls. Thread t, c; c = Thread.currentThread(); if ((t = requests.get(key)) == null) { requests.put (key, c); assert cached == null;

Re: RFR: 8284893: Fix typos in java.base

2022-04-15 Thread Andrey Turbanov
On Thu, 14 Apr 2022 19:07:09 GMT, Magnus Ihse Bursie wrote: > I ran `codespell` on the `src/java.base` directory, and accepted those > changes where it indeed discovered real typos. > > (Due to false positives this can unfortunately not be run automatically) > > The majority of fixes are in c

Integrated: 8284567: Collapse identical catch branches in java.base

2022-04-11 Thread Andrey Turbanov
On Sat, 2 Apr 2022 16:05:06 GMT, Andrey Turbanov wrote: > Let's take advantage of Java 7 language feature - "Catching Multiple > Exception Types". > It simplifies code. Reduces duplication. > Found by IntelliJ IDEA inspection Identical 'catch' branches in

RFR: 8284567: Collapse identical catch branches in java.base

2022-04-07 Thread Andrey Turbanov
Let's take advantage of Java 7 language feature - "Catching Multiple Exception Types". It simplifies code. Reduces duplication. Found by IntelliJ IDEA inspection Identical 'catch' branches in 'try' statement - Commit messages: - Merge remote-tracking branch 'origin/master' into col

Confusing startLock.wait()/finishLock.wait() calls in WindowsSelectorImpl

2022-03-20 Thread Andrey Turbanov
e synchronized void waitForHelperThreads() { ... finishLock.wait(); It seems confusing to me. I would expect that method 'wait()' to be called directly on 'this' too. For StartLock it even allows to mark it as a 'static' nested class (minus one redundant field). Is it intentional to call 'wait()' like this? Andrey Turbanov

Integrated: 8278263: Remove redundant synchronized from URLStreamHandler.openConnection methods

2022-01-31 Thread Andrey Turbanov
On Fri, 12 Nov 2021 19:35:10 GMT, Andrey Turbanov wrote: > All this Handler's are stateless and there is nothing to protect via > synchronization. This pull request has now been integrated. Changeset: c6ed2046 Author:Andrey Turbanov URL: https://git.openjdk.java.net

Integrated: 8277412: Use String.isBlank to simplify code in sun.net.www.protocol.mailto.Handler

2022-01-29 Thread Andrey Turbanov
On Fri, 12 Nov 2021 19:11:36 GMT, Andrey Turbanov wrote: > All this manually written code actually can be replaced with single > String.isBlank() call. > `file` variable is guaranteed to be non-null. This pull request has now been integrated. Changeset: 268880b4 Author: Andrey

Integrated: 8277120: Use Optional.isEmpty instead of !Optional.isPresent in java.net.http

2022-01-21 Thread Andrey Turbanov
On Mon, 18 Oct 2021 07:55:52 GMT, Andrey Turbanov wrote: > I propose to replace usages of !Optional.isPresent() with Optional.isEmpty > method. > It's makes code a bit easier to read. This pull request has now been integrated. Changeset: 47b1c51b Author:Andrey Turbanov URL

Integrated: 8280010: Remove double buffering of InputStream for Properties.load

2022-01-18 Thread Andrey Turbanov
On Mon, 10 Jan 2022 20:46:36 GMT, Andrey Turbanov wrote: > `Properties.load` uses `java.util.Properties.LineReader`. LineReader already > buffers input stream. Hence wrapping InputStream in BufferedInputStream is > redundant. This pull request has now been integrated. Changeset:

Re: RFR: 8280010: Remove double buffering of InputStream for Properties.load

2022-01-14 Thread Andrey Turbanov
On Mon, 10 Jan 2022 20:46:36 GMT, Andrey Turbanov wrote: > `Properties.load` uses `java.util.Properties.LineReader`. LineReader already > buffers input stream. Hence wrapping InputStream in BufferedInputStream is > redundant. Checked. `BufferedInputStream` add a bit of overhead.

RFR: 8280010: Remove double buffering of InputStream for Properties.load

2022-01-14 Thread Andrey Turbanov
`Properties.load` uses `java.util.Properties.LineReader`. LineReader already buffers input stream. Hence wrapping InputStream in BufferedInputStream is redundant. - Commit messages: - [PATCH] Remove double buffering of InputStream for Properties.load - [PATCH] Remove double buffer

Integrated: 8274809: Update java.base classes to use try-with-resources

2022-01-10 Thread Andrey Turbanov
On Tue, 5 Oct 2021 09:36:23 GMT, Andrey Turbanov wrote: > 8274809: Update java.base classes to use try-with-resources This pull request has now been integrated. Changeset: dee447f8 Author: Andrey Turbanov Committer: Daniel Fuchs URL: https://git.openjdk.java.net/jdk/com

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v4]

2021-12-23 Thread Andrey Turbanov
On Fri, 10 Dec 2021 18:18:02 GMT, Andrey Turbanov wrote: >> This is legacy code with probably poor testing coverage. Usually we don't >> print anything on the console directly and unconditionally - except in some >> well identified cases. Ignoring exceptions thrown

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v4]

2021-12-10 Thread Andrey Turbanov
On Thu, 9 Dec 2021 01:25:20 GMT, Bradford Wetmore wrote: >> That's one of the places where I personally would always use the var keyword >> too: it makes the line shorter and the type is already clearly visible in >> the RHS of the assignment, so repeating it on the left hand side does not >>

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v4]

2021-12-10 Thread Andrey Turbanov
On Tue, 7 Dec 2021 14:48:17 GMT, Daniel Fuchs wrote: >Remind me to sponsor this after the fork. fork is done :) - PR: https://git.openjdk.java.net/jdk/pull/5818

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v4]

2021-12-10 Thread Andrey Turbanov
On Tue, 7 Dec 2021 07:59:54 GMT, Alan Bateman wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8274809: Update java.base classes to use try-with-resources >> fix review comments &

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v5]

2021-12-10 Thread Andrey Turbanov
> 8274809: Update java.base classes to use try-with-resources Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8274809: Update java.base classes to use try-with-resources move { to previous line - Changes: -

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v4]

2021-12-07 Thread Andrey Turbanov
On Tue, 7 Dec 2021 11:41:12 GMT, Daniel Fuchs wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8274809: Update java.base classes to use try-with-resources >> fix review comments &

Re: RFR: 8277412: Use String.isBlank to simplify code in sun.net.www.protocol.mailto.Handler

2021-12-07 Thread Andrey Turbanov
On Tue, 7 Dec 2021 08:07:22 GMT, Alan Bateman wrote: >> All this manually written code actually can be replaced with single >> String.isBlank() call. >> `file` variable is guaranteed to be non-null. > > src/java.base/share/classes/sun/net/www/protocol/mailto/Handler.java line 125: > >> 123:

RFR: 8278263: Remove redundant synchronized from URLStreamHandler.openConnection methods

2021-12-04 Thread Andrey Turbanov
All this Handler's are stateless and there is nothing to protect via synchronization. - Commit messages: - [PATCH] Remove redundant synchronized from URLStreamHandler.openConnection methods Changes: https://git.openjdk.java.net/jdk/pull/6373/files Webrev: https://webrevs.openjdk.

Integrated: 8274949: Use String.contains() instead of String.indexOf() in java.base

2021-11-19 Thread Andrey Turbanov
On Fri, 17 Sep 2021 08:56:47 GMT, Andrey Turbanov wrote: > String.contains was introduced in Java 5. > Some code in java.base still uses old approach with `String.indexOf` to check > if String contains specified substring. > I propose to migrate such usages. Makes code shorter a

RFR: 8277412: Use String.isBlank to simplify code in sun.net.www.protocol.mailto.Handler

2021-11-18 Thread Andrey Turbanov
All this manually written code actually can be replaced with single String.isBlank() call. `file` variable is guaranteed to be non-null. - Commit messages: - [PATCH] Use String.isBlank to simplify code Changes: https://git.openjdk.java.net/jdk/pull/6372/files Webrev: https://webre

RFR: 8277120: Use Optional.isEmpty instead of !Optional.isPresent in java.net.http

2021-11-15 Thread Andrey Turbanov
I propose to replace usages of !Optional.isPresent() with Optional.isEmpty method. It's makes code a bit easier to read. - Commit messages: - [PATCH] Use Optional.isEmpty instead of !Optional.isPresent in java.net.http Changes: https://git.openjdk.java.net/jdk/pull/5985/files Webr

Integrated: 8274835: Remove unnecessary castings in java.base

2021-11-12 Thread Andrey Turbanov
On Thu, 9 Sep 2021 20:12:47 GMT, Andrey Turbanov wrote: > Redundant castings make code harder to read. > Found them by IntelliJ IDEA. > I tried to select only casts which are definitely safe to remove. Also didn't > touch primitive types casts. This pull request has no

Re: RFR: 8276348: Use blessed modifier order in java.base

2021-11-02 Thread Andrey Turbanov
On Tue, 2 Nov 2021 16:30:56 GMT, Pavel Rappo wrote: > This PR follows up one of the recent PRs, where I used a non-canonical > modifier order. Since the problem was noticed [^1], why not to address it at > mass? > > As far as I remember, the first mass-canonicalization of modifiers took place

Integrated: 8274879: Replace uses of StringBuffer with StringBuilder within java.base classes

2021-10-27 Thread Andrey Turbanov
On Thu, 9 Sep 2021 06:50:21 GMT, Andrey Turbanov wrote: > StringBuffer is a legacy synchronized class. There are more modern > alternatives which perform better: > 1. Plain String concatenation should be preferred > 2. StringBuilder is a direct replacement to StringBuffer which ge

Integrated: 8275079: Remove unnecessary conversion to String in java.net.http

2021-10-26 Thread Andrey Turbanov
On Sat, 2 Oct 2021 20:05:37 GMT, Andrey Turbanov wrote: > Cleanup unnecessary String.valueOf calls (and similar) when conversion will > happen implicitly anyway This pull request has now been integrated. Changeset: 19f76c21 Author:Andrey Turbanov Committer: Daniel Fuch

Re: RFR: 8274879: Replace uses of StringBuffer with StringBuilder within java.base classes [v2]

2021-10-12 Thread Andrey Turbanov
n [JDK-8264029](https://bugs.openjdk.java.net/browse/JDK-8264029) I > migrated only usages which were automatically detected by IDEA. It turns out > there are more usages which can be migrated. Andrey Turbanov has updated the pull request incrementally with one additional commit since the last re

Re: RFR: 8274879: Replace uses of StringBuffer with StringBuilder within java.base classes [v2]

2021-10-12 Thread Andrey Turbanov
On Tue, 12 Oct 2021 20:33:20 GMT, Naoto Sato wrote: >> reverted changes in this spec. > > Did you modify the PR? I am unable to locate the revert. Oops. Forgot to push - PR: https://git.openjdk.java.net/jdk/pull/5432

Integrated: 8274894: Use Optional.empty() instead of ofNullable(null) in HttpResponse.BodySubscribers.discarding

2021-10-12 Thread Andrey Turbanov
On Wed, 18 Aug 2021 07:55:35 GMT, Andrey Turbanov wrote: > Usage of `Optional.ofNullable` is unnecessary when value is known. If it's > `null` value Optional.empty() should be preferred, as it doesn't perform > redundant `null` check. This pull request has now been int

Re: RFR: 8274879: Replace uses of StringBuffer with StringBuilder within java.base classes

2021-10-11 Thread Andrey Turbanov
On Thu, 7 Oct 2021 16:48:06 GMT, Naoto Sato wrote: >> StringBuffer is a legacy synchronized class. There are more modern >> alternatives which perform better: >> 1. Plain String concatenation should be preferred >> 2. StringBuilder is a direct replacement to StringBuffer which generally >> have

Re: RFR: 8275079: Remove unnecessary conversion to String in java.net.http

2021-10-11 Thread Andrey Turbanov
On Mon, 4 Oct 2021 13:39:00 GMT, Weijun Wang wrote: >> Cleanup unnecessary String.valueOf calls (and similar) when conversion will >> happen implicitly anyway > > src/java.net.http/share/classes/jdk/internal/net/http/Http1AsyncReceiver.java > line 738: > >> 736: if (flowTag != null

RFR: 8275079: Remove unnecessary conversion to String in java.net.http

2021-10-11 Thread Andrey Turbanov
Cleanup unnecessary String.valueOf calls (and similar) when conversion will happen implicitly anyway - Commit messages: - 8275079: Remove unnecessary conversion to String in java.net.http - [PATCH] Remove unnecessary conversion to String Changes: https://git.openjdk.java.net/jdk/p

Re: RFR: 8274949: Use String.contains() instead of String.indexOf() in java.base

2021-10-08 Thread Andrey Turbanov
On Fri, 8 Oct 2021 09:35:25 GMT, Daniel Fuchs wrote: >Did you run tier1, tier2? I did run tier2. (tier1 is automatically checked by GithubActions). No new tests failed. Only _usual_ tests, which always fail on my machine, were failed. - PR: https://git.openjdk.java.net/jdk/pull/55

RFR: 8274949: Use String.contains() instead of String.indexOf() in java.base

2021-10-08 Thread Andrey Turbanov
String.contains was introduced in Java 5. Some code in java.base still uses old approach with `String.indexOf` to check if String contains specified substring. I propose to migrate such usages. Makes code shorter and easier to read. - Commit messages: - [PATCH] Use String.contains()

Integrated: 8273910: Redundant condition and assignment in java.net.URI

2021-10-07 Thread Andrey Turbanov
On Thu, 19 Aug 2021 19:08:59 GMT, Andrey Turbanov wrote: > 1. Assignment `ru.host = child.host;` is duplicated and hence redundant. > 2. Condition `q > p` is always `true`, because it just bellow inverse check > > if (q <= p) > break;

Re: RFR: 8274894: Use Optional.empty() instead of ofNullable(null) in HttpResponse.BodySubscribers.discarding

2021-10-07 Thread Andrey Turbanov
On Wed, 18 Aug 2021 07:55:35 GMT, Andrey Turbanov wrote: > Usage of `Optional.ofNullable` is unnecessary when value is known. If it's > `null` value Optional.empty() should be preferred, as it doesn't perform > redundant `null` check. Not sure if it worth separate issu

RFR: 8274894: Use Optional.empty() instead of ofNullable(null) in HttpResponse.BodySubscribers.discarding

2021-10-07 Thread Andrey Turbanov
Usage of `Optional.ofNullable` is unnecessary when value is known. If it's `null` value Optional.empty() should be preferred, as it doesn't perform redundant `null` check. - Commit messages: - [PATCH] Cleanup Optional usage in HttpResponse.BodySubscribers.discarding Changes: https

RFR: 8274879: Replace uses of StringBuffer with StringBuilder within java.base classes

2021-10-07 Thread Andrey Turbanov
StringBuffer is a legacy synchronized class. There are more modern alternatives which perform better: 1. Plain String concatenation should be preferred 2. StringBuilder is a direct replacement to StringBuffer which generally have better performance In [JDK-8264029](https://bugs.openjdk.java.net/

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v4]

2021-10-06 Thread Andrey Turbanov
On Wed, 6 Oct 2021 16:00:26 GMT, Bradford Wetmore wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8274809: Update java.base classes to use try-with-resources >> fix review co

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v4]

2021-10-06 Thread Andrey Turbanov
> 8274809: Update java.base classes to use try-with-resources Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8274809: Update java.base classes to use try-with-resources fix review comments - Changes: -

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v3]

2021-10-06 Thread Andrey Turbanov
> 8274809: Update java.base classes to use try-with-resources Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8274809: Update java.base classes to use try-with-resources update copyright year - Changes: -

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v3]

2021-10-06 Thread Andrey Turbanov
On Wed, 6 Oct 2021 16:11:25 GMT, Bradford Wetmore wrote: >Files like HttpTimestamper need the copyright dates updated to 2021. Updated - PR: https://git.openjdk.java.net/jdk/pull/5818

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v2]

2021-10-06 Thread Andrey Turbanov
On Wed, 6 Oct 2021 16:20:48 GMT, Pavel Rappo wrote: >> src/java.base/share/classes/sun/security/timestamp/HttpTimestamper.java line >> 127: >> >>> 125: // Receive the reply >>> 126: byte[] replyBuffer = null; >>> 127: try (BufferedInputStream input = new >>> BufferedInp

Re: RFR: 8274809: Update java.base classes to use try-with-resources [v2]

2021-10-06 Thread Andrey Turbanov
> 8274809: Update java.base classes to use try-with-resources Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8274809: Update java.base classes to use try-with-resources fix post-review comment - Changes: -

Re: RFR: 8274809: Update java.base classes to use try-with-resources

2021-10-06 Thread Andrey Turbanov
On Wed, 6 Oct 2021 16:24:03 GMT, Andrey Turbanov wrote: >> src/java.base/share/classes/sun/net/NetProperties.java line 71: >> >>> 69: f = new File(f, "net.properties"); >>> 70: fname = f.getCanonicalPath(); >>&g

Re: RFR: 8274809: Update java.base classes to use try-with-resources

2021-10-06 Thread Andrey Turbanov
On Wed, 6 Oct 2021 16:04:54 GMT, Bradford Wetmore wrote: >> 8274809: Update java.base classes to use try-with-resources > > src/java.base/share/classes/sun/net/NetProperties.java line 71: > >> 69: f = new File(f, "net.properties"); >> 70: fname = f.getCanonicalPath(); >>

RFR: 8274835: Remove unnecessary castings in java.base

2021-10-06 Thread Andrey Turbanov
Redundant castings make code harder to read. Found them by IntelliJ IDEA. I tried to select only casts which are definitely safe to remove. Also didn't touch primitive types casts. - Commit messages: - [PATCH] Remove unnecessary castings in java.base - [PATCH] Remove unnecessary ca

RFR: 8274809: Update java.base classes to use try-with-resources

2021-10-06 Thread Andrey Turbanov
8274809: Update java.base classes to use try-with-resources - Commit messages: - [PATCH] Use try-with-resources to close FileInputStream in java.base Changes: https://git.openjdk.java.net/jdk/pull/5818/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5818&range=00 Issu

Integrated: 8274079: Cleanup unnecessary calls to Throwable.initCause() in java.base module

2021-10-05 Thread Andrey Turbanov
On Thu, 16 Sep 2021 19:03:26 GMT, Andrey Turbanov wrote: > Pass "cause" exception as constructor parameter is shorter and easier to read. This pull request has now been integrated. Changeset: 1459180f Author:Andrey Turbanov Committer: Weijun Wang URL: https://git.ope

Integrated: 8274237: Replace 'for' cycles with iterator with enhanced-for in java.base

2021-09-24 Thread Andrey Turbanov
On Thu, 23 Sep 2021 20:42:48 GMT, Andrey Turbanov wrote: > There are few places in code where manual `for` loop is used with Iterator to > iterate over Collection. > Instead of manual `for` cycles it's preferred to use enhanced-for cycle > instead: it's less verbose, mak

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

2021-09-23 Thread Andrey Turbanov
There are few places in code where manual `for` loop is used with Iterator to iterate over Collection. Instead of manual `for` 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. Sometimes we even don't need cycle at all

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

2021-09-23 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, mak

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

2021-09-23 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, mak

RFR: 8274079: Cleanup unnecessary calls to Throwable.initCause() in java.base module

2021-09-21 Thread Andrey Turbanov
Pass "cause" exception as constructor parameter is shorter and easier to read. - Commit messages: - [PATCH] Cleanup unnecessary calls to Throwable.initCause() in java.base module Changes: https://git.openjdk.java.net/jdk/pull/5551/files Webrev: https://webrevs.openjdk.java.net/?re

RFR: 8273910: Redundant condition and assignment in java.net.URI

2021-09-16 Thread Andrey Turbanov
1. Assignment `ru.host = child.host;` is duplicated and hence redundant. 2. Condition `q > p` is always `true`, because it just bellow inverse check if (q <= p) break; - Commit messages: - [PATCH] Cleanup redundant assignment and condition in URI

Re: RFR: 8245095: Implementation of JEP 408: Simple Web Server

2021-09-14 Thread Andrey Turbanov
On Tue, 14 Sep 2021 08:52:37 GMT, Julia Boes wrote: > This change implements a simple web server that can be run on the > command-line with `java -m jdk.httpserver`. > > This is facilitated by adding an entry point for the `jdk.httpserver` module, > an implementation class whose main method is

Re: RFR: 8245095: Implementation of JEP 408: Simple Web Server

2021-09-14 Thread Andrey Turbanov
On Tue, 14 Sep 2021 08:52:37 GMT, Julia Boes wrote: > This change implements a simple web server that can be run on the > command-line with `java -m jdk.httpserver`. > > This is facilitated by adding an entry point for the `jdk.httpserver` module, > an implementation class whose main method is

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, mak

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: j

Integrated: 8272863: Replace usages of Collections.sort with List.sort call in public java modules

2021-08-26 Thread Andrey Turbanov
On Mon, 23 Aug 2021 21:01:48 GMT, Andrey Turbanov wrote: > Collections.sort is just a wrapper, so it is better to use an instance method > directly. This pull request has now been integrated. Changeset: d732c309 Author:Andrey Turbanov Committer: Sergey Bylokhov URL:

Re: RFR: 8272863: Replace usages of Collections.sort with List.sort call in public java modules [v3]

2021-08-25 Thread Andrey Turbanov
> Collections.sort is just a wrapper, so it is better to use an instance method > directly. Andrey Turbanov has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of

Re: RFR: 8272863: Replace usages of Collections.sort with List.sort call in public java modules [v2]

2021-08-25 Thread Andrey Turbanov
On Wed, 25 Aug 2021 08:29:57 GMT, Daniel Fuchs wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8272863: Replace usages of Collections.sort with List.sort call in public >

Re: RFR: 8272863: Replace usages of Collections.sort with List.sort call in public java modules

2021-08-24 Thread Andrey Turbanov
On Tue, 24 Aug 2021 11:48:46 GMT, Alexander Zvegintsev wrote: > Is there any reason to not touch them along with this fix? Update them too. - PR: https://git.openjdk.java.net/jdk/pull/5229

Re: RFR: 8272863: Replace usages of Collections.sort with List.sort call in public java modules [v2]

2021-08-24 Thread Andrey Turbanov
> Collections.sort is just a wrapper, so it is better to use an instance method > directly. Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8272863: Replace usages of Collections.sort with List.sort call in public java m

RFR: 8272863: Replace usages of Collections.sort with List.sort call in public java modules

2021-08-23 Thread Andrey Turbanov
Collections.sort is just a wrapper, so it is better to use an instance method directly. - Commit messages: - [PATCH] Replace usages of Collections.sort with List.sort call in public java modules Changes: https://git.openjdk.java.net/jdk/pull/5229/files Webrev: https://webrevs.ope

Re: RFR: 8272805: Avoid looking up standard charsets [v2]

2021-08-23 Thread Andrey Turbanov
On Sun, 22 Aug 2021 23:02:06 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 t

Re: RFR: 8272805: Avoid looking up standard charsets

2021-08-22 Thread Andrey Turbanov
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

Redundant Math.min call in Http2ClientImpl#getConnectionWindowSize

2021-08-19 Thread Andrey Turbanov
defaultValue = Math.min(Integer.MAX_VALUE, Math.max(streamWindow, K*K*32)); Call of method Math.min(int, int) is redundant if one of parameters is known to be Integer.MAX_VALUE (or Integer.MIN_VALUE) Andrey Turbanov

Suspicious 'completed' variable in ResponseContent.UnknownLengthBodyParser#accept

2021-08-18 Thread Andrey Turbanov
onally = t; if (!completed) { onComplete.accept(t); } } Variable 'completed' has an initial value 'false' and never assigned again. Then it's checked in the 'catch' section. It seems it should be set to 'true' somewhere. Andrey Turbanov

Integrated: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy

2021-03-16 Thread Andrey Turbanov
On Sun, 20 Dec 2020 17:05:21 GMT, Andrey Turbanov wrote: > 8080272 Refactor I/O stream copying to use > InputStream.transferTo/readAllBytes and Files.copy This pull request has now been integrated. Changeset: 68deb24b Author:Andrey Turbanov Committer: Julia Boes URL:

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v13]

2021-03-15 Thread Andrey Turbanov
> 8080272 Refactor I/O stream copying to use > InputStream.transferTo/readAllBytes and Files.copy Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAl

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v11]

2021-03-07 Thread Andrey Turbanov
On Fri, 19 Feb 2021 15:03:11 GMT, Sean Mullan wrote: >> As I can see only ByteArrayInputStream is actually passed in `InputStream` >> in current JDK code: >> >> PKCS7 pkcs7 = new PKCS7(is.readAllBytes()); >> private static List parsePKCS7(InputStream is) >> certs = parse

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v11]

2021-02-19 Thread Andrey Turbanov
On Thu, 18 Feb 2021 19:21:45 GMT, Sean Mullan wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8080272: Refactor I/O stream copying to use java.io.InputStream.transferTo >>

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-18 Thread Andrey Turbanov
On Thu, 18 Feb 2021 07:35:51 GMT, Jaikiran Pai wrote: >> Yes. Once here and once inside `synchronized` block. >> Reading `volatile` fields cost _something_ on some architectures, so I think >> we could optimize it a bit. > > Hello @turbanoff, the double read is necessary to correctly avoid any r

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy

2021-02-17 Thread Andrey Turbanov
On Tue, 16 Feb 2021 17:20:37 GMT, Julia Boes wrote: >> 8080272 Refactor I/O stream copying to use >> InputStream.transferTo/readAllBytes and Files.copy > > Hi @turbanoff, I'm happy to sponsor but I see two comments by @marschall - > have they been addressed? > https://github.com/openjdk/jdk/pu

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Andrey Turbanov
On Thu, 18 Feb 2021 01:08:30 GMT, Jaikiran Pai wrote: >> src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java line 171: >> >>> 169: >>> 170: public static ExtendedSocketOptions getInstance() { >>> 171: if (instance != null) { >> >> May be it's worth to avoid reading `

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Andrey Turbanov
On Wed, 17 Feb 2021 13:42:57 GMT, Jaikiran Pai wrote: >> Can I please get a review for this change which proposes to fix the issue >> reported in https://bugs.openjdk.java.net/browse/JDK-8260366? >> >> The issue relates to the concurrent classloading of >> `sun.net.ext.ExtendedSocketOptions` a

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v12]

2021-02-16 Thread Andrey Turbanov
> 8080272 Refactor I/O stream copying to use > InputStream.transferTo/readAllBytes and Files.copy Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8080272: Refactor I/O stream copying to use java.io.InputStream.tran

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v9]

2021-02-16 Thread Andrey Turbanov
On Tue, 9 Feb 2021 11:40:09 GMT, Philippe Marschall wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8080272: Refactor I/O stream copying to use java.io.InputStream.transferTo >>

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v9]

2021-02-16 Thread Andrey Turbanov
On Mon, 8 Feb 2021 21:18:44 GMT, Philippe Marschall wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8080272: Refactor I/O stream copying to use java.io.InputStream.transferTo >>

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v11]

2021-02-15 Thread Andrey Turbanov
> 8080272 Refactor I/O stream copying to use > InputStream.transferTo/readAllBytes and Files.copy Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8080272: Refactor I/O stream copying to use java.io.InputStream.tran

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v10]

2021-02-15 Thread Andrey Turbanov
On Mon, 15 Feb 2021 19:23:16 GMT, Alan Bateman wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8080272: Refactor I/O stream copying to use java.io.InputStream.transferTo >> re

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v10]

2021-02-15 Thread Andrey Turbanov
> 8080272 Refactor I/O stream copying to use > InputStream.transferTo/readAllBytes and Files.copy Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8080272: Refactor I/O stream copying to use java.io.InputStream.tran

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v8]

2021-02-13 Thread Andrey Turbanov
On Sat, 13 Feb 2021 10:20:29 GMT, Andrey Turbanov wrote: >> ## tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java >> >> make test >> TEST="jtreg:tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java" >> >> ST

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v8]

2021-02-13 Thread Andrey Turbanov
On Fri, 12 Feb 2021 22:12:29 GMT, Andrey Turbanov wrote: >> ## java/security/AccessController/DoPrivAccompliceTest.java >> >> make test >> TEST="jtreg:java/security/AccessController/DoPrivAccompliceTest.java" >> >> STDOUT: >>

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v8]

2021-02-12 Thread Andrey Turbanov
On Fri, 12 Feb 2021 21:53:13 GMT, Andrey Turbanov wrote: >> ## java/nio/file/Files/CopyAndMove.java >> >> make test TEST="jtreg:java/nio/file/Files/CopyAndMove.java" >> >> STDOUT: >> Seed from RandomFactory = 7045320

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v8]

2021-02-12 Thread Andrey Turbanov
On Fri, 12 Feb 2021 21:32:04 GMT, Andrey Turbanov wrote: >> ## java/net/MulticastSocket/SetLoopbackMode.java >> >> make test >> TEST="jtreg:test/jdk/java/net/MulticastSocket/SetLoopbackMode.java" >> >> >> STDOUT: >>

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v8]

2021-02-12 Thread Andrey Turbanov
On Fri, 12 Feb 2021 21:12:14 GMT, Andrey Turbanov wrote: >> ## java/net/MulticastSocket/MulticastAddresses.java >> >> make test >> TEST="jtreg:test/jdk/java/net/MulticastSocket/MulticastAddresses.java" >> >> STDOUT: >> Test:

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v8]

2021-02-12 Thread Andrey Turbanov
On Fri, 12 Feb 2021 21:06:24 GMT, Andrey Turbanov wrote: >> Then I tried to run tests separately: >> ## java/io/File/GetXSpace.java >> >> >> make test TEST="jtreg:test/jdk/java/io/File/GetXSpace.java" >> >> STDERR: >> jav

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v8]

2021-02-12 Thread Andrey Turbanov
On Mon, 8 Feb 2021 16:39:55 GMT, Julia Boes wrote: >> The other security-related code changes look good to me. > > I've updated the issue summary to better reflect the changes, the PR summary > should be renamed accordingly. > As mentioned earlier, have you run the tests for the affected areas?

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v8]

2021-02-12 Thread Andrey Turbanov
On Fri, 12 Feb 2021 21:03:04 GMT, Andrey Turbanov wrote: >> I've updated the issue summary to better reflect the changes, the PR summary >> should be renamed accordingly. >> As mentioned earlier, have you run the tests for the affected areas? Here's >>

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v8]

2021-02-12 Thread Andrey Turbanov
On Fri, 12 Feb 2021 21:04:54 GMT, Andrey Turbanov wrote: >> I rebased my changes onto master. (commit >> 837bd8930d0a010110f1318b947c036609d3aa33) >> and checked tier2 and tier3. >> What I got: >> >> ==

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v9]

2021-02-08 Thread Andrey Turbanov
> 8080272 Refactor I/O stream copying to use > InputStream.transferTo/readAllBytes and Files.copy Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8080272: Refactor I/O stream copying to use java.io.InputStream.transferTo

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v8]

2021-02-08 Thread Andrey Turbanov
On Mon, 8 Feb 2021 14:38:52 GMT, Weijun Wang wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8080272: Refactor I/O stream copying to use java.io.InputStream.transferTo >> reve

Re: RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v7]

2021-02-08 Thread Andrey Turbanov
On Mon, 8 Feb 2021 16:19:17 GMT, Julia Boes wrote: >> Andrey Turbanov has refreshed the contents of this pull request, and >> previous commits have been removed. The incremental views will show >> differences compared to the previous content of the PR. > > src/jav

Re: RFR: 8080272 Refactor I/O stream copying to use java.io.InputStream.transferTo [v8]

2021-02-08 Thread Andrey Turbanov
On Mon, 8 Feb 2021 14:01:34 GMT, Alan Bateman wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8080272: Refactor I/O stream copying to use java.io.InputStream.transferTo >> reve

  1   2   >