You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Mikhail Markov (JIRA)" <ji...@apache.org> on 2007/01/18 07:41:29 UTC
[jira] Commented: (HARMONY-2467) [classlib][nio charset]
java.nio.charset.CharsetDecoder(cs, Float.MIN_VALUE,Float.MIN_VALUE) does
not throw IllegalArgumentException
[ https://issues.apache.org/jira/browse/HARMONY-2467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12465662 ]
Mikhail Markov commented on HARMONY-2467:
-----------------------------------------
I've experimented with the code to reproduce and found that the same effect takes place if 3-rd parameter (maxCharsPerByte) is less than 1.
So, it seems that RI not allow specifying maxCharsPerByte less than 1 (although the message in IAE is rather strange).
As API spec says that IAE should be thrown "if the preconditions on the parameters do not hold" i think we should follow RI here.
I'll provide the patch soon.
> [classlib][nio charset] java.nio.charset.CharsetDecoder(cs, Float.MIN_VALUE,Float.MIN_VALUE) does not throw IllegalArgumentException
> ------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-2467
> URL: https://issues.apache.org/jira/browse/HARMONY-2467
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Anton Ivanov
> Priority: Minor
>
> According to the specification constructor must throw IllegalArgumentException if the preconditions on the parameters do not hold.
> java.nio.charset.CharsetDecoder(cs, Float.MIN_VALUE,Float.MIN_VALUE) does not throw IllegalArgumentException while RI does with message:
> java.lang.IllegalArgumentException: Replacement too long
> Test to reproduce the problem:
> import junit.framework.TestCase;
> import java.nio.charset.*;
> import java.nio.*;
> public class test10036 extends TestCase {
> public void test1 () {
> try {
> CharsetDecoderImpl obj = new CharsetDecoderImpl(Charset.forName("UTF-8"),
> Float.MIN_VALUE , Float.MIN_VALUE );
> fail("IllegalArgumentException should be thrown");
> } catch (IllegalArgumentException e) {
> //expected
> }
> }
> }
> class CharsetDecoderImpl extends CharsetDecoder{
> public CharsetDecoderImpl(Charset cs, float averageBytesPerChar,
> float maxBytesPerChar){
> super(cs, averageBytesPerChar, maxBytesPerChar);
> }
> public CoderResult decodeLoop(ByteBuffer out, CharBuffer in) {
> return CoderResult.UNDERFLOW;
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira