United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-8015604 JDP packets containing ideographic characters are broken
JDK-8015604 : JDP packets containing ideographic characters are broken

Details
Type:
Bug
Submit Date:
2013-05-29
Status:
Resolved
Updated Date:
2013-12-17
Project Name:
JDK
Resolved Date:
2013-06-05
Component:
core-svc
OS:
generic
Sub-Component:
javax.management
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
7u40
Fixed Versions:
7u40 (b30)

Related Reports
Backport:
Backport:
Backport:

Sub Tasks

Description
JDP packets with multibyte characters are broken since the code in JdpPacketWriter looks at the String length when adding entries instead of encoding the byte length. I.e. the code looks like this:

    public void addEntry(String entry)
            throws IOException {
        pkt.writeShort(entry.length());
        byte[] b = entry.getBytes("UTF-8");
        pkt.write(b);
    }

It should look like this:
    public void addEntry(String entry)
            throws IOException {
        byte[] b = entry.getBytes("UTF-8");
        pkt.writeShort(b.length);
        pkt.write(b);
    }

Or even more elegantly just like this:
    public void addEntry(String entry)
            throws IOException {
        pkt.writeUTF(entry);
    }
...as it seems that writeUTF in DataOutputStream actually encodes the length in a short in the beginning of the array. 

(This last version is how the JDPServer we use for testing in JMC is coded.)
                                    

Comments
URL:   http://hg.openjdk.java.net/jdk7u/jdk7u-dev/jdk/rev/21bf0e775ea4
User:  dsamersoff
Date:  2013-06-05 13:19:46 +0000

                                     
2013-06-05
URL:   http://hg.openjdk.java.net/jdk7u/jdk7u/jdk/rev/21bf0e775ea4
User:  lana
Date:  2013-06-17 17:00:03 +0000

                                     
2013-06-17



Hardware and Software, Engineered to Work Together