Skip to content

Commit

Permalink
Issue #4483 - More resiliency on bad DNS servers
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed Jan 16, 2020
1 parent 8c32857 commit b25a587
Showing 1 changed file with 12 additions and 1 deletion.
Expand Up @@ -19,11 +19,13 @@
package org.eclipse.jetty.util;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

import org.eclipse.jetty.toolchain.test.Net;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -113,8 +115,17 @@ public static Stream<String> badsingletons()

@ParameterizedTest
@MethodSource("badsingletons")
public void testBadSingleton(String badAddr)
public void testBadSingleton(final String badAddr)
{
try
{
InetAddress inetAddress = InetAddress.getByName(badAddr);
Assumptions.assumeTrue(inetAddress == null);
}
catch (UnknownHostException ignored)
{
}

//noinspection MismatchedQueryAndUpdateOfCollection
InetAddressSet inetAddressSet = new InetAddressSet();
IllegalArgumentException cause = assertThrows(IllegalArgumentException.class, () -> inetAddressSet.add(badAddr));
Expand Down

0 comments on commit b25a587

Please sign in to comment.