You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2025/06/26 11:47:42 UTC

(maven-javadoc-plugin) branch 1207 created (now 19671a68)

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

elharo pushed a change to branch 1207
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git


      at 19671a68 Decouple from wagon proxy classes

This branch includes the following new commits:

     new 19671a68 Decouple from wagon proxy classes

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(maven-javadoc-plugin) 01/01: Decouple from wagon proxy classes

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch 1207
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git

commit 19671a68a521267f4dd970961e4bf19e8fbe3721
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Thu Jun 26 07:47:24 2025 -0400

    Decouple from wagon proxy classes
---
 .../apache/maven/plugins/javadoc/JavadocUtil.java  | 31 +++++++++++++++-------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
index 4b2e0ae7..6303d522 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -96,8 +96,6 @@ import org.apache.maven.shared.invoker.MavenInvocationException;
 import org.apache.maven.shared.invoker.PrintStreamHandler;
 import org.apache.maven.shared.utils.io.DirectoryScanner;
 import org.apache.maven.shared.utils.io.FileUtils;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.proxy.ProxyUtils;
 import org.codehaus.plexus.languages.java.version.JavaVersion;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -1527,20 +1525,17 @@ public class JavadocUtil {
         // Some web servers don't allow the default user-agent sent by httpClient
         builder.setUserAgent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
 
-        // Some server reject requests that do not have an Accept header
+        // Some servers reject requests that do not have an Accept header
         builder.setDefaultHeaders(Collections.singletonList(new BasicHeader(HttpHeaders.ACCEPT, "*/*")));
 
         if (settings != null && settings.getActiveProxy() != null) {
             Proxy activeProxy = settings.getActiveProxy();
-
-            ProxyInfo proxyInfo = new ProxyInfo();
-            proxyInfo.setNonProxyHosts(activeProxy.getNonProxyHosts());
-
+            String nonProxyHosts = activeProxy.getNonProxyHosts();
             String activeProxyHost = activeProxy.getHost();
             if (activeProxyHost != null
                     && !activeProxyHost.isEmpty()
-                    && (url == null || !ProxyUtils.validateNonProxyHosts(proxyInfo, url.getHost()))) {
-                HttpHost proxy = new HttpHost(activeProxy.getHost(), activeProxy.getPort());
+                    && (url == null || !validateNonProxyHosts(nonProxyHosts, url.getHost()))) {
+                HttpHost proxy = new HttpHost(activeProxyHost, activeProxy.getPort());
                 builder.setProxy(proxy);
 
                 String activeProxyUsername = activeProxy.getUsername();
@@ -1559,6 +1554,24 @@ public class JavadocUtil {
         return builder.build();
     }
 
+    private static boolean validateNonProxyHosts(String nonProxyHosts, String targetHost) {
+        if (nonProxyHosts == null) {
+            return false;
+        }
+        if (targetHost == null) {
+            targetHost = "";
+        }
+        StringTokenizer tokenizer = new StringTokenizer(nonProxyHosts, "|");
+        while (tokenizer.hasMoreTokens()) {
+            String pattern = tokenizer.nextToken();
+            pattern = pattern.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*");
+            if (targetHost.matches(pattern)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     static boolean equalsIgnoreCase(String value, String... strings) {
         for (String s : strings) {
             if (s.equalsIgnoreCase(value)) {