]> source.dussan.org Git - jgit.git/commitdiff
[findBugs] Fix calculation of host header in SignerV4 61/73161/2
authorMatthias Sohn <matthias.sohn@sap.com>
Thu, 19 May 2016 12:50:12 +0000 (14:50 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Thu, 19 May 2016 13:01:05 +0000 (15:01 +0200)
We ignored the returned concatenation of host name and port number. Fix
this and use a StringBuilder to avoid creation of unnecessary String
objects.

Change-Id: I61fac639d4a4c95412eb41a0f9131d0c38aca794
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java

index 08bb4b96fd45344a01fce0fdebf4c71c14132a1b..f95b605c85955c391d3477f993c18d1bd02454c0 100644 (file)
@@ -229,12 +229,12 @@ class SignerV4 {
 
        private static void addHostHeader(URL url,
                        Map<String, String> headers) {
-               String hostHeader = url.getHost();
+               StringBuilder hostHeader = new StringBuilder(url.getHost());
                int port = url.getPort();
                if (port > -1) {
-                       hostHeader.concat(":" + Integer.toString(port)); //$NON-NLS-1$
+                       hostHeader.append(":").append(port); //$NON-NLS-1$
                }
-               headers.put("Host", hostHeader); //$NON-NLS-1$
+               headers.put("Host", hostHeader.toString()); //$NON-NLS-1$
        }
 
        private static String canonicalizeHeaderNames(