-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.4.2
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Problem found in ByteToCharConverter, non-substitution mode: when the input byte sequence ends despite more bytes are required to complete conversion successfully.
- there's no MalformedInputException thrown from convert(char[] input, int inOff, int inEnd, byte[] output, int outOff, int outEnd); this is the correct behavior since the state is set that more bytes are required for input.
- However, when flush(byte[] output, int outStart, int outEnd) is called, there's no MalformedInputException thrown though the error is identified correctly inside the method. MalformedInputException is not a part of flush method API.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Allocate new byte array for input byte sequence in some character set, for example, Shift_JIS
- Specify the incomplete input byte sequence, for example, 0xf8 in case of Shift_JIS
- Set substitution mode to false
- Call ByteToCharConverter.convert method
- Call ByteToCharConverter.flush method
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
MalformedInputException should be thrown from flush method. This Exception should be a part of ByteToCharConverter.flush(byte[] output, int outStart, int outEnd) API.
Expected API:
public final int flush(char[] output,
int outStart,
int outEnd)
throws IllegalArgumentException,
sun.io.ConversionBufferFullException,
sun.io.MalformedInputException
ACTUAL -
No MalformedInputException thrown from flush method.
Current API:
public final int flush(char[] output,
int outStart,
int outEnd)
throws IllegalArgumentException,
sun.io.ConversionBufferFullException
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
try {
byte[] data = {(byte)0xf8};
char[] targetChars = new char[30];
int charLength;
ByteToCharConverterICU conv = new ByteToCharConverterICU("Shift_JIS");
conv.setSubstitutionMode(false);
charLength = conv.convert(data, 0, data.length, targetChars, 0, targetChars.length);
conv.flush(targetChars, charLength, targetChars.length);
} catch (Exception e){
e.printStackTrace();
}
---------- END SOURCE ----------
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Problem found in ByteToCharConverter, non-substitution mode: when the input byte sequence ends despite more bytes are required to complete conversion successfully.
- there's no MalformedInputException thrown from convert(char[] input, int inOff, int inEnd, byte[] output, int outOff, int outEnd); this is the correct behavior since the state is set that more bytes are required for input.
- However, when flush(byte[] output, int outStart, int outEnd) is called, there's no MalformedInputException thrown though the error is identified correctly inside the method. MalformedInputException is not a part of flush method API.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Allocate new byte array for input byte sequence in some character set, for example, Shift_JIS
- Specify the incomplete input byte sequence, for example, 0xf8 in case of Shift_JIS
- Set substitution mode to false
- Call ByteToCharConverter.convert method
- Call ByteToCharConverter.flush method
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
MalformedInputException should be thrown from flush method. This Exception should be a part of ByteToCharConverter.flush(byte[] output, int outStart, int outEnd) API.
Expected API:
public final int flush(char[] output,
int outStart,
int outEnd)
throws IllegalArgumentException,
sun.io.ConversionBufferFullException,
sun.io.MalformedInputException
ACTUAL -
No MalformedInputException thrown from flush method.
Current API:
public final int flush(char[] output,
int outStart,
int outEnd)
throws IllegalArgumentException,
sun.io.ConversionBufferFullException
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
try {
byte[] data = {(byte)0xf8};
char[] targetChars = new char[30];
int charLength;
ByteToCharConverterICU conv = new ByteToCharConverterICU("Shift_JIS");
conv.setSubstitutionMode(false);
charLength = conv.convert(data, 0, data.length, targetChars, 0, targetChars.length);
conv.flush(targetChars, charLength, targetChars.length);
} catch (Exception e){
e.printStackTrace();
}
---------- END SOURCE ----------