Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 95513 invoked from network); 30 Mar 2006 08:58:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Mar 2006 08:58:53 -0000 Received: (qmail 1476 invoked by uid 500); 30 Mar 2006 08:58:48 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 1447 invoked by uid 500); 30 Mar 2006 08:58:48 -0000 Mailing-List: contact harmony-commits-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-commits@incubator.apache.org Received: (qmail 1435 invoked by uid 99); 30 Mar 2006 08:58:47 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Mar 2006 00:58:47 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Mar 2006 00:58:47 -0800 Received: from ajax (localhost.localdomain [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 59A7C6ACB0 for ; Thu, 30 Mar 2006 09:58:26 +0100 (BST) Message-ID: <834162551.1143709106355.JavaMail.jira@ajax> Date: Thu, 30 Mar 2006 09:58:26 +0100 (BST) From: "Tim Ellison (JIRA)" To: harmony-commits@incubator.apache.org Subject: [jira] Resolved: (HARMONY-182) java.nio.charset.Charset.encode(in) doesn't use the same cached encoder. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/HARMONY-182?page=all ] Tim Ellison resolved HARMONY-182: --------------------------------- Resolution: Duplicate Duplicate of HARMONY-150 > java.nio.charset.Charset.encode(in) doesn't use the same cached encoder. > ------------------------------------------------------------------------ > > Key: HARMONY-182 > URL: http://issues.apache.org/jira/browse/HARMONY-182 > Project: Harmony > Type: Bug > Reporter: Richard Liang > > As spec says, "An invocation of this method upon a charset cs returns the same result as the expression cs.newEncoder() .onMalformedInput(CodingErrorAction.REPLACE) .onUnmappableCharacter(CodingErrorAction.REPLACE) .decode(bb); except that it is potentially more efficient because it can cache encoders between successive invocations. " > RI always uses the same cached encoder (the same reference) for the charsets with same name. > The following test case pass on RI 5.0, but fail on Harmony. > /* > * test cached encoder > */ > public void testCachedEncoder() throws Exception { > MockCachedCharset cs1 = new MockCachedCharset("CachedCharset", null); > MockCachedCharset cs2 = new MockCachedCharset("CachedCharset", null); > CharBuffer in = CharBuffer.wrap("A"); > cs1.encode(in); > in.flip(); > cs2.encode(in); > } > /* > * Mock Charset for cached encoder test > */ > static class MockCachedCharset extends Charset { > public MockCachedCharset(String canonicalName, String[] aliases) { > super(canonicalName, aliases); > } > public boolean contains(Charset charset) { > return false; > } > public CharsetDecoder newDecoder() { > return new MockCachedDecoder(this); > } > public CharsetEncoder newEncoder() { > return new MockCachedEncoder(this); > } > } > /* > * Mock encoder. Only one caller is permitted. > */ > static class MockCachedEncoder extends CharsetEncoder { > static MockCachedEncoder caller = null; > public MockCachedEncoder(Charset cs) { > super(cs, 1, 10); > } > /* > * Only one caller is permitted. > */ > protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) { > if (null == caller) { > caller = this; > } else { > if (caller != this) { > // Another instance > fail("should use same instance"); > } > } > return CoderResult.UNDERFLOW; > } > } > /* > * Mock decoder. > */ > static class MockCachedDecoder extends CharsetDecoder { > static MockCachedEncoder caller = null; > public MockCachedDecoder(Charset cs) { > super(cs, 1, 10); > } > protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) { > in.position(in.limit()); > return CoderResult.UNDERFLOW; > } > } -- 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