[maven-javadoc-plugin] branch MJAVADOC-516 updated (14c837c -> 29dc4dd)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[maven-javadoc-plugin] branch MJAVADOC-516 updated (14c837c -> 29dc4dd)

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

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


 discard 14c837c  [MJAVADOC-516] Replace usage of deprecated HttpClient code
     add c922342  [MJAVADOC-517] NPE under Java 10 RC Replace JavadocVersion with JavaVersion from plexus-java Extract parts from commons-lang3 SystemUtils, which should not be used anymore; it uses enums for java versions, which means an update is required for every new Java version.
     add 8d0b6d4  updated Modello xsd url
     add b49d947  [MJAVADOC-571] Upgrade plexus-java to 0.9.7
     add e637834  [MJAVADOC-515] - Upgrade parent to 31  o Fixed checkstyle issues related to upgrade.
     add d955df5  [MJAVADOC-519] - IT detectLinks fails on Windows
     add e4a55bb  Upgrade maven-surefire-plugin
     add 7c75ad5  [MJAVADOC-512] - Even when <javadocVersion>1.8.0</javadocVersion> matches there still is a warning.
     add c611330  [MJAVADOC-512] - Even when <javadocVersion>1.8.0</javadocVersion> matches there still is a warning.
     add 84a1e6b  [MNGSITE-332] - Changed download templates of plugins not to reference .md5 anymore
     add 86aa561  Skip Java 10 due to com.sun.tools.doclets removal in Java 10 which causes failing tests, must be fixed later
     add 8e47dca  [MJAVADOC-520] Upgrade dependencies
     add 3df4a85  [MJAVADOC-521] - Added github information.
     add 41a8475  Fix javadoc errors
     add e00b87b  [maven-release-plugin] prepare release maven-javadoc-plugin-3.0.1
     add e7da1a4  [maven-release-plugin] prepare for next development iteration
     add e2e0316  [INFRA-16467] move components documentation out of CMS space
     add 976b8d2  [MJAVADOC-530] - Clean up additionalparam documentation
     add 4e95ecf  Merge pull request #6 from marschall/MJAVADOC-530
     add 65bdf55  Switch to asfMavenTlp set https.protocols for Java 7
     add 5410f11  Fix JenkinsFile
     add dc510d2  Fix unittests which depend on connection with Central :(
     add 3ccb3cc  [MJAVADOC-532] <link> entries that do not redirect are ignored
     add 407343b  [MJAVADOC-533] <link> entries that point to a resource that requires an Accept header may be ignored
     new 29dc4dd  [MJAVADOC-516] Replace usage of deprecated HttpClient code

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (14c837c)
            \
             N -- N -- N   refs/heads/MJAVADOC-516 (29dc4dd)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:
 .gitignore                                         |   1 +
 CONTRIBUTING.md                                    |  91 ++++++
 Jenkinsfile                                        |   2 +-
 README.md                                          |  99 +++++++
 pom.xml                                            |  23 +-
 src/it/projects/detectLinks/pom.xml                |   5 +-
 .../plugins/javadoc/AbstractFixJavadocMojo.java    |  10 +-
 .../maven/plugins/javadoc/AbstractJavadocMojo.java |  68 ++---
 .../maven/plugins/javadoc/JavadocReport.java       |   4 +-
 .../apache/maven/plugins/javadoc/JavadocUtil.java  | 320 ++++++++++-----------
 .../maven/plugins/javadoc/JavadocVersion.java      |   2 +
 .../apache/maven/plugins/javadoc/SystemUtils.java  | 181 ++++++++++++
 .../javadoc/resolver/SourceResolverConfig.java     |   6 +-
 src/main/mdo/javadocOptions.mdo                    |   4 +-
 src/site/apt/examples/alternate-doclet.apt.vm      |  14 +-
 src/site/fml/faq.fml                               |   4 +-
 src/site/xdoc/download.xml.vm                      |   2 +-
 .../maven/plugins/javadoc/FixJavadocMojoTest.java  |  18 +-
 .../maven/plugins/javadoc/JavadocJarTest.java      |  10 +-
 .../maven/plugins/javadoc/JavadocReportTest.java   |  10 +-
 .../maven/plugins/javadoc/JavadocUtilTest.java     |  81 ++++++
 21 files changed, 701 insertions(+), 254 deletions(-)
 create mode 100644 CONTRIBUTING.md
 create mode 100644 README.md
 create mode 100644 src/main/java/org/apache/maven/plugins/javadoc/SystemUtils.java

Reply | Threaded
Open this post in threaded view
|

[maven-javadoc-plugin] 01/01: [MJAVADOC-516] Replace usage of deprecated HttpClient code

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

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

commit 29dc4ddbaec0f15ff31a0e63bbd059fb68be0f93
Author: Guillaume Boué <[hidden email]>
AuthorDate: Fri Mar 2 20:34:47 2018 +0100

    [MJAVADOC-516] Replace usage of deprecated HttpClient code
   
    Instead of creating a mutable DefaultHttpClient, we now use builder
    classes and the new API introduced in 4.3, which deprecates the old one.
    The configuration of the HttpClient stays the same.
   
    Since the new API is guaranteeing a CloseableHttpClient,
    try-with-resources can be used.
---
 .../apache/maven/plugins/javadoc/JavadocUtil.java  | 80 ++++++++--------------
 1 file changed, 30 insertions(+), 50 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 c7467ae..d906713 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -26,16 +26,17 @@ import org.apache.http.HttpStatus;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.Credentials;
 import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.HttpClient;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.params.ClientPNames;
 import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.conn.params.ConnRoutePNames;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.PoolingClientConnectionManager;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.message.BasicHeader;
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.params.CoreProtocolPNames;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.settings.Proxy;
@@ -74,7 +75,6 @@ import java.io.OutputStreamWriter;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Modifier;
-import java.net.SocketTimeoutException;
 import java.net.URI;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -1641,10 +1641,8 @@ public class JavadocUtil
         {
             return url;
         }
-        HttpClient httpClient = null;
-        try
+        try ( CloseableHttpClient httpClient = createHttpClient( settings, url ) )
         {
-            httpClient = createHttpClient( settings, url );
             HttpClientContext httpContext = HttpClientContext.create();
             HttpGet httpMethod = new HttpGet( url.toString() );
             HttpResponse response = httpClient.execute( httpMethod, httpContext );
@@ -1658,13 +1656,6 @@ public class JavadocUtil
             List<URI> redirects = httpContext.getRedirectLocations();
             return isEmpty( redirects ) ? url : redirects.get( redirects.size() - 1 ).toURL();
         }
-        finally
-        {
-            if ( httpClient != null )
-            {
-                httpClient.getConnectionManager().shutdown();
-            }
-        }
     }
 
     /**
@@ -1689,8 +1680,7 @@ public class JavadocUtil
         }
 
         BufferedReader reader = null;
-        HttpGet httpMethod = null;
-        HttpClient httpClient = null;
+        CloseableHttpClient httpClient = null;
 
         try
         {
@@ -1704,17 +1694,8 @@ public class JavadocUtil
                 // http, https...
                 httpClient = createHttpClient( settings, url );
 
-                httpMethod = new HttpGet( url.toString() );
-                HttpResponse response;
-                try
-                {
-                    response = httpClient.execute( httpMethod );
-                }
-                catch ( SocketTimeoutException e )
-                {
-                    // could be a sporadic failure, one more retry before we give up
-                    response = httpClient.execute( httpMethod );
-                }
+                HttpGet httpMethod = new HttpGet( url.toString() );
+                HttpResponse response = httpClient.execute( httpMethod );
 
                 int status = response.getStatusLine().getStatusCode();
                 if ( status != HttpStatus.SC_OK )
@@ -1747,13 +1728,9 @@ public class JavadocUtil
         {
             IOUtil.close( reader );
 
-            if ( httpMethod != null )
-            {
-                httpMethod.releaseConnection();
-            }
             if ( httpClient != null )
             {
-                httpClient.getConnectionManager().shutdown();
+                httpClient.close();
             }
         }
     }
@@ -1807,20 +1784,21 @@ public class JavadocUtil
      * @see #DEFAULT_TIMEOUT
      * @since 2.8
      */
-    private static HttpClient createHttpClient( Settings settings, URL url )
+    private static CloseableHttpClient createHttpClient( Settings settings, URL url )
     {
-        DefaultHttpClient httpClient = new DefaultHttpClient( new PoolingClientConnectionManager() );
-        httpClient.getParams().setIntParameter( CoreConnectionPNames.SO_TIMEOUT, DEFAULT_TIMEOUT );
-        httpClient.getParams().setIntParameter( CoreConnectionPNames.CONNECTION_TIMEOUT, DEFAULT_TIMEOUT );
-        httpClient.getParams().setBooleanParameter( ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true );
-
+        HttpClientBuilder builder = HttpClients.custom();
+        builder.setConnectionManager( new PoolingHttpClientConnectionManager() );
+        builder.setDefaultRequestConfig( RequestConfig.custom()
+                                           .setSocketTimeout( DEFAULT_TIMEOUT )
+                                           .setConnectTimeout( DEFAULT_TIMEOUT )
+                                           .setCircularRedirectsAllowed( true ).build()
+        );
         // Some web servers don't allow the default user-agent sent by httpClient
-        httpClient.getParams().setParameter( CoreProtocolPNames.USER_AGENT,
-                                             "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" );
-
+        builder.setUserAgent( "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" );
         // Some server reject requests that do not have an Accept header
-        httpClient.getParams().setParameter( ClientPNames.DEFAULT_HEADERS,
-                                             Arrays.asList( new BasicHeader( HttpHeaders.ACCEPT, "*/*" ) ) );
+        builder.setDefaultHeaders( Arrays.asList( new BasicHeader( HttpHeaders.ACCEPT, "*/*" ) ) );
+
+        builder.setRetryHandler( new DefaultHttpRequestRetryHandler( 1, false ) );
 
         if ( settings != null && settings.getActiveProxy() != null )
         {
@@ -1833,19 +1811,21 @@ public class JavadocUtil
                 && ( url == null || !ProxyUtils.validateNonProxyHosts( proxyInfo, url.getHost() ) ) )
             {
                 HttpHost proxy = new HttpHost( activeProxy.getHost(), activeProxy.getPort() );
-                httpClient.getParams().setParameter( ConnRoutePNames.DEFAULT_PROXY, proxy );
+                builder.setProxy( proxy );
 
                 if ( StringUtils.isNotEmpty( activeProxy.getUsername() ) && activeProxy.getPassword() != null )
                 {
                     Credentials credentials =
                         new UsernamePasswordCredentials( activeProxy.getUsername(), activeProxy.getPassword() );
 
-                    httpClient.getCredentialsProvider().setCredentials( AuthScope.ANY, credentials );
+                    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+                    credentialsProvider.setCredentials( AuthScope.ANY, credentials );
+                    builder.setDefaultCredentialsProvider( credentialsProvider );
                 }
             }
         }
 
-        return httpClient;
+        return builder.build();
     }
 
     static boolean equalsIgnoreCase( String value, String... strings )