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

8292043: Incorrect decoding near EOF for stateful decoders like UTF-16 #9945

Closed
wants to merge 2 commits into from

Conversation

naotoj
Copy link
Member

@naotoj naotoj commented Aug 19, 2022

Fixing incorrect state handling with EOF in StreamDecoder. There's a reset() call to the decoder seeing the EOF before the last decode() operation to handle the state correctly. Removing the call should not affect other cases because reset() is issued down the execution.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8292043: Incorrect decoding near EOF for stateful decoders like UTF-16

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9945/head:pull/9945
$ git checkout pull/9945

Update a local copy of the PR:
$ git checkout pull/9945
$ git pull https://git.openjdk.org/jdk pull/9945/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9945

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9945.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 19, 2022

👋 Welcome back naoto! 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 Pull request is ready for review label Aug 19, 2022
@openjdk
Copy link

openjdk bot commented Aug 19, 2022

@naotoj The following labels will be automatically applied to this pull request:

  • core-libs
  • nio

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

@openjdk openjdk bot added nio nio-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Aug 19, 2022
@mlbridge
Copy link

mlbridge bot commented Aug 19, 2022

Webrevs

@openjdk
Copy link

openjdk bot commented Aug 19, 2022

@naotoj 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:

8292043: Incorrect decoding near EOF for stateful decoders like UTF-16

Reviewed-by: joehw, alanb, lancea

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 72 new commits pushed to the master branch:

  • 79597f1: 8272702: Resolving URI relative path with no / may lead to incorrect toString
  • 7b5f9ed: 8288966: Better handle very spiky promotion in G1
  • 07c7977: 8290249: Vectorize signum on AArch64
  • a3ec0bb: 8253413: [REDO] [REDO] G1 incorrectly limiting young gen size when using the reserve can result in repeated full gcs
  • 27b0f77: 8292318: Memory corruption in remove_dumptime_info
  • 9a65524: 8290300: Use standard String-joining tools where applicable
  • f9004fe: 8292561: Make "ReplayCompiles" a diagnostic product switch
  • 2fbb936: 8292691: Move CompilerConfig::is_xxx() inline functions out of compilerDefinitions.hpp
  • 3601e30: 8290909: MemoryPoolMBean/isUsageThresholdExceeded tests failed with "isUsageThresholdExceeded() returned false, and is still false, while threshold = MMMMMMM and used peak = NNNNNNN"
  • 37c0a13: 8292350: Use static methods for hashCode/toString primitives
  • ... and 62 more: https://git.openjdk.org/jdk/compare/ea2c82e74f5580f396920f9e561cbec80c03f373...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 Pull request is ready to be integrated label Aug 19, 2022
new ByteArrayInputStream(INPUT),
StandardCharsets.UTF_16.newDecoder().onMalformedInput(CodingErrorAction.REPORT))) {
System.out.printf("%04x%n", r.read()); // \u00d8 (wrong, uses UTF-16BE)
System.out.printf("%04x%n", r.read()); // EOF
Copy link
Contributor

Choose a reason for hiding this comment

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

This will pass if either read fails, I think the test should be checking that the first call to read throws MalformedInputException.

Would it be feasible to add a second test where there are characters between the BOM and the truncated high surrogate? It would be possible to decode those characters before it fails at the end of the stream.

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed both points.

Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

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

Thanks for the update, I think the test is much better now.

@naotoj
Copy link
Member Author

naotoj commented Aug 22, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Aug 22, 2022

Going to push as commit aa9b8f0.
Since your change was applied there have been 83 commits pushed to the master branch:

  • f95ee79: 8292566: Add reference to the java.nio.file package in java.nio package documentation
  • 45c3e89: 8292316: Tests should not rely on specific JAR file names (jpackage)
  • db77227: 8282684: Obsolete UseContainerCpuShares and PreferContainerQuotaForCPUCount flags
  • 256b523: 8292381: java/net/httpclient/SpecialHeadersTest.java fails with "ERROR: Shutting down connection: HTTP/2 client stopped"
  • e561933: 8292623: Reduce runtime of java.io microbenchmarks
  • dcd7802: 8292708: Rename G1ParScanThreadState::flush to flush_stats
  • 16593cf: 8292717: Clean up checking of testing requirements in configure
  • c59f9b3: 8287828: Fix so that one can select jtreg test case by ID from make
  • 476c484: 8292656: G1: Remove G1HotCardCache::_use_cache
  • a17fce7: 6445283: ProgressMonitorInputStream not large file aware (>2GB)
  • ... and 73 more: https://git.openjdk.org/jdk/compare/ea2c82e74f5580f396920f9e561cbec80c03f373...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 22, 2022
@openjdk openjdk bot closed this Aug 22, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 22, 2022
@openjdk
Copy link

openjdk bot commented Aug 22, 2022

@naotoj Pushed as commit aa9b8f0.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated nio nio-dev@openjdk.org
4 participants