knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject knox git commit: KNOX-883 - Fix FindBugs "Correctness" issues (Colm O hEigeartaigh via lmccay)
Date Wed, 22 Feb 2017 03:32:28 GMT
Repository: knox
Updated Branches:
  refs/heads/master c346ee379 -> 15bb53810


KNOX-883 - Fix FindBugs "Correctness" issues (Colm O hEigeartaigh via lmccay)

Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/15bb5381
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/15bb5381
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/15bb5381

Branch: refs/heads/master
Commit: 15bb53810b5af0009a4c0a6df2a3e7bc0729ed67
Parents: c346ee3
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Tue Feb 21 22:31:53 2017 -0500
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Tue Feb 21 22:32:21 2017 -0500

----------------------------------------------------------------------
 .../gateway/service/knoxsso/WebSSOResource.java |  5 +++--
 .../service/knoxsso/WebSSOutResource.java       |  4 ++++
 .../org/apache/hadoop/gateway/shell/KnoxSh.java |  4 +++-
 .../security/impl/BaseKeystoreService.java      |  4 +++-
 .../hadoop/test/mock/MockResponseProvider.java  |  4 ----
 .../audit/log4j/audit/Log4jAuditContext.java    |  3 ---
 .../impl/DefaultConfigurationInjector.java      | 22 ++++++++++---------
 .../hadoop/gateway/launcher/Streamer.java       |  2 ++
 .../gateway/util/urltemplate/Template.java      | 23 +++++++-------------
 9 files changed, 35 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/15bb5381/gateway-service-knoxsso/src/main/java/org/apache/hadoop/gateway/service/knoxsso/WebSSOResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-knoxsso/src/main/java/org/apache/hadoop/gateway/service/knoxsso/WebSSOResource.java
b/gateway-service-knoxsso/src/main/java/org/apache/hadoop/gateway/service/knoxsso/WebSSOResource.java
index 283b627..417fe66 100644
--- a/gateway-service-knoxsso/src/main/java/org/apache/hadoop/gateway/service/knoxsso/WebSSOResource.java
+++ b/gateway-service-knoxsso/src/main/java/org/apache/hadoop/gateway/service/knoxsso/WebSSOResource.java
@@ -22,6 +22,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.security.Principal;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Map;
 import java.util.Map.Entry;
 
@@ -204,7 +205,7 @@ public class WebSSOResource {
       try {
         response.getOutputStream().close();
       } catch (IOException e) {
-        log.unableToCloseOutputStream(e.getMessage(), e.getStackTrace().toString());
+        log.unableToCloseOutputStream(e.getMessage(), Arrays.toString(e.getStackTrace()));
       }
     }
     catch (TokenServiceException e) {
@@ -291,7 +292,7 @@ public class WebSSOResource {
       log.addedJWTCookie();
     }
     catch(Exception e) {
-      log.unableAddCookieToResponse(e.getMessage(), e.getStackTrace().toString());
+      log.unableAddCookieToResponse(e.getMessage(), Arrays.toString(e.getStackTrace()));
       throw new WebApplicationException("Unable to add JWT cookie to response.");
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/15bb5381/gateway-service-knoxssout/src/main/java/org/apache/hadoop/gateway/service/knoxsso/WebSSOutResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-knoxssout/src/main/java/org/apache/hadoop/gateway/service/knoxsso/WebSSOutResource.java
b/gateway-service-knoxssout/src/main/java/org/apache/hadoop/gateway/service/knoxsso/WebSSOutResource.java
index cfc9af6..f01aa33 100644
--- a/gateway-service-knoxssout/src/main/java/org/apache/hadoop/gateway/service/knoxsso/WebSSOutResource.java
+++ b/gateway-service-knoxssout/src/main/java/org/apache/hadoop/gateway/service/knoxsso/WebSSOutResource.java
@@ -80,6 +80,10 @@ public class WebSSOutResource {
       return ok().entity("{ \"loggedOut\" : false }").build();
     }
   }
+  
+  public void setDomainSuffix(String domainSuffix) {
+    this.domainSuffix = domainSuffix;
+  }
 
   private boolean removeAuthenticationToken(HttpServletResponse response) {
     boolean rc = true;

http://git-wip-us.apache.org/repos/asf/knox/blob/15bb5381/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java
index 3dfce78..0e2a14d 100644
--- a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java
@@ -203,7 +203,9 @@ public class KnoxSh {
       catch(HadoopException he) {
         System.out.println("Failure to acquire token. Please verify your credentials and
Knox URL and try again.");
       }
-      session.shutdown();
+      if ( session != null ) {
+        session.shutdown();
+      }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/15bb5381/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/BaseKeystoreService.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/BaseKeystoreService.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/BaseKeystoreService.java
index 0f1b611..055cbe3 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/BaseKeystoreService.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/BaseKeystoreService.java
@@ -135,7 +135,9 @@ public class BaseKeystoreService {
       }
       finally {
           try {
-            input.close();
+            if ( input != null ) {
+              input.close();
+            }
           } catch (IOException e) {
             LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
           }

http://git-wip-us.apache.org/repos/asf/knox/blob/15bb5381/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
index 82571ef..21952e1 100644
--- a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
+++ b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
@@ -44,7 +44,6 @@ public class MockResponseProvider {
   String contentType = null;
   String characterEncoding = null;
   Integer contentLength = null;
-  Locale locale = null;
 
   public MockResponseProvider status( int statusCode ) {
     this.statusCode = statusCode;
@@ -139,9 +138,6 @@ public class MockResponseProvider {
         response.addCookie( cookie );
       }
     }
-    if( locale != null ) {
-      response.setLocale( locale );
-    }
     if( contentType != null ) {
       response.setContentType( contentType );
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/15bb5381/gateway-util-common/src/main/java/org/apache/hadoop/gateway/audit/log4j/audit/Log4jAuditContext.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/hadoop/gateway/audit/log4j/audit/Log4jAuditContext.java
b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/audit/log4j/audit/Log4jAuditContext.java
index 03c2f75..aa6659c 100644
--- a/gateway-util-common/src/main/java/org/apache/hadoop/gateway/audit/log4j/audit/Log4jAuditContext.java
+++ b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/audit/log4j/audit/Log4jAuditContext.java
@@ -18,7 +18,6 @@
 package org.apache.hadoop.gateway.audit.log4j.audit;
 
 import java.io.Serializable;
-import java.util.Set;
 
 import org.apache.hadoop.gateway.audit.api.AuditContext;
 
@@ -29,7 +28,6 @@ public class Log4jAuditContext implements Serializable, AuditContext {
   private String username;
   private String proxyUsername;
   private String systemUsername;
-  private Set<String> groups;
   private String targetServiceName;
   private String remoteIp;
   private String remoteHostname;
@@ -101,7 +99,6 @@ public class Log4jAuditContext implements Serializable, AuditContext {
     sb.append( "username=" ).append( username );
     sb.append( ", proxy_username=" ).append( proxyUsername );
     sb.append( ", system_username=" ).append( systemUsername );
-    sb.append( ", groups=" ).append( groups );
     sb.append( ", targetServiceName=" ).append( targetServiceName );
     sb.append( ", remoteIp=" ).append( remoteIp );
     sb.append( ", remoteHostname=" ).append( remoteHostname );

http://git-wip-us.apache.org/repos/asf/knox/blob/15bb5381/gateway-util-configinjector/src/main/java/org/apache/hadoop/gateway/config/impl/DefaultConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/gateway-util-configinjector/src/main/java/org/apache/hadoop/gateway/config/impl/DefaultConfigurationInjector.java
b/gateway-util-configinjector/src/main/java/org/apache/hadoop/gateway/config/impl/DefaultConfigurationInjector.java
index 8b7e13a..29c9e85 100755
--- a/gateway-util-configinjector/src/main/java/org/apache/hadoop/gateway/config/impl/DefaultConfigurationInjector.java
+++ b/gateway-util-configinjector/src/main/java/org/apache/hadoop/gateway/config/impl/DefaultConfigurationInjector.java
@@ -211,17 +211,19 @@ public class DefaultConfigurationInjector implements ConfigurationInjector
{
 
   private static String getConfigName( Method method ) {
     String methodName = method.getName();
-    StringBuilder name = new StringBuilder( methodName.length() );
-    if( methodName != null &&
-        methodName.length() > 3 &&
-        methodName.startsWith( "set" ) &&
-        Character.isUpperCase( methodName.charAt( 3 ) ) ) {
-      name.append( methodName.substring( 3 ) );
-      name.setCharAt( 0, Character.toLowerCase( name.charAt( 0 ) ) );
-    } else {
-      name.append( name );
+    if( methodName != null ) {
+        StringBuilder name = new StringBuilder( methodName.length() );
+        if( methodName.length() > 3 &&
+            methodName.startsWith( "set" ) &&
+            Character.isUpperCase( methodName.charAt( 3 ) ) ) {
+          name.append( methodName.substring( 3 ) );
+          name.setCharAt( 0, Character.toLowerCase( name.charAt( 0 ) ) );
+        } else {
+          name.append( name );
+        }
+        return name.toString();
     }
-    return name.toString();
+    return null;
   }
 
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/15bb5381/gateway-util-launcher/src/main/java/org/apache/hadoop/gateway/launcher/Streamer.java
----------------------------------------------------------------------
diff --git a/gateway-util-launcher/src/main/java/org/apache/hadoop/gateway/launcher/Streamer.java
b/gateway-util-launcher/src/main/java/org/apache/hadoop/gateway/launcher/Streamer.java
index 02cb88b..f701e38 100644
--- a/gateway-util-launcher/src/main/java/org/apache/hadoop/gateway/launcher/Streamer.java
+++ b/gateway-util-launcher/src/main/java/org/apache/hadoop/gateway/launcher/Streamer.java
@@ -32,6 +32,8 @@ public class Streamer extends Thread {
     this.setName( name );
     this.setPriority( priority );
     this.start();
+    this.input = input;
+    this.output = output;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/15bb5381/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Template.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Template.java
b/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Template.java
index 253b2e0..6104e76 100644
--- a/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Template.java
+++ b/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Template.java
@@ -43,7 +43,6 @@ public class Template {
   private boolean hasQuery;
   private Fragment fragment;
   private boolean hasFragment;
-  private String image;
   private Integer hash;
 
   Template(
@@ -81,7 +80,6 @@ public class Template {
     this.hasQuery = hasQuery;
     this.fragment = fragment;
     this.hasFragment = hasFragment;
-    this.image = null;
     this.hash = null;
   }
 
@@ -363,21 +361,16 @@ public class Template {
   }
 
   private String toString( boolean encoded ) {
-    String s = image;
-    if( s == null ) {
-      StringBuilder b = new StringBuilder();
-      buildScheme( b, encoded );
-      buildAuthority( b, encoded );
-      buildPath( b, encoded );
-      buildQuery( b, encoded );
-      buildFragment( b , encoded);
-      s = b.toString();
-      //image = s;
-    }
-    return s;
+    StringBuilder b = new StringBuilder();
+    buildScheme( b, encoded );
+    buildAuthority( b, encoded );
+    buildPath( b, encoded );
+    buildQuery( b, encoded );
+    buildFragment( b , encoded);
+    return b.toString();
   }
 
- public String toEncodedString() {
+  public String toEncodedString() {
     return toString(true);
   }
 


Mime
View raw message