KNOX-2128 - fix javadoc warnings/errors
Signed-off-by: Kevin Risden <krisden@apache.org>
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.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 @@
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 void waitFor( Future<?>... futures ) throws ExecutionException, InterruptedException {
if( futures != null ) {
- for( Future future : futures ) {
+ for( Future<?> future : futures ) {
future.get();
}
}
@@ -538,7 +537,7 @@
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 @@
/**
* 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 @@
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 @@
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 @@
* 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 @@
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 @@
/**
* 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 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 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 @@
}
private static final class JAASClientConfig extends Configuration {
-
private static final Configuration baseConfig = Configuration.getConfiguration();
private Configuration configFile;