[maven-javadoc-plugin] branch MJAVADOC-532 created (now 3ccb3cc)

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-532 created (now 3ccb3cc)

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

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


      at 3ccb3cc  [MJAVADOC-532] <link> entries that do not redirect are ignored

This branch includes the following new commits:

     new 3ccb3cc  [MJAVADOC-532] <link> entries that do not redirect are ignored

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.


Reply | Threaded
Open this post in threaded view
|

[maven-javadoc-plugin] 01/01: [MJAVADOC-532] <link> entries that do not redirect are ignored

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

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

commit 3ccb3cc719adb0dd46ef214c4802dcc00099d823
Author: Guillaume Boué <[hidden email]>
AuthorDate: Thu Aug 9 19:02:17 2018 +0200

    [MJAVADOC-532] <link> entries that do not redirect are ignored
   
    HttpClientContext#getRedirectLocations() can return null when there are
    no redirects.
---
 .../apache/maven/plugins/javadoc/JavadocUtil.java  |  2 +-
 .../maven/plugins/javadoc/JavadocUtilTest.java     | 41 ++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

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 a740c6e..5881549 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -1654,7 +1654,7 @@ public class JavadocUtil
             }
 
             List<URI> redirects = httpContext.getRedirectLocations();
-            return redirects.isEmpty() ? url : redirects.get( redirects.size() - 1 ).toURL();
+            return isEmpty( redirects ) ? url : redirects.get( redirects.size() - 1 ).toURL();
         }
         finally
         {
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/JavadocUtilTest.java b/src/test/java/org/apache/maven/plugins/javadoc/JavadocUtilTest.java
index ed6ee00..8e9b33f 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocUtilTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocUtilTest.java
@@ -577,6 +577,47 @@ public class JavadocUtilTest
     }
 
     /**
+     * Tests that getRedirectUrl returns the same URL when there are no redirects.
+     */
+    public void testGetRedirectUrlWithNoRedirects()
+        throws Exception
+    {
+        Server server = null;
+        try
+        {
+            server = new Server( 0 );
+            server.addHandler( new AbstractHandler()
+            {
+                @Override
+                public void handle( String target, HttpServletRequest request, HttpServletResponse response,
+                                    int dispatch )
+                    throws IOException, ServletException
+                {
+                    response.setStatus( HttpServletResponse.SC_OK );
+                    ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer( 100 );
+                    writer.write( "<html>Hello world</html>" );
+                    writer.flush();
+                    response.setContentLength( writer.size() );
+                    OutputStream out = response.getOutputStream();
+                    writer.writeTo( out );
+                    out.close();
+                    writer.close();
+                }
+            } );
+            server.start();
+
+            URL url = new URI( "http://localhost:" + server.getConnectors()[0].getLocalPort() ).toURL();
+            URL redirectUrl = JavadocUtil.getRedirectUrl( url, new Settings() );
+
+            assertEquals( url.toURI(), redirectUrl.toURI() );
+        }
+        finally
+        {
+            stopSilently( server );
+        }
+    }
+
+    /**
      * Method to test copyJavadocResources()
      *
      * @throws Exception if any