Skip to content

Commit bff9c47

Browse files
joegallook2c
authored andcommitted
Fix PublicSuffixMatcherLoader#getDefault (#621)
1 parent b7ece75 commit bff9c47

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcherLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
@Contract(threading = ThreadingBehavior.SAFE)
5252
public final class PublicSuffixMatcherLoader {
5353

54-
private static final String PUBLIC_SUFFIX_LIST = "org/publicsuffix/list/effective_tld_names.dat";
54+
private static final String PUBLIC_SUFFIX_LIST = "/org/publicsuffix/list/effective_tld_names.dat";
5555

5656
private static final Logger LOG = LoggerFactory.getLogger(PublicSuffixMatcherLoader.class);
5757

httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
import java.io.InputStream;
3131
import java.io.InputStreamReader;
32-
import java.net.URL;
3332
import java.nio.charset.StandardCharsets;
3433
import java.util.List;
3534

@@ -40,7 +39,6 @@
4039
class TestPublicSuffixMatcher {
4140

4241
private static final String SOURCE_FILE = "suffixlistmatcher.txt";
43-
private static final String PUBLIC_SUFFIX_LIST_FILE = "org/publicsuffix/list/effective_tld_names.dat";
4442

4543
private PublicSuffixMatcher matcher;
4644
private PublicSuffixMatcher pslMatcher;
@@ -60,9 +58,7 @@ void setUp() throws Exception {
6058
final List<PublicSuffixList> lists = PublicSuffixListParser.INSTANCE.parseByType(new InputStreamReader(in, StandardCharsets.UTF_8));
6159
matcher = new PublicSuffixMatcher(lists);
6260
}
63-
final URL publicSuffixListUrl = classLoader.getResource(PUBLIC_SUFFIX_LIST_FILE);
64-
Assertions.assertNotNull(publicSuffixListUrl, PUBLIC_SUFFIX_LIST_FILE);
65-
pslMatcher = PublicSuffixMatcherLoader.load(publicSuffixListUrl);
61+
pslMatcher = PublicSuffixMatcherLoader.getDefault();
6662
}
6763

6864
@Test

httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcherLoader.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
package org.apache.hc.client5.http.psl;
2929

30+
import static org.junit.jupiter.api.Assertions.assertEquals;
3031
import static org.junit.jupiter.api.Assertions.assertNotNull;
3132

3233
import org.junit.jupiter.api.Test;
@@ -37,7 +38,10 @@
3738
public class TestPublicSuffixMatcherLoader {
3839

3940
@Test
40-
public void testGetDefault() {
41-
assertNotNull(PublicSuffixMatcherLoader.getDefault());
41+
void testGetDefault() {
42+
final PublicSuffixMatcher defaultMatcher = PublicSuffixMatcherLoader.getDefault();
43+
assertNotNull(defaultMatcher);
44+
// check for an expected-to-be-stable entry in the PUBLIC_SUFFIX_LIST
45+
assertEquals("example.net", defaultMatcher.getDomainRoot("example.net", DomainType.ICANN));
4246
}
4347
}

0 commit comments

Comments
 (0)