You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2025/03/06 11:33:04 UTC

(httpcomponents-client) branch master updated: Fix PublicSuffixMatcherLoader#getDefault (#621)

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/master by this push:
     new c68724713 Fix PublicSuffixMatcherLoader#getDefault (#621)
c68724713 is described below

commit c68724713ab8e4a41992d230d41f8dfe0a1a7ba5
Author: Joe Gallo <jo...@gmail.com>
AuthorDate: Thu Mar 6 06:32:59 2025 -0500

    Fix PublicSuffixMatcherLoader#getDefault (#621)
---
 .../org/apache/hc/client5/http/psl/PublicSuffixMatcherLoader.java   | 2 +-
 .../org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java     | 6 +-----
 .../apache/hc/client5/http/psl/TestPublicSuffixMatcherLoader.java   | 6 +++++-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcherLoader.java b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcherLoader.java
index ef3abbda4..1c2022890 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcherLoader.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcherLoader.java
@@ -51,7 +51,7 @@
 @Contract(threading = ThreadingBehavior.SAFE)
 public final class PublicSuffixMatcherLoader {
 
-    private static final String PUBLIC_SUFFIX_LIST = "org/publicsuffix/list/effective_tld_names.dat";
+    private static final String PUBLIC_SUFFIX_LIST = "/org/publicsuffix/list/effective_tld_names.dat";
 
     private static final Logger LOG = LoggerFactory.getLogger(PublicSuffixMatcherLoader.class);
 
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java
index c56229d1f..b2709d996 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java
@@ -29,7 +29,6 @@
 
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 
@@ -40,7 +39,6 @@
 class TestPublicSuffixMatcher {
 
     private static final String SOURCE_FILE = "suffixlistmatcher.txt";
-    private static final String PUBLIC_SUFFIX_LIST_FILE = "org/publicsuffix/list/effective_tld_names.dat";
 
     private PublicSuffixMatcher matcher;
     private PublicSuffixMatcher pslMatcher;
@@ -60,9 +58,7 @@ void setUp() throws Exception {
             final List<PublicSuffixList> lists = PublicSuffixListParser.INSTANCE.parseByType(new InputStreamReader(in, StandardCharsets.UTF_8));
             matcher = new PublicSuffixMatcher(lists);
         }
-        final URL publicSuffixListUrl = classLoader.getResource(PUBLIC_SUFFIX_LIST_FILE);
-        Assertions.assertNotNull(publicSuffixListUrl, PUBLIC_SUFFIX_LIST_FILE);
-        pslMatcher = PublicSuffixMatcherLoader.load(publicSuffixListUrl);
+        pslMatcher = PublicSuffixMatcherLoader.getDefault();
     }
 
     @Test
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcherLoader.java b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcherLoader.java
index 566f6e6ea..35cb54896 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcherLoader.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcherLoader.java
@@ -27,6 +27,7 @@
 
 package org.apache.hc.client5.http.psl;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import org.junit.jupiter.api.Test;
@@ -38,7 +39,10 @@ class TestPublicSuffixMatcherLoader {
 
     @Test
     void testGetDefault() {
-        assertNotNull(PublicSuffixMatcherLoader.getDefault());
+        final PublicSuffixMatcher defaultMatcher = PublicSuffixMatcherLoader.getDefault();
+        assertNotNull(defaultMatcher);
+        // check for an expected-to-be-stable entry in the PUBLIC_SUFFIX_LIST
+        assertEquals("example.net", defaultMatcher.getDomainRoot("example.net", DomainType.ICANN));
     }
 
 }