summaryrefslogtreecommitdiff
path: root/java/util/zip/ZipFile.java
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-08-15 14:25:36 +0000
committerRoman Kennke <roman@kennke.org>2006-08-15 14:25:36 +0000
commit47450063df84125a93b4022bac9f7e4aecf8da3c (patch)
tree2bb669475971322be711fa158f6dbcba5986f4df /java/util/zip/ZipFile.java
parentbb650fa7857a762e5a31d54a6f1fc9041b009014 (diff)
downloadclasspath-47450063df84125a93b4022bac9f7e4aecf8da3c.tar.gz
2006-08-15 Roman Kennke <kennke@aicas.com>
* java/util/zip/ZipFile.java (UTF8DECODER): Removed. (UTF8CHARSET): New constant field. Stores the UTF8 charset. (utf8Decoder): New instance field. (decodeChars): Lazily create UTF8 decoder. Use instance field rather than a static field to avoid corruption.
Diffstat (limited to 'java/util/zip/ZipFile.java')
-rw-r--r--java/util/zip/ZipFile.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/java/util/zip/ZipFile.java b/java/util/zip/ZipFile.java
index d52fdc3d1..2bae2eb1f 100644
--- a/java/util/zip/ZipFile.java
+++ b/java/util/zip/ZipFile.java
@@ -520,10 +520,14 @@ public class ZipFile implements ZipConstants
private static final class PartialInputStream extends InputStream
{
/**
- * The UTF-8 decoder use for decoding the filenames.
+ * The UTF-8 charset use for decoding the filenames.
*/
- private static final CharsetDecoder UTF8DECODER =
- Charset.forName("UTF-8").newDecoder();
+ private static final Charset UTF8CHARSET = Charset.forName("UTF-8");
+
+ /**
+ * The actual UTF-8 decoder. Created on demand.
+ */
+ private CharsetDecoder utf8Decoder;
private final RandomAccessFile raf;
private final byte[] buffer;
@@ -734,8 +738,10 @@ public class ZipFile implements ZipConstants
else
{
ByteBuffer bufferBuffer = ByteBuffer.wrap(buffer, pos, length);
- UTF8DECODER.reset();
- char [] characters = UTF8DECODER.decode(bufferBuffer).array();
+ if (utf8Decoder == null)
+ utf8Decoder = UTF8CHARSET.newDecoder();
+ utf8Decoder.reset();
+ char [] characters = utf8Decoder.decode(bufferBuffer).array();
result = String.valueOf(characters);
}
return result;