deserialize ipv6 addresses correctly. patch by Gary Dusbabek, reviewed by Jonathan Ellis. CASSANDRA-969

git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.6@933229 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Dusbabek 2010-04-12 13:34:10 +00:00
parent 4fe2f37ba0
commit c2ea5dfa6a
1 changed files with 5 additions and 3 deletions

View File

@ -24,13 +24,15 @@ import java.net.InetAddress;
public class CompactEndPointSerializationHelper
{
public static void serialize(InetAddress endPoint, DataOutputStream dos) throws IOException
{
dos.write(endPoint.getAddress());
{
byte[] buf = endPoint.getAddress();
dos.writeByte(buf.length);
dos.write(buf);
}
public static InetAddress deserialize(DataInputStream dis) throws IOException
{
byte[] bytes = new byte[4];
byte[] bytes = new byte[dis.readByte()];
dis.readFully(bytes, 0, bytes.length);
return InetAddress.getByAddress(bytes);
}