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:
2021-01-25 18:32:19 +01:00
parent 8f931f3d16
commit ed2b34add0
2 changed files with 2 additions and 5 deletions

View File

@@ -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) {

View File

@@ -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