Index: wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
===================================================================
--- wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java	(revision 668025)
+++ wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java	(working copy)
@@ -354,14 +354,15 @@
         int statusCode;
         try
         {
-            statusCode = execute( headMethod );
-        }
-        catch ( IOException e )
-        {
-            throw new TransferFailedException( e.getMessage(), e );
-        }
-        try
-        {
+            try
+            {
+                statusCode = execute( headMethod );
+            }
+            catch ( IOException e )
+            {
+                throw new TransferFailedException( e.getMessage(), e );
+            }
+            
             switch ( statusCode )
             {
                 case HttpStatus.SC_OK:
@@ -471,127 +472,134 @@
             getMethod.addRequestHeader( hdr );
         }
 
-        int statusCode;
         try
         {
-            statusCode = execute( getMethod );
-        }
-        catch ( IOException e )
-        {
-            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+            int statusCode;
+            try
+            {
+                statusCode = execute( getMethod );
+            }
+            catch ( IOException e )
+            {
+                fireTransferError( resource, e, TransferEvent.REQUEST_GET );
 
-            throw new TransferFailedException( e.getMessage(), e );
-        }
+                throw new TransferFailedException( e.getMessage(), e );
+            }
 
-        fireTransferDebug( url + " - Status code: " + statusCode );
+            fireTransferDebug( url + " - Status code: " + statusCode );
 
-        // TODO [BP]: according to httpclient docs, really should swallow the output on error. verify if that is
-        // required
-        switch ( statusCode )
-        {
-            case HttpStatus.SC_OK:
-                break;
+            // TODO [BP]: according to httpclient docs, really should swallow the output on error. verify if that is
+            // required
+            switch ( statusCode )
+            {
+                case HttpStatus.SC_OK:
+                    break;
 
-            case HttpStatus.SC_NOT_MODIFIED:
-                // return, leaving last modified set to original value so getIfNewer should return unmodified
-                return;
+                case HttpStatus.SC_NOT_MODIFIED:
+                    // return, leaving last modified set to original value so getIfNewer should return unmodified
+                    return;
 
-            case SC_NULL:
-            {
-                TransferFailedException e = new TransferFailedException( "Failed to transfer file: " + url );
-                fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-                throw e;
-            }
+                case SC_NULL:
+                {
+                    TransferFailedException e = new TransferFailedException( "Failed to transfer file: " + url );
+                    fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+                    throw e;
+                }
 
-            case HttpStatus.SC_FORBIDDEN:
-                fireSessionConnectionRefused();
-                throw new AuthorizationException( "Access denied to: " + url );
+                case HttpStatus.SC_FORBIDDEN:
+                    fireSessionConnectionRefused();
+                    throw new AuthorizationException( "Access denied to: " + url );
 
-            case HttpStatus.SC_UNAUTHORIZED:
-                fireSessionConnectionRefused();
-                throw new AuthorizationException( "Not authorized." );
+                case HttpStatus.SC_UNAUTHORIZED:
+                    fireSessionConnectionRefused();
+                    throw new AuthorizationException( "Not authorized." );
 
-            case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
-                fireSessionConnectionRefused();
-                throw new AuthorizationException( "Not authorized by proxy." );
+                case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+                    fireSessionConnectionRefused();
+                    throw new AuthorizationException( "Not authorized by proxy." );
 
-            case HttpStatus.SC_NOT_FOUND:
-                throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
+                case HttpStatus.SC_NOT_FOUND:
+                    throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
 
-                // add more entries here
-            default:
-            {
-                cleanupGetTransfer( resource );
-                TransferFailedException e =
-                    new TransferFailedException( "Failed to transfer file: " + url + ". Return code is: "
-                        + statusCode );
-                fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-                throw e;
+                    // add more entries here
+                default:
+                {
+                    cleanupGetTransfer( resource );
+                    TransferFailedException e =
+                        new TransferFailedException( "Failed to transfer file: " + url + ". Return code is: "
+                            + statusCode );
+                    fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+                    throw e;
+                }
             }
-        }
 
-        InputStream is = null;
+            InputStream is = null;
 
-        Header contentLengthHeader = getMethod.getResponseHeader( "Content-Length" );
+            Header contentLengthHeader = getMethod.getResponseHeader( "Content-Length" );
 
-        if ( contentLengthHeader != null )
-        {
-            try
+            if ( contentLengthHeader != null )
             {
-                long contentLength = Integer.valueOf( contentLengthHeader.getValue() ).intValue();
+                try
+                {
+                    long contentLength = Integer.valueOf( contentLengthHeader.getValue() ).intValue();
 
-                resource.setContentLength( contentLength );
+                    resource.setContentLength( contentLength );
+                }
+                catch ( NumberFormatException e )
+                {
+                    fireTransferDebug( "error parsing content length header '" + contentLengthHeader.getValue() + "' "
+                        + e );
+                }
             }
-            catch ( NumberFormatException e )
+
+            Header lastModifiedHeader = getMethod.getResponseHeader( "Last-Modified" );
+
+            long lastModified = 0;
+
+            if ( lastModifiedHeader != null )
             {
-                fireTransferDebug( "error parsing content length header '" + contentLengthHeader.getValue() + "' "
-                    + e );
+                try
+                {
+                    lastModified = DateParser.parseDate( lastModifiedHeader.getValue() ).getTime();
+
+                    resource.setLastModified( lastModified );
+                }
+                catch ( DateParseException e )
+                {
+                    fireTransferDebug( "Unable to parse last modified header" );
+                }
+
+                fireTransferDebug( "last-modified = " + lastModifiedHeader.getValue() + " (" + lastModified + ")" );
             }
-        }
 
-        Header lastModifiedHeader = getMethod.getResponseHeader( "Last-Modified" );
+            Header contentEncoding = getMethod.getResponseHeader( "Content-Encoding" );
+            boolean isGZipped =
+                contentEncoding == null ? false : "gzip".equalsIgnoreCase( contentEncoding.getValue() );
 
-        long lastModified = 0;
-
-        if ( lastModifiedHeader != null )
-        {
             try
             {
-                lastModified = DateParser.parseDate( lastModifiedHeader.getValue() ).getTime();
-
-                resource.setLastModified( lastModified );
+                is = getMethod.getResponseBodyAsStream();
+                if ( isGZipped )
+                {
+                    is = new GZIPInputStream( is );
+                }
             }
-            catch ( DateParseException e )
+            catch ( IOException e )
             {
-                fireTransferDebug( "Unable to parse last modified header" );
-            }
+                fireTransferError( resource, e, TransferEvent.REQUEST_GET );
 
-            fireTransferDebug( "last-modified = " + lastModifiedHeader.getValue() + " (" + lastModified + ")" );
-        }
+                String msg =
+                    "Error occurred while retrieving from remote repository:" + getRepository() + ": " + e.getMessage();
 
-        Header contentEncoding = getMethod.getResponseHeader( "Content-Encoding" );
-        boolean isGZipped =
-            contentEncoding == null ? false : "gzip".equalsIgnoreCase( contentEncoding.getValue() );
+                throw new TransferFailedException( msg, e );
+            }
 
-        try
-        {
-            is = getMethod.getResponseBodyAsStream();
-            if ( isGZipped )
-            {
-                is = new GZIPInputStream( is );
-            }
+            inputData.setInputStream( is );
         }
-        catch ( IOException e )
+        finally
         {
-            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
-            String msg =
-                "Error occurred while retrieving from remote repository:" + getRepository() + ": " + e.getMessage();
-
-            throw new TransferFailedException( msg, e );
+            getMethod.releaseConnection();
         }
-        
-        inputData.setInputStream( is );
     }
 
     protected void cleanupGetTransfer( Resource resource )

