You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2020/03/10 22:22:22 UTC

[maven-wagon] branch WAGON-568 updated (ae49128 -> fbb195f)

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

michaelo pushed a change to branch WAGON-568
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git.


 discard ae49128  [WAGON-568] Fail to deploy on Sonatype OSS since maven 3.5.4
     new fbb195f  [WAGON-568] Fail to deploy on Sonatype OSS since maven 3.5.4

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   (ae49128)
            \
             N -- N -- N   refs/heads/WAGON-568 (fbb195f)

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:
 .../org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java  | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)


[maven-wagon] 01/01: [WAGON-568] Fail to deploy on Sonatype OSS since maven 3.5.4

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

michaelo pushed a commit to branch WAGON-568
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git

commit fbb195fc84c9438ffc9d25691585d1d196673a8a
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Tue Mar 10 22:05:38 2020 +0100

    [WAGON-568] Fail to deploy on Sonatype OSS since maven 3.5.4
    
    Previously we assumed with manual relocation that a request can always
    be replayed (repeated). This caused stream-based resources with a
    provided content length the peer to block for advertised bytes until a
    REQUEST_TIMEOUT (408) is issued.
    
    Now we properly detect non-repeatable streams and abort any redirect in
    such a case. A new test will very a TransferFailedException for this.
    
    See also WAGON-570, WAGON-581 (HTTPCLIENT-2052).
---
 .../apache/maven/wagon/http/HttpWagonTestCase.java | 80 ++++++++++++++++++++--
 .../providers/http/LightweightHttpWagonTest.java   |  4 +-
 .../maven/wagon/providers/http/HttpWagonTest.java  |  5 +-
 .../wagon/providers/webdav/WebDavWagonTest.java    | 10 ++-
 4 files changed, 87 insertions(+), 12 deletions(-)

diff --git a/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java b/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
index 4680416..b747768 100644
--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
+++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
@@ -59,6 +59,7 @@ import org.eclipse.jetty.util.security.Password;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -167,12 +168,12 @@ public abstract class HttpWagonTestCase
     public void testHttpHeaders()
         throws Exception
     {
-        Properties properties = new Properties();
-        properties.setProperty( "User-Agent", "Maven-Wagon/1.0" );
+        Properties headers = new Properties();
+        headers.setProperty( "User-Agent", "Maven-Wagon/1.0" );
 
         StreamingWagon wagon = (StreamingWagon) getWagon();
 
-        setHttpHeaders( wagon, properties );
+        setHttpConfiguration( wagon, headers, new Properties() );
 
         Server server = new Server(  );
         TestHeaderHandler handler = new TestHeaderHandler();
@@ -251,7 +252,7 @@ public abstract class HttpWagonTestCase
         // 1. set User-Agent header via HttpConfiguration
         Properties headers1 = new Properties();
         headers1.setProperty( "User-Agent", "test-user-agent" );
-        setHttpHeaders( wagon, headers1 );
+        setHttpConfiguration( wagon, headers1, new Properties() );
 
         // 2. redundantly set User-Agent header via setHttpHeaders()
         Properties headers2 = new Properties();
@@ -273,7 +274,7 @@ public abstract class HttpWagonTestCase
 
     }
 
-    protected abstract void setHttpHeaders( StreamingWagon wagon, Properties properties );
+    protected abstract void setHttpConfiguration( StreamingWagon wagon, Properties headers, Properties params );
 
     protected ServerConnector addConnector( Server server )
     {
@@ -348,7 +349,7 @@ public abstract class HttpWagonTestCase
             };
 
             server.setHandler( handler );
-            ServerConnector serverConnector = addConnector( server );
+            addConnector( server );
             server.start();
 
             wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
@@ -1167,6 +1168,73 @@ public abstract class HttpWagonTestCase
         }
     }
 
+    public void testRedirectPutFailureNonRepeatableStream()
+            throws Exception
+        {
+            File repositoryDirectory = getRepositoryDirectory();
+            FileUtils.deleteDirectory( repositoryDirectory );
+            repositoryDirectory.mkdirs();
+
+            Server redirectServer = new Server( );
+
+            addConnector( redirectServer );
+
+            RedirectHandler redirectHandler =
+                new RedirectHandler( "See Other", HttpServletResponse.SC_SEE_OTHER, "/redirectRequest/foo",
+                                     null );
+
+            redirectServer.setHandler( redirectHandler );
+
+            redirectServer.start();
+
+            try
+            {
+                StreamingWagon wagon = (StreamingWagon) getWagon();
+
+                Properties params = new Properties();
+                params.put( "http.protocol.expect-continue", "%b,false" );
+                setHttpConfiguration( wagon, new Properties(), params );
+                Repository repository = new Repository( "foo", getRepositoryUrl( redirectServer ) );
+                wagon.connect( repository );
+
+                File sourceFile = new File( repositoryDirectory, "/redirectRequest/foo/test-secured-put-resource" );
+                sourceFile.delete();
+                assertFalse( sourceFile.exists() );
+
+                File tempFile = File.createTempFile( "wagon", "tmp" );
+                tempFile.deleteOnExit();
+                String content = "put top secret";
+                FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
+
+                try ( FileInputStream fileInputStream = new FileInputStream( tempFile ) )
+                {
+                    wagon.putFromStream( fileInputStream, "test-secured-put-resource", content.length(), -1 );
+                    // This does not behave as expected because LightweightWagon does buffering by default
+                    if ( wagon.getClass().getName().contains( "Lightweight" ) )
+                    {
+                        assertTrue( true );
+                    }
+                    else
+                    {
+                        fail();
+                    }
+                }
+                catch ( TransferFailedException e )
+                {
+                    assertTrue( true );
+                }
+                finally
+                {
+                    wagon.disconnect();
+                    tempFile.delete();
+                }
+
+            }
+            finally
+            {
+                redirectServer.stop();
+            }
+        }
 
     /**
      *
diff --git a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
index 5d2eb57..1db8454 100644
--- a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
+++ b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
@@ -49,9 +49,9 @@ public class LightweightHttpWagonTest
         return getProtocol() + "://localhost:" + getTestRepositoryPort() + "/";
     }
 
-    protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
+    protected void setHttpConfiguration( StreamingWagon wagon, Properties headers, Properties params )
     {
-        ( (LightweightHttpWagon) wagon ).setHttpHeaders( properties );
+        ( (LightweightHttpWagon) wagon ).setHttpHeaders( headers );
     }
 
     @Override
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
index f872147..2aeb3a0 100755
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
@@ -42,12 +42,13 @@ public class HttpWagonTest
         return getProtocol() + "://localhost:" + getTestRepositoryPort();
     }
 
-    protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
+    protected void setHttpConfiguration( StreamingWagon wagon, Properties headers, Properties params )
     {
         HttpConfiguration config = new HttpConfiguration();
 
         HttpMethodConfiguration methodConfiguration = new HttpMethodConfiguration();
-        methodConfiguration.setHeaders( properties );
+        methodConfiguration.setHeaders( headers );
+        methodConfiguration.setParams( params );
         config.setAll( methodConfiguration );
         ( (HttpWagon) wagon ).setHttpConfiguration( config );
     }
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
index e1150e3..e6a355d 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
@@ -242,9 +242,15 @@ public class WebDavWagonTest
         }
     }
 
-    protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
+    protected void setHttpConfiguration( StreamingWagon wagon, Properties headers, Properties params )
     {
-        ( (WebDavWagon) wagon ).setHttpHeaders( properties );
+        HttpConfiguration config = new HttpConfiguration();
+
+        HttpMethodConfiguration methodConfiguration = new HttpMethodConfiguration();
+        methodConfiguration.setHeaders( headers );
+        methodConfiguration.setParams( params );
+        config.setAll( methodConfiguration );
+        ( (WebDavWagon) wagon ).setHttpConfiguration( config );
     }
 
     /**