You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Andrew Cornwall (JIRA)" <ji...@apache.org> on 2007/07/12 19:21:04 UTC
[jira] Created: (HARMONY-4447) XMLEncoder.flush() should not always
flush
XMLEncoder.flush() should not always flush
------------------------------------------
Key: HARMONY-4447
URL: https://issues.apache.org/jira/browse/HARMONY-4447
Project: Harmony
Issue Type: Bug
Environment: M2 on Win x86.
Reporter: Andrew Cornwall
Priority: Minor
The flush() method in XMLEncoder doesn't take into account the fact that data may have already been written. Consequently, calling XMLEncoder.flush() may result in the same data being written twice.
Here's a testcase:
import java.beans.XMLEncoder;
import java.io.ByteArrayOutputStream;
public class Bugzilla125927 {
public static void main (String args[]) {
Object object = "hello";
byte[] out = null;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(outputStream);
try{
encoder.writeObject(object);
encoder.flush();
encoder.close();
outputStream.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
System.out.println(new String(outputStream.toByteArray()));
}
}
On the Sun JDK, this results in the following output:
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.5.0_04" class="java.beans.XMLDecoder">
<string>hello</string>
</java>
On Harmony, you get the following:
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-4447) XMLEncoder.flush() should not
always flush
Posted by "Andrew Cornwall (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-4447?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12514718 ]
Andrew Cornwall commented on HARMONY-4447:
------------------------------------------
Verified in build r558789.
> XMLEncoder.flush() should not always flush
> ------------------------------------------
>
> Key: HARMONY-4447
> URL: https://issues.apache.org/jira/browse/HARMONY-4447
> Project: Harmony
> Issue Type: Bug
> Environment: M2 on Win x86.
> Reporter: Andrew Cornwall
> Assignee: Leo Li
> Priority: Minor
>
> The flush() method in XMLEncoder doesn't take into account the fact that data may have already been written. Consequently, calling XMLEncoder.flush() may result in the same data being written twice.
> Here's a testcase:
> import java.beans.XMLEncoder;
> import java.io.ByteArrayOutputStream;
> public class Bugzilla125927 {
> public static void main (String args[]) {
> Object object = "hello";
> byte[] out = null;
> ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
> XMLEncoder encoder = new XMLEncoder(outputStream);
> try{
> encoder.writeObject(object);
> encoder.flush();
> encoder.close();
> outputStream.close();
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
> System.out.println(new String(outputStream.toByteArray()));
> }
> }
> On the Sun JDK, this results in the following output:
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0_04" class="java.beans.XMLDecoder">
> <string>hello</string>
> </java>
> On Harmony, you get the following:
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-4447) XMLEncoder.flush() should not
always flush
Posted by "Leo Li (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-4447?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12514583 ]
Leo Li commented on HARMONY-4447:
---------------------------------
Hi, Andrew
The bug has been fixed on r558643. Please verify if it is fixed as you expect.
Good luck!
Leo.
> XMLEncoder.flush() should not always flush
> ------------------------------------------
>
> Key: HARMONY-4447
> URL: https://issues.apache.org/jira/browse/HARMONY-4447
> Project: Harmony
> Issue Type: Bug
> Environment: M2 on Win x86.
> Reporter: Andrew Cornwall
> Assignee: Leo Li
> Priority: Minor
>
> The flush() method in XMLEncoder doesn't take into account the fact that data may have already been written. Consequently, calling XMLEncoder.flush() may result in the same data being written twice.
> Here's a testcase:
> import java.beans.XMLEncoder;
> import java.io.ByteArrayOutputStream;
> public class Bugzilla125927 {
> public static void main (String args[]) {
> Object object = "hello";
> byte[] out = null;
> ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
> XMLEncoder encoder = new XMLEncoder(outputStream);
> try{
> encoder.writeObject(object);
> encoder.flush();
> encoder.close();
> outputStream.close();
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
> System.out.println(new String(outputStream.toByteArray()));
> }
> }
> On the Sun JDK, this results in the following output:
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0_04" class="java.beans.XMLDecoder">
> <string>hello</string>
> </java>
> On Harmony, you get the following:
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-4447) XMLEncoder.flush() should not always
flush
Posted by "Leo Li (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-4447?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Leo Li updated HARMONY-4447:
----------------------------
Comment: was deleted
> XMLEncoder.flush() should not always flush
> ------------------------------------------
>
> Key: HARMONY-4447
> URL: https://issues.apache.org/jira/browse/HARMONY-4447
> Project: Harmony
> Issue Type: Bug
> Environment: M2 on Win x86.
> Reporter: Andrew Cornwall
> Assignee: Leo Li
> Priority: Minor
>
> The flush() method in XMLEncoder doesn't take into account the fact that data may have already been written. Consequently, calling XMLEncoder.flush() may result in the same data being written twice.
> Here's a testcase:
> import java.beans.XMLEncoder;
> import java.io.ByteArrayOutputStream;
> public class Bugzilla125927 {
> public static void main (String args[]) {
> Object object = "hello";
> byte[] out = null;
> ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
> XMLEncoder encoder = new XMLEncoder(outputStream);
> try{
> encoder.writeObject(object);
> encoder.flush();
> encoder.close();
> outputStream.close();
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
> System.out.println(new String(outputStream.toByteArray()));
> }
> }
> On the Sun JDK, this results in the following output:
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0_04" class="java.beans.XMLDecoder">
> <string>hello</string>
> </java>
> On Harmony, you get the following:
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (HARMONY-4447) XMLEncoder.flush() should not
always flush
Posted by "Leo Li (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-4447?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Leo Li reassigned HARMONY-4447:
-------------------------------
Assignee: Leo Li
> XMLEncoder.flush() should not always flush
> ------------------------------------------
>
> Key: HARMONY-4447
> URL: https://issues.apache.org/jira/browse/HARMONY-4447
> Project: Harmony
> Issue Type: Bug
> Environment: M2 on Win x86.
> Reporter: Andrew Cornwall
> Assignee: Leo Li
> Priority: Minor
>
> The flush() method in XMLEncoder doesn't take into account the fact that data may have already been written. Consequently, calling XMLEncoder.flush() may result in the same data being written twice.
> Here's a testcase:
> import java.beans.XMLEncoder;
> import java.io.ByteArrayOutputStream;
> public class Bugzilla125927 {
> public static void main (String args[]) {
> Object object = "hello";
> byte[] out = null;
> ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
> XMLEncoder encoder = new XMLEncoder(outputStream);
> try{
> encoder.writeObject(object);
> encoder.flush();
> encoder.close();
> outputStream.close();
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
> System.out.println(new String(outputStream.toByteArray()));
> }
> }
> On the Sun JDK, this results in the following output:
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0_04" class="java.beans.XMLDecoder">
> <string>hello</string>
> </java>
> On Harmony, you get the following:
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (HARMONY-4447) XMLEncoder.flush() should not
always flush
Posted by "Leo Li (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-4447?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Leo Li resolved HARMONY-4447.
-----------------------------
Resolution: Fixed
Fixed at r558606.
> XMLEncoder.flush() should not always flush
> ------------------------------------------
>
> Key: HARMONY-4447
> URL: https://issues.apache.org/jira/browse/HARMONY-4447
> Project: Harmony
> Issue Type: Bug
> Environment: M2 on Win x86.
> Reporter: Andrew Cornwall
> Assignee: Leo Li
> Priority: Minor
>
> The flush() method in XMLEncoder doesn't take into account the fact that data may have already been written. Consequently, calling XMLEncoder.flush() may result in the same data being written twice.
> Here's a testcase:
> import java.beans.XMLEncoder;
> import java.io.ByteArrayOutputStream;
> public class Bugzilla125927 {
> public static void main (String args[]) {
> Object object = "hello";
> byte[] out = null;
> ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
> XMLEncoder encoder = new XMLEncoder(outputStream);
> try{
> encoder.writeObject(object);
> encoder.flush();
> encoder.close();
> outputStream.close();
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
> System.out.println(new String(outputStream.toByteArray()));
> }
> }
> On the Sun JDK, this results in the following output:
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0_04" class="java.beans.XMLDecoder">
> <string>hello</string>
> </java>
> On Harmony, you get the following:
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-4447) XMLEncoder.flush() should not
always flush
Posted by "Andrew Cornwall (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-4447?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12512182 ]
Andrew Cornwall commented on HARMONY-4447:
------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.5.0" class="java.beans.XMLDecoder">
<string>hello</string>
</java>
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.5.0" class="java.beans.XMLDecoder">
<string>hello</string>
</java>
A possible fix is to implement a boolean dirty=false, and set it to true when writeObject or writeStatement happens, and false when a flush is done. The writeAll in the flush should only be done if the dirty flag is true.
(I'm not sure if this means you also have to override the parent writeExpression/write methods to update the flag there as well.)
> XMLEncoder.flush() should not always flush
> ------------------------------------------
>
> Key: HARMONY-4447
> URL: https://issues.apache.org/jira/browse/HARMONY-4447
> Project: Harmony
> Issue Type: Bug
> Environment: M2 on Win x86.
> Reporter: Andrew Cornwall
> Priority: Minor
>
> The flush() method in XMLEncoder doesn't take into account the fact that data may have already been written. Consequently, calling XMLEncoder.flush() may result in the same data being written twice.
> Here's a testcase:
> import java.beans.XMLEncoder;
> import java.io.ByteArrayOutputStream;
> public class Bugzilla125927 {
> public static void main (String args[]) {
> Object object = "hello";
> byte[] out = null;
> ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
> XMLEncoder encoder = new XMLEncoder(outputStream);
> try{
> encoder.writeObject(object);
> encoder.flush();
> encoder.close();
> outputStream.close();
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
> System.out.println(new String(outputStream.toByteArray()));
> }
> }
> On the Sun JDK, this results in the following output:
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0_04" class="java.beans.XMLDecoder">
> <string>hello</string>
> </java>
> On Harmony, you get the following:
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.