knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [knox] branch master updated: KNOX-2128 - fix javadoc warnings/errors
Date Thu, 16 Jan 2020 19:37:18 GMT
This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
     new 22b61f1  KNOX-2128 - fix javadoc warnings/errors
22b61f1 is described below

commit 22b61f1068337588f884127eed3aefbd12344645
Author: Kevin Risden <krisden@apache.org>
AuthorDate: Thu Jan 16 14:18:33 2020 -0500

    KNOX-2128 - fix javadoc warnings/errors
    
    Signed-off-by: Kevin Risden <krisden@apache.org>
---
 .../org/apache/knox/gateway/shell/KnoxSession.java | 50 +++++++++-------------
 1 file changed, 21 insertions(+), 29 deletions(-)

diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
index 085a9a6..d046094 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
@@ -78,7 +78,6 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.nio.channels.FileChannel;
 import java.nio.channels.OverlappingFileLockException;
-import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.StandardOpenOption;
@@ -384,7 +383,7 @@ public class KnoxSession implements Closeable {
 
   private KeyStore getTrustStore(ClientContext clientContext) throws GeneralSecurityException
{
     KeyStore ks;
-    String truststorePass = null;
+    String truststorePass;
 
     // if a PEM file was provided create a keystore from that and use
     // it as the truststore
@@ -528,7 +527,7 @@ public class KnoxSession implements Closeable {
 
   public void waitFor( Future<?>... futures ) throws ExecutionException, InterruptedException
{
     if( futures != null ) {
-      for( Future future : futures ) {
+      for( Future<?> future : futures ) {
         future.get();
       }
     }
@@ -538,7 +537,7 @@ public class KnoxSession implements Closeable {
     if( futures != null ) {
       timeout = TimeUnit.MILLISECONDS.convert( timeout, units );
       long start;
-      for( Future future : futures ) {
+      for( Future<?> future : futures ) {
         start = System.currentTimeMillis();
         future.get( timeout, TimeUnit.MILLISECONDS );
         timeout -= ( System.currentTimeMillis() - start );
@@ -586,7 +585,7 @@ public class KnoxSession implements Closeable {
 
   /**
    * Persist provided Map to a file within the {user.home}/.knoxshell directory
-   * @param <T>
+   * @param <T> type of the list
    * @param fileName of persisted file
    * @param map to persist
    */
@@ -594,16 +593,13 @@ public class KnoxSession implements Closeable {
     String s = JsonUtils.renderAsJsonString(map);
     String home = System.getProperty("user.home");
     try {
-      write(new File(
-          home + File.separator +
-          ".knoxshell" + File.separator + fileName),
-          s, StandardCharsets.UTF_8);
+      write(new File(home + File.separator + ".knoxshell" + File.separator + fileName), s);
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
 
-  private static void write(File file, String s, Charset utf8) throws IOException {
+  private static void write(File file, String s) throws IOException {
     synchronized(KnoxSession.class) {
       // Ensure the parent directory exists...
       // This will attempt to create all missing directories.  No failures will occur if
the directories already exist.
@@ -611,9 +607,8 @@ public class KnoxSession implements Closeable {
       try (FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.WRITE,
           StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
         channel.tryLock();
-        FileUtils.write(file, s, utf8);
-      }
-      catch (OverlappingFileLockException e) {
+        FileUtils.write(file, s, StandardCharsets.UTF_8);
+      } catch (OverlappingFileLockException e) {
         System.out.println("Unable to acquire write lock for: " + file.getAbsolutePath());
       }
     }
@@ -631,6 +626,7 @@ public class KnoxSession implements Closeable {
    * Load and return a map of datasource names to sql commands
    * from the {user.home}/.knoxshell/knoxsqlhistories.json file.
    * @return sqlHistory map
+   * @throws IOException exception when loading sql history
    */
   public static Map<String, List<String>> loadSQLHistories() throws IOException
{
     Map<String, List<String>> sqlHistories = null;
@@ -640,22 +636,20 @@ public class KnoxSession implements Closeable {
         home + File.separator +
         ".knoxshell" + File.separator + KNOXSQLHISTORIES_JSON);
     if (historyFile.exists()) {
-      String json = readFileToString(historyFile, "UTF8");
-      sqlHistories = (Map<String, List<String>>) getMapOfStringArrayListsFromJsonString(json);
+      String json = readFileToString(historyFile);
+      sqlHistories = getMapOfStringArrayListsFromJsonString(json);
     }
     return sqlHistories;
   }
 
-  private static String readFileToString(File file, String s)
-      throws FileNotFoundException, IOException {
+  private static String readFileToString(File file) throws IOException {
     String content = null;
 
     synchronized(KnoxSession.class) {
       try (FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ))
{
         channel.tryLock(0L, Long.MAX_VALUE, true);
-        content = FileUtils.readFileToString(file, s);
-      }
-      catch (OverlappingFileLockException e) {
+        content = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
+      } catch (OverlappingFileLockException e) {
         System.out.println("Unable to acquire write lock for: " + file.getAbsolutePath());
       }
     }
@@ -666,18 +660,17 @@ public class KnoxSession implements Closeable {
   /**
    * Load and return a map of datasource names to KnoxDataSource
    * objects from the {user.home}/.knoxshell/knoxdatasources.json file.
-   * @return
+   * @return map of data sources
+   * @throws IOException exception when loading data sources
    */
   public static Map<String, KnoxDataSource> loadDataSources() throws IOException {
     Map<String, KnoxDataSource> datasources = null;
     String home = System.getProperty("user.home");
-    String json = null;
+    String json;
 
-    File dsFile = new File(
-        home + File.separator +
-        ".knoxshell" + File.separator + KNOXDATASOURCES_JSON);
+    File dsFile = new File(home + File.separator + ".knoxshell" + File.separator + KNOXDATASOURCES_JSON);
     if (dsFile.exists()) {
-      json = readFileToString(dsFile, "UTF8");
+      json = readFileToString(dsFile);
       datasources = getMapOfDataSourcesFromJsonString(json);
     }
 
@@ -685,7 +678,7 @@ public class KnoxSession implements Closeable {
   }
 
   public static Map<String, List<String>> getMapOfStringArrayListsFromJsonString(String
json) throws IOException {
-    Map<String, List<String>> obj = null;
+    Map<String, List<String>> obj;
     JsonFactory factory = new JsonFactory();
     ObjectMapper mapper = new ObjectMapper(factory);
     TypeReference<Map<String, List<String>>> typeRef = new TypeReference<Map<String,
List<String>>>() {};
@@ -694,7 +687,7 @@ public class KnoxSession implements Closeable {
   }
 
   public static Map<String, KnoxDataSource> getMapOfDataSourcesFromJsonString(String
json) throws IOException {
-    Map<String, KnoxDataSource> obj = null;
+    Map<String, KnoxDataSource> obj;
     JsonFactory factory = new JsonFactory();
     ObjectMapper mapper = new ObjectMapper(factory);
     TypeReference<Map<String, KnoxDataSource>> typeRef = new TypeReference<Map<String,
KnoxDataSource>>() {};
@@ -703,7 +696,6 @@ public class KnoxSession implements Closeable {
   }
 
   private static final class JAASClientConfig extends Configuration {
-
     private static final Configuration baseConfig = Configuration.getConfiguration();
 
     private Configuration configFile;


Mime
View raw message