Skip to content

Conversation

@jankratochvil
Copy link

@jankratochvil jankratochvil commented Jul 8, 2025

Multithreaded handling of ZIP files can throw an exception.

This backport is far from clean. The last commit resolves the conflicts.

The backport would be a little cleaner if there was backported as a pre-requisite JDK-8321156. But given there is a backward compatibility concern I have not backported it.

(jdk25 already contains it), this jdk21, jdk17.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • JDK-8347712 needs maintainer approval
  • JDK-8355975 needs maintainer approval
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issues

  • JDK-8347712: IllegalStateException on multithreaded ZipFile access with non-UTF8 charset (Bug - P3)
  • JDK-8355975: ZipFile uses incorrect Charset if another instance for the same ZIP file was constructed with a different Charset (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk21u-dev.git pull/1949/head:pull/1949
$ git checkout pull/1949

Update a local copy of the PR:
$ git checkout pull/1949
$ git pull https://git.openjdk.org/jdk21u-dev.git pull/1949/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1949

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk21u-dev/pull/1949.diff

Using Webrev

Link to Webrev Comment

jaikiran and others added 2 commits July 8, 2025 14:54
…on-UTF8 charset

8355975: ZipFile uses incorrect Charset if another instance for the same ZIP file was constructed with a different Charset

Co-authored-by: Eirik Bjørsnøs <eirbjo@openjdk.org>
Reviewed-by: eirbjo, lancea, redestad, alanb
@bridgekeeper
Copy link

bridgekeeper bot commented Jul 8, 2025

👋 Welcome back jkratochvil! 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
Copy link

openjdk bot commented Jul 8, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title Backport 2c4e8d211a030c85488e656a9a851d10dd0f9c11 8347712: IllegalStateException on multithreaded ZipFile access with non-UTF8 charset Jul 8, 2025
@openjdk
Copy link

openjdk bot commented Jul 8, 2025

This backport pull request has now been updated with issues from the original commit.

@openjdk openjdk bot added backport Port of a pull request already in a different code base rfr Pull request is ready for review labels Jul 8, 2025
@mlbridge
Copy link

mlbridge bot commented Jul 8, 2025

Webrevs

@openjdk
Copy link

openjdk bot commented Jul 9, 2025

⚠️ @jankratochvil This change is now ready for you to apply for maintainer approval. This can be done directly in each associated issue or by using the /approval command.

@jankratochvil
Copy link
Author

/approval request There is needed a backport for 21u to fix ZIP files handling. It is not a clean backport, last commit resolves the conflicts.

@openjdk
Copy link

openjdk bot commented Jul 9, 2025

@jankratochvil
8347712: The approval request has been created successfully.
8355975: The approval request has been created successfully.

@openjdk openjdk bot added the approval Requires approval; will be removed when approval is received label Jul 9, 2025
@GoeLin
Copy link
Member

GoeLin commented Jul 11, 2025

Hi @jankratochvil
this is a larger change and just fresh in 25. Can we give this some time until January update?

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 8, 2025

@jankratochvil This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@GoeLin
Copy link
Member

GoeLin commented Sep 3, 2025

Hi @jankratochvil
can you please merge head and make sure the tests still pass?
Also please give a fix request message listing reason, risk and testing.

@openjdk openjdk bot removed the approval Requires approval; will be removed when approval is received label Sep 15, 2025
@jerboaa
Copy link
Contributor

jerboaa commented Sep 15, 2025

There is needed a backport for 21u to fix ZIP files handling. It is not a clean backport, last commit resolves the conflicts.

This is an insufficient comment. Not explaining when the issue occurs, how likely it is, what you assess the risk of this change is and how you ensured this doesn't cause regressions when ported 4 releases back. It's a fresh change in JDK 25 to really evaluate its impact. This needs a really convincing argument to warrant the fix be backported.

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 14, 2025

@jankratochvil This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@jankratochvil
Copy link
Author

jankratochvil commented Nov 10, 2025

[edited] a mistaken comment: Besides other mentioned issues this backport is primarily blocked by CSR: https://bugs.openjdk.org/browse/JDK-8367128

@jerboaa
Copy link
Contributor

jerboaa commented Nov 11, 2025

Besides other mentioned issues this backport is primarily blocked by CSR: https://bugs.openjdk.org/browse/JDK-8367128

How is this backport for ZipFile relevant for an ICC_Profile (AWT) CSR or vice versa?

@jankratochvil
Copy link
Author

Besides other mentioned issues this backport is primarily blocked by CSR: https://bugs.openjdk.org/browse/JDK-8367128

How is this backport for ZipFile relevant for an ICC_Profile (AWT) CSR or vice versa?

Sorry my mistake, the CSR was for an unrelated backport.

@jankratochvil
Copy link
Author

The problem does not happen for UTF8 ZIPs as ZipCoder contains its specialization UTF8ZipCoder which is stateless so it can be shared across threads. For non-UTF8 ZIPs:

The problem occured as res.zsrc.zc was using single ZipCoder for one on-disk ZIP file despite each thread had its own instance of ZipFile for that on-disk ZIP file. res.zsrc is ZipFile.Source which contains a cache using single ZipCoder for multiple threads of the same on-disk ZIP file. Now for non-UTF8 ZIPs each ZipFile instance has its new ZipCoder.

For regression risk the change is localized in ZipFile.java, the shared UTF8 ZipCoder is stateless and non-UTF8 ZipCoders are now created for each ZipFile instance. Multithreaded access to ZipFile must be synchronized by its user, not by ZipFile itself. That is documented by:

+ * The {@code ZipCoder} for UTF-8 charset is thread safe, {@code ZipCoder}
+ * for other charsets require external synchronization.

In JDK21 ZipCoder (and its UTF8ZipCoder) is mostly the same as in JDK25.

A customer has reported IllegalStateException on multithreaded ZipFile access with non-UTF8 charset after they migrated their codebase to JDK17. JDK17 backport sure needs JDK21 backport to be done first.

JDK21 vs. JDK25 for src/java.base/share/classes/java/util/zip/ZipCoder.java:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Port of a pull request already in a different code base rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

5 participants