-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.3.0
-
x86
-
windows_nt
Name: krT82822 Date: 12/05/99
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)
I previously filed this bug, and was told it was a duplicate of bug #4209274,
which was closed as "not a bug".
The described problem first appeared with JDK1.1.7. The task is simple:
1. create a byte array
// fill byte array
for (int i = 0; i < 256; i++)
inputData[i] = (byte)i;
2. this results in the following buffer (what a wonder!)
ZipTest: input data [256 bytes]
0000 00010203 04050607 08090A0B 0C0D0E0F * ............... *
0010 10111213 14151617 18191A1B 1C1D1E1F * ................ *
0020 20212223 24252627 28292A2B 2C2D2E2F * !"#$.&'()*+,-./ *
0030 30313233 34353637 38393A3B 3C3D3E3F * 0123456789:;<=>? *
0040 40414243 44454647 48494A4B 4C4D4E4F * @ABCDEFGHIJKLMNO *
0050 50515253 54555657 58595A5B 5C5D5E5F * PQRSTUVWXYZ[\]^_ *
0060 60616263 64656667 68696A6B 6C6D6E6F * `abcdefghijklmno *
0070 70717273 74757677 78797A7B 7C7D7E7F * pqrstuvwxyz{|}~⌂ *
0080 80818283 84858687 88898A8B 8C8D8E8F * ???????????????? *
0090 90919293 94959697 98999A9B 9C9D9E9F * ???????????????? *
00a0 A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF * ?????????⌐?????? *
00b0 B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF * ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ *
00c0 C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF * └┴┬├─┼╞╟╚╔╩╦╠═╬╧ *
00d0 D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF * ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ *
00e0 E0E1E2E3 E4E5E6E7 E8E9EAEB ECEDEEEF * α?ΓπΣσ?τΦΘΩδ∞φε∩ *
00f0 F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF * ≡?≥≤⌠⌡?≈?∙?√ⁿ?■. *
3. provide zip routine with this byte array
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
byte[]
zip // zip the transmitted buffer
// ----------------------------------------------------------------------- //
(byte[] bBuffer,
int iPosition,
int iLength)
// ----------------------------------------------------------------------- //
{
byte[] bReturn = null;
try
{
// create a byte array output stream to receive the zipped data
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
// create the output stream with the zip stream
BufferedOutputStream out =
new BufferedOutputStream(
new GZIPOutputStream(byteArrayOutputStream));
// write buffer into stream
out.write(bBuffer, iPosition, iLength);
out.close();
// set return value
bReturn = byteArrayOutputStream.toByteArray();
} // try
catch (Exception e)
{
e.printStackTrace();
} // catch
finally
{
// return the compressed byte array
return bReturn;
} // finally
} // zip()
4. this results in the following buffer: (everything still ok!)
ZipTest: buffer after zip [279 bytes]
0000 1F8B0800 00000000 00000100 01FFFE00 * .?. . ..■ *
0010 01020304 05060708 090A0B0C 0D0E0F10 * ................ *
0020 11121314 15161718 191A1B1C 1D1E1F20 * ............... *
0030 21222324 25262728 292A2B2C 2D2E2F30 * !"#$.&'()*+,-./0 *
0040 31323334 35363738 393A3B3C 3D3E3F40 * 123456789:;<=>?@ *
0050 41424344 45464748 494A4B4C 4D4E4F50 * ABCDEFGHIJKLMNOP *
0060 51525354 55565758 595A5B5C 5D5E5F60 * QRSTUVWXYZ[\]^_` *
0070 61626364 65666768 696A6B6C 6D6E6F70 * abcdefghijklmnop *
0080 71727374 75767778 797A7B7C 7D7E7F80 * qrstuvwxyz{|}~⌂? *
0090 81828384 85868788 898A8B8C 8D8E8F90 * ???????????????? *
00a0 91929394 95969798 999A9B9C 9D9E9FA0 * ???????????????? *
00b0 A1A2A3A4 A5A6A7A8 A9AAABAC ADAEAFB0 * ????????⌐??????░ *
00c0 B1B2B3B4 B5B6B7B8 B9BABBBC BDBEBFC0 * ▒▓│┤╡╢╖╕╣║╗╝╜╛┐└ *
00d0 C1C2C3C4 C5C6C7C8 C9CACBCC CDCECFD0 * ┴┬├─┼╞╟╚╔╩╦╠═╬╧╨ *
00e0 D1D2D3D4 D5D6D7D8 D9DADBDC DDDEDFE0 * ╤╥╙╘╒╓╫╪┘┌█▄▌▐▀α *
00f0 E1E2E3E4 E5E6E7E8 E9EAEBEC EDEEEFF0 * ?ΓπΣσ?τΦΘΩδ∞φε∩≡ *
0100 F1F2F3F4 F5F6F7F8 F9FAFBFC FDFEFF73 * ?≥≤⌠⌡?≈?∙?√ⁿ?■.s *
0110 8C052900 010000 * ?.) . *
5. transmit the zip result to an unzip routine
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
byte[]
unZip // unzip the transmitted buffer
// ----------------------------------------------------------------------- //
(byte[] bBuffer,
int iPosition,
int iLength)
// ----------------------------------------------------------------------- //
{
byte[] bReturn = null;
try
{
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream
(bBuffer, iPosition, iLength);
BufferedReader in =
new BufferedReader(
new InputStreamReader(
new GZIPInputStream(byteArrayInputStream)));
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
BufferedOutputStream out =
new BufferedOutputStream(byteArrayOutputStream);
int c;
while (-1 != (c = in.read()))
out.write(c);
in.close();
out.close();
// get the uncompressed byte array
bReturn = byteArrayOutputStream.toByteArray();
} // try
catch (Exception e)
{
e.printStackTrace();
} // catch
finally
{
// return the decompressed byte array
return bReturn;
} // finally
} // unZip()
6. unzipping results in the following buffer (this is no longer ok!)
ZipTest: buffer after unzip [256 bytes]
0000 00010203 04050607 08090A0B 0C0D0E0F * ............... *
0010 10111213 14151617 18191A1B 1C1D1E1F * ................ *
0020 20212223 24252627 28292A2B 2C2D2E2F * !"#$.&'()*+,-./ *
0030 30313233 34353637 38393A3B 3C3D3E3F * 0123456789:;<=>? *
0040 40414243 44454647 48494A4B 4C4D4E4F * @ABCDEFGHIJKLMNO *
0050 50515253 54555657 58595A5B 5C5D5E5F * PQRSTUVWXYZ[\]^_ *
0060 60616263 64656667 68696A6B 6C6D6E6F * `abcdefghijklmno *
0070 70717273 74757677 78797A7B 7C7D7E7F * pqrstuvwxyz{|}~⌂ *
0080 ACFD1A92 1E262021 C6306039 52FD7DFD * ??.?.& !╞0`9R?}? *
0090 FD18191C 1D221314 DC22613A 53FD7E78 * ?...."..▄"a:S?~x *
00a0 A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF * ?????????⌐?????? *
00b0 B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF * ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ *
00c0 C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF * └┴┬├─┼╞╟╚╔╩╦╠═╬╧ *
00d0 D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF * ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ *
00e0 E0E1E2E3 E4E5E6E7 E8E9EAEB ECEDEEEF * α?ΓπΣσ?τΦΘΩδ∞φε∩ *
00f0 F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF * ≡?≥≤⌠⌡?≈?∙?√ⁿ?■. *
As you - at least I hope so!!!! - can see: bytes in the range from 0x80 up to
0x9f are corrupt after unzipping the buffer. So what shall I do with such a
routine??? I'm unzipping EBCDIC datastreams sent from an IBM 3270 host.
Lower case characters 'a' to 'r' ly in the affected range, thus being restored
incorrectly by the unzip routine!
Thank You very much.
I've filed this problem earlier - internal revision ID 95764 (in addition to a
String.getBytes() problem, which leads to similar problems in the affected byte
ranges) - and was told that the filed bug was similar to
the bug ID 4209274 which is already closed, without any solution or workaround.
That's really great! Can imagine how important serious developers using Your
Java environment are to You.
Hava a nice time!
(Review ID: 98472)
======================================================================