rithyskun / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

com.google.gson.internal.Streams.AppendableWriter.CurrentWrite does not override toString() #527

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Run this code:

    final Appendable appendable = new org.apache.commons.lang3.text.StrBuilder();
    new Gson().toJson("foo", appendable);
    System.out.println(appendable.toString());

The StrBuilder class is defined by the Apache Commons Lang3 library 
(commons-lang3-3.1.jar).

What is the expected output? What do you see instead?

Expected:
"foo"

Actual:
ccomc

What version of the product are you using? On what operating system?

I am using 2.2.4 on Windows XP Professional x64.

Please provide any additional information below.

The com.google.gson.internal.Streams.AppendableWriter.CurrentWrite class (see 
http://google-gson.googlecode.com/svn/trunk/gson/src/main/java/com/google/gson/i
nternal/Streams.java) implements java.lang.CharSequence, but does not override 
the toString() method. CharSequence.toString() is required to return "a string 
consisting of exactly this sequence of characters", but CurrentWrite.toString() 
does not adhere to this contract.

Original issue reported on code.google.com by schneega...@gmail.com on 5 Jul 2013 at 6:06