forked from I2P_Developers/i2p.i2p
Fix net.i2p.util.Addresses::getIP empty string
The standard library behavior is to return the localhost when null or an empty string is passed. getIP seeked to override that behavior, but didn't treat the empty string case.
This commit is contained in:
@@ -399,7 +399,7 @@ public abstract class Addresses {
|
||||
* @since 0.9.3
|
||||
*/
|
||||
public static byte[] getIP(String host) {
|
||||
if (host == null)
|
||||
if (host == null || host.isEmpty())
|
||||
return null;
|
||||
byte[] rv;
|
||||
synchronized (_IPAddress) {
|
||||
|
||||
@@ -19,10 +19,7 @@ public class AddressesTest {
|
||||
|
||||
@Test
|
||||
public void getIPEmptyString() {
|
||||
byte[] address = {
|
||||
127, 0, 0, 1
|
||||
};
|
||||
assertArrayEquals(address, Addresses.getIP(""));
|
||||
assertNull(Addresses.getIP(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user