mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8260010: UTF8ZipCoder not thread-safe since JDK-8243469
Reviewed-by: lancea
This commit is contained in:
parent
8b95d9549e
commit
1f47de5f6a
1 changed files with 9 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -251,8 +251,14 @@ class ZipCoder {
|
||||||
while (off < end) {
|
while (off < end) {
|
||||||
byte b = a[off];
|
byte b = a[off];
|
||||||
if (b < 0) {
|
if (b < 0) {
|
||||||
// Non-ASCII, fall back to decoder loop
|
// Non-ASCII, fall back to decoding a String
|
||||||
return normalizedHashDecode(h, a, off, end);
|
// We avoid using decoder() here since the UTF8ZipCoder is
|
||||||
|
// shared and that decoder is not thread safe.
|
||||||
|
// We also avoid the JLA.newStringUTF8NoRepl variant at
|
||||||
|
// this point to avoid throwing exceptions eagerly when
|
||||||
|
// opening ZipFiles (exceptions are expected when accessing
|
||||||
|
// malformed entries.)
|
||||||
|
return normalizedHash(new String(a, end - len, len, UTF_8.INSTANCE));
|
||||||
} else {
|
} else {
|
||||||
h = 31 * h + b;
|
h = 31 * h + b;
|
||||||
off++;
|
off++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue