Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 69891 invoked from network); 24 May 2006 01:34:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 May 2006 01:34:52 -0000 Received: (qmail 46053 invoked by uid 500); 24 May 2006 01:34:45 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 45992 invoked by uid 500); 24 May 2006 01:34:45 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 45981 invoked by uid 99); 24 May 2006 01:34:45 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 May 2006 18:34:45 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of zhanghuangzhu@gmail.com designates 66.249.82.199 as permitted sender) Received: from [66.249.82.199] (HELO wx-out-0102.google.com) (66.249.82.199) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 May 2006 18:34:44 -0700 Received: by wx-out-0102.google.com with SMTP id t16so514854wxc for ; Tue, 23 May 2006 18:34:23 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=O3Qg4IGWcfexUMOQvTtV99YMAhxLcUDnjeCONk0YDVJ3kipK2ah9bsD0wKXJrXHRhymBquxNEUTtd6pYIjoPqM3SW0cL/CXbdoODKOnJkmKbpduNcx/SJU2PbG1rXU+d25lS9vhCGw2gKl5GkCKmuCqtmQRDhpAifLOhbn1fjEE= Received: by 10.70.76.17 with SMTP id y17mr7059794wxa; Tue, 23 May 2006 18:34:23 -0700 (PDT) Received: by 10.70.118.7 with HTTP; Tue, 23 May 2006 18:34:23 -0700 (PDT) Message-ID: <4d0b24970605231834r2446ec89naa7b54f62b731b9d@mail.gmail.com> Date: Wed, 24 May 2006 09:34:23 +0800 From: "Andrew Zhang" To: harmony-dev@incubator.apache.org Subject: Re: [jira] Updated: (HARMONY-491) [classlib] Constructors of java.nio.charset.CharsetEncoder should not throw NPE if charset==null In-Reply-To: <20136963.1148375011074.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_59517_21430611.1148434463102" References: <16039837.1148369609776.JavaMail.jira@brutus> <20136963.1148375011074.JavaMail.jira@brutus> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_59517_21430611.1148434463102 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, Svetlana I took a quick view on your patch, I found your quick fix didn't resolve th= e problem thoroughly. Try to comment following code in your test case, RI fails on the test case but Harmony with your patch passes. public boolean isLegalReplacement(byte[] arg0) { return true; } Here's my suggestion, 1. remove cs.newDecoder() in CharsetEnconder constructor. 2. add following code in isLegalReplacement method: if(null =3D=3D decoder){ decoder =3D cs.newDecoder(); } The following code shows the change in patch format. Would you please have a review? Thanks! Index: nio_char/src/main/java/java/nio/charset/CharsetEncoder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- nio_char/src/main/java/java/nio/charset/CharsetEncoder.java (revision 408852) +++ nio_char/src/main/java/java/nio/charset/CharsetEncoder.java (working copy) @@ -133,7 +133,7 @@ // decoder instance for this encoder's charset, used for replacement valu= e // checking - private CharsetDecoder decoder; + private CharsetDecoder decoder =3D null; /* * --------------------------------------- Constructors @@ -202,7 +202,6 @@ status =3D INIT; malformAction =3D CodingErrorAction.REPORT; unmapAction =3D CodingErrorAction.REPORT; - decoder =3D cs.newDecoder(); replaceWith(replacement); } @@ -722,6 +721,9 @@ * replacement byte array. */ public boolean isLegalReplacement(byte[] repl) { + if(null =3D=3D decoder){ + decoder =3D cs.newDecoder(); + } CodingErrorAction malform =3D decoder.malformedInputAction(); CodingErrorAction unmap =3D decoder.unmappableCharacterAction(); decoder.onMalformedInput(CodingErrorAction.REPORT); On 5/23/06, Svetlana Samoilenko (JIRA) wrote: > > [ http://issues.apache.org/jira/browse/HARMONY-491?page=3Dall ] > > Svetlana Samoilenko updated HARMONY-491: > ---------------------------------------- > > Attachment: CharsetEncoder.txt > > patch and unit test > > > [classlib] Constructors of java.nio.charset.CharsetEncoder should not > throw NPE if charset=3D=3Dnull > > > -------------------------------------------------------------------------= ----------------------- > > > > Key: HARMONY-491 > > URL: http://issues.apache.org/jira/browse/HARMONY-491 > > Project: Harmony > > Type: Bug > > > Components: Classlib > > Reporter: Svetlana Samoilenko > > Priority: Minor > > Attachments: CharsetEncoder.txt > > > > The test listed below will pass on RI but fail on Harmony. > > import java.nio.*; > > import java.nio.charset.*; > > public class test { > > public static void main(String [] args) { > > CharsetEncoder cen=3Dnew CharsetEncoderImpl(null, 1, 1); > > if (cen.charset() =3D=3D null) { > > System.out.println("PASSED"); > > } else > > System.out.println("FAILED"); > > } > > } > > class CharsetEncoderImpl extends CharsetEncoder { > > public CharsetEncoderImpl(Charset arg0, float arg1, float arg2, > byte[] arg3) { > > super(arg0, arg1, arg2, arg3); > > } > > public boolean isLegalReplacement(byte[] arg0) { > > return true; > > } > > public CharsetEncoderImpl(Charset arg0, float arg1, float arg2) { > > super(arg0, arg1, arg2); > > } > > protected CoderResult encodeLoop(CharBuffer arg0, ByteBuffer arg1) = { > > return null; > > } > > } > > -- > This message is automatically generated by JIRA. > - > If you think it was sent incorrectly contact one of the administrators: > http://issues.apache.org/jira/secure/Administrators.jspa > - > For more information on JIRA, see: > http://www.atlassian.com/software/jira > > --=20 Andrew Zhang China Software Development Lab, IBM ------=_Part_59517_21430611.1148434463102--