SLIDER-82 some minor IDE-suggested cleanup
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/138912cc Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/138912cc Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/138912cc Branch: refs/heads/feature/SLIDER-82-pass-3.1 Commit: 138912cce9a092a4babd054124cfe3babb12a303 Parents: 7f96416 Author: Steve Loughran <[email protected]> Authored: Fri Nov 6 10:42:58 2015 +0000 Committer: Steve Loughran <[email protected]> Committed: Fri Nov 6 12:06:11 2015 +0000 ---------------------------------------------------------------------- .../java/org/apache/slider/api/ClusterDescription.java | 8 ++++---- .../org/apache/slider/common/tools/SliderUtils.java | 12 +++++------- 2 files changed, 9 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/138912cc/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java b/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java index 025bd32..7e3a9b4 100644 --- a/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java +++ b/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java @@ -166,14 +166,14 @@ public class ClusterDescription implements Cloneable { * the Slider AM and the application that it deploys */ public Map<String, String> options = - new HashMap<String, String>(); + new HashMap<>(); /** * cluster information * This is only valid when querying the cluster status. */ public Map<String, String> info = - new HashMap<String, String>(); + new HashMap<>(); /** * Statistics. This is only relevant when querying the cluster status @@ -199,7 +199,7 @@ public class ClusterDescription implements Cloneable { * List of key-value pairs to add to a client config to set up the client */ public Map<String, String> clientProperties = - new HashMap<String, String>(); + new HashMap<>(); /** * Status information @@ -564,7 +564,7 @@ public class ClusterDescription implements Cloneable { public Map<String, String> getOrAddRole(String role) { Map<String, String> map = getRole(role); if (map == null) { - map = new HashMap<String, String>(); + map = new HashMap<>(); } roles.put(role, map); return map; http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/138912cc/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java index 76668bf..5bf8622 100644 --- a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java +++ b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java @@ -746,10 +746,7 @@ public final class SliderUtils { * through */ public static boolean filter(String value, String filter) { - if (StringUtils.isEmpty(filter) || filter.equals(value)) { - return false; - } - return true; + return !(StringUtils.isEmpty(filter) || filter.equals(value)); } /** @@ -2028,10 +2025,10 @@ public final class SliderUtils { errorText.append("No native IO library. "); } try { - String path = Shell.getQualifiedBinPath("winutils.exe"); + String path = Shell.getQualifiedBinPath(WINUTILS); log.debug("winutils is at {}", path); } catch (IOException e) { - errorText.append("No WINUTILS.EXE. "); + errorText.append("No " + WINUTILS); log.warn("No winutils: {}", e, e); } try { @@ -2334,6 +2331,7 @@ public final class SliderUtils { public static String getClientConfigPath() { URL path = ConfigHelper.class.getClassLoader().getResource( SliderKeys.SLIDER_CLIENT_XML); + Preconditions.checkNotNull(path, "Failed to locate resource " + SliderKeys.SLIDER_CLIENT_XML); return path.toString(); } @@ -2483,7 +2481,7 @@ public final class SliderUtils { public static String requestToString(AMRMClient.ContainerRequest request) { Preconditions.checkArgument(request != null, "Null request"); - StringBuffer buffer = new StringBuffer(request.toString()); + StringBuilder buffer = new StringBuilder(request.toString()); buffer.append("; "); buffer.append("relaxLocality=").append(request.getRelaxLocality()).append("; "); String labels = request.getNodeLabelExpression();
