Skip to content
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

8266078: Reader.read(CharBuffer) advances Reader position for read-only Charbuffers #3725

Closed
wants to merge 3 commits into from

Conversation

bplb
Copy link
Member

@bplb bplb commented Apr 27, 2021

Please consider this request to modify Reader.read(CharBuffer) to check whether the buffer is read-only before reading any characters from the character stream. This can happen now if the buffer is read-only. Character are first read thereby advancing the stream before an attempt is made to put them in the CharBuffer thus incorrectly advancing the stream position.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8266078: Reader.read(CharBuffer) advances Reader position for read-only Charbuffers

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3725/head:pull/3725
$ git checkout pull/3725

Update a local copy of the PR:
$ git checkout pull/3725
$ git pull https://git.openjdk.java.net/jdk pull/3725/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3725

View PR using the GUI difftool:
$ git pr show -t 3725

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3725.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Apr 27, 2021

👋 Welcome back bpb! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr label Apr 27, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 27, 2021

@bplb The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs label Apr 27, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Apr 27, 2021

Webrevs

private static void read(Reader r, CharBuffer b) throws IOException {
try {
r.read(b);
throw new RuntimeException();
Copy link
Contributor

@RogerRiggs RogerRiggs Apr 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A helpful message would make it clearer what failed, when/if it fails.

Copy link
Member Author

@bplb bplb Apr 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

src/java.base/share/classes/java/io/Reader.java Outdated Show resolved Hide resolved
@openjdk
Copy link

@openjdk openjdk bot commented Apr 27, 2021

@bplb This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8266078: Reader.read(CharBuffer) advances Reader position for read-only Charbuffers

Reviewed-by: rriggs, alanb, chegar

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 48 new commits pushed to the master branch:

  • f40bf1d: 8266087: Move 'buffer' declaration in get_user_name_slow() inside of linux specific code
  • ec383ab: 8183374: Refactor java/lang/Runtime shell tests to java
  • 343a4a7: 8185127: Add tests to cover hashCode() method for java supported crypto key types
  • e325a75: 8264593: debug.cpp utilities should be available in product builds.
  • e879f8c: 8265587: IGV: track nodes across matching
  • 164454f: 8265867: thread.hpp defines some enums but no reference
  • 75a2354: 8266028: C2 computes -0.0 for Math.pow(-0.0, 0.5)
  • ca37be1: 8197800: Test java/awt/Focus/NonFocusableWindowTest/NoEventsTest.java fails on Windows
  • cf92693: 8198619: java/awt/Focus/FocusTraversalPolicy/ButtonGroupLayoutTraversal/ButtonGroupLayoutTraversalTest.java fails on mac
  • 2201e11: 8266055: ZGC: ZHeap::print_extended_on() doesn't disable deferred delete
  • ... and 38 more: https://git.openjdk.java.net/jdk/compare/1d37b9840a4a7b998abdd70bd1ec49ddb1db4142...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Apr 27, 2021
src/java.base/share/classes/java/io/Reader.java Outdated Show resolved Hide resolved
@bplb
Copy link
Member Author

@bplb bplb commented Apr 29, 2021

/integrate

@openjdk openjdk bot closed this Apr 29, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Apr 29, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 29, 2021

@bplb Since your change was applied there have been 88 commits pushed to the master branch:

  • 2a03739: 8266014: Regression brought by optimization done with JDK-4926314
  • 6bb71d9: 8264762: ByteBuffer.byteOrder(BIG_ENDIAN).asXBuffer.put(Xarray) and ByteBuffer.byteOrder(nativeOrder()).asXBuffer.put(Xarray) are slow
  • f0f6b0d: 8266027: The diamond finder does not find diamond candidates in field initializers
  • 8072ea5: 8238173: jshell - switch statement with a single default not return cause syntax error
  • c76ce28: 8265842: G1: Introduce API to run multiple separate tasks in a single gangtask
  • 294347b: 8265918: java/io/Console/CharsetTest.java failed with "expect: spawn id exp6 not open"
  • 84b52db: 8265666: Enable AIX build platform to make external debug symbols
  • dd8286e: 8198616: java/awt/Focus/6378278/InputVerifierTest.java fails on mac
  • 5574922: 8266284: ProblemList java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java
  • df7f0b4: 8198317: Enhance JavacTool.getTask for flexibility
  • ... and 78 more: https://git.openjdk.java.net/jdk/compare/1d37b9840a4a7b998abdd70bd1ec49ddb1db4142...master

Your commit was automatically rebased without conflicts.

Pushed as commit 5f15666.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@bplb bplb deleted the Reader-ReadOnly-Buffer-8266078 branch Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs integrated
4 participants