eclipse-uprotocol / up-java

uProtocol Language Specific Library for Java
Apache License 2.0
9 stars 14 forks source link

The ShortUriSerializer relies on the format produced by InetAddress.toString() #103

Closed sophokles73 closed 6 months ago

sophokles73 commented 6 months ago

The [ShortUriSerializer]() uses InetAddress.toString() to produce the textual representation of the IP address contained in a UAuthority. In doing so, it assumes that the IP address' hostname is empty and thus toString() yields something like /192.168.1.10, i.e. starts with a slash.

While this assumption is correct for the IP addresses used in UAuthority (which contain no hostname), the usage of the toString() method should better be replaced with getHostAddress() which yields only the textual representation of the IP address' bytes and therefore seems better suited for the purpose of serializing the address to short format.