Hi, Svetlana,
Welcome :)
Samoilenko, Svetlana V wrote:
Hi, Andrew,
I've prepared new patch with your fixes.
Thank you for your suggestion.
Regards,
Svetlana
-----Original Message-----
From: Andrew Zhang [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 24, 2006 8:34 AM
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
Hi, Svetlana
I took a quick view on your patch, I found your quick fix didn't resolve
the
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 == decoder){
decoder = 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
===================================================================
--- 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
value
// checking
- private CharsetDecoder decoder;
+ private CharsetDecoder decoder = null;
/*
* --------------------------------------- Constructors
@@ -202,7 +202,6 @@
status = INIT;
malformAction = CodingErrorAction.REPORT;
unmapAction = CodingErrorAction.REPORT;
- decoder = cs.newDecoder();
replaceWith(replacement);
}
@@ -722,6 +721,9 @@
* replacement byte array.
*/
public boolean isLegalReplacement(byte[] repl) {
+ if(null == decoder){
+ decoder = cs.newDecoder();
+ }
CodingErrorAction malform = decoder.malformedInputAction();
CodingErrorAction unmap = decoder.unmappableCharacterAction();
decoder.onMalformedInput(CodingErrorAction.REPORT);
On 5/23/06, Svetlana Samoilenko (JIRA) <[EMAIL PROTECTED]> wrote:
[ http://issues.apache.org/jira/browse/HARMONY-491?page=all ]
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==null
------------------------------------------------------------------------
------------------------
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=new CharsetEncoderImpl(null, 1, 1);
if (cen.charset() == 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
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]