You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/02/14 15:47:10 UTC
[commons-compress] branch master updated: Fix thread safety issues when encoding 7z password (#248)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new 6860cf1 Fix thread safety issues when encoding 7z password (#248)
6860cf1 is described below
commit 6860cf108dbaa3c94e8335a8481e6c5d69c65562
Author: Glavo <zj...@gmail.com>
AuthorDate: Mon Feb 14 23:45:40 2022 +0800
Fix thread safety issues when encoding 7z password (#248)
SevenZFile instances are not thread-safe but it is reasonable to be able to create multiple instances from different threads.
---
.../org/apache/commons/compress/archivers/sevenz/SevenZFile.java | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index e463776..1fd6300 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -30,7 +30,6 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.CharBuffer;
import java.nio.channels.SeekableByteChannel;
-import java.nio.charset.CharsetEncoder;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
@@ -2056,13 +2055,11 @@ public class SevenZFile implements Closeable {
return lastSegment + "~";
}
- private static final CharsetEncoder PASSWORD_ENCODER = UTF_16LE.newEncoder();
-
private static byte[] utf16Decode(final char[] chars) throws IOException {
if (chars == null) {
return null;
}
- final ByteBuffer encoded = PASSWORD_ENCODER.encode(CharBuffer.wrap(chars));
+ final ByteBuffer encoded = UTF_16LE.encode(CharBuffer.wrap(chars));
if (encoded.hasArray()) {
return encoded.array();
}