You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by an...@apache.org on 2018/07/02 08:01:00 UTC

oozie git commit: OOZIE-2956 Fix Findbugs warnings related to reliance on default encoding in oozie-core (Jan Hentschel, kmarton via andras.piros)

Repository: oozie
Updated Branches:
  refs/heads/master 5b55169c6 -> 2f6bced4f


OOZIE-2956 Fix Findbugs warnings related to reliance on default encoding in oozie-core (Jan Hentschel, kmarton via andras.piros)


Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/2f6bced4
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/2f6bced4
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/2f6bced4

Branch: refs/heads/master
Commit: 2f6bced4fdfe6a438183b3e3fb0f4e2cadc89770
Parents: 5b55169
Author: Andras Piros <an...@cloudera.com>
Authored: Mon Jul 2 09:58:05 2018 +0200
Committer: Andras Piros <an...@cloudera.com>
Committed: Mon Jul 2 09:59:41 2018 +0200

----------------------------------------------------------------------
 core/pom.xml                                    |   5 +
 .../main/java/org/apache/oozie/StringBlob.java  |   4 +-
 .../org/apache/oozie/action/ActionExecutor.java |  16 ++-
 .../oozie/action/hadoop/LauncherHelper.java     |  52 ++++----
 .../action/hadoop/MapReduceActionExecutor.java  |  13 +-
 .../action/hadoop/SqoopActionExecutor.java      |   5 +-
 .../oozie/action/ssh/SshActionExecutor.java     |  47 +++----
 .../command/bundle/BundleSubmitXCommand.java    |  21 +--
 .../command/coord/CoordSubmitXCommand.java      |  47 +++----
 .../command/coord/CoordUpdateXCommand.java      |  15 +--
 .../oozie/service/AuthorizationService.java     | 133 +++++++++----------
 .../oozie/service/WorkflowAppService.java       |  20 +--
 .../org/apache/oozie/servlet/V1JobServlet.java  |  39 ++----
 .../apache/oozie/servlet/V2ValidateServlet.java |   8 +-
 .../org/apache/oozie/util/AuthUrlClient.java    |  35 +++--
 .../java/org/apache/oozie/util/IOUtils.java     |   6 +-
 .../org/apache/oozie/util/MultiFileReader.java  |   6 +-
 .../org/apache/oozie/util/XConfiguration.java   |  14 +-
 .../java/org/apache/oozie/util/XmlUtils.java    |  12 +-
 release-log.txt                                 |   1 +
 20 files changed, 233 insertions(+), 266 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index a5a776c..92236bc 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -507,6 +507,11 @@
             <artifactId>hive-jdbc</artifactId>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/StringBlob.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/StringBlob.java b/core/src/main/java/org/apache/oozie/StringBlob.java
index 6c77601..eba1313 100644
--- a/core/src/main/java/org/apache/oozie/StringBlob.java
+++ b/core/src/main/java/org/apache/oozie/StringBlob.java
@@ -21,7 +21,9 @@ package org.apache.oozie;
 import java.io.ByteArrayInputStream;
 import java.io.DataInputStream;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 
+import com.google.common.base.Charsets;
 import org.apache.oozie.compression.CodecFactory;
 import org.apache.oozie.compression.CompressionCodec;
 import org.apache.oozie.util.ByteArrayUtils;
@@ -117,7 +119,7 @@ public class StringBlob {
             }
         }
         else {
-            rawBlob = ByteArrayUtils.weakIntern(string.getBytes());
+            rawBlob = ByteArrayUtils.weakIntern(string.getBytes(Charsets.UTF_8));
         }
         return rawBlob;
     }

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/action/ActionExecutor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/action/ActionExecutor.java b/core/src/main/java/org/apache/oozie/action/ActionExecutor.java
index 919509d..71bd36a 100644
--- a/core/src/main/java/org/apache/oozie/action/ActionExecutor.java
+++ b/core/src/main/java/org/apache/oozie/action/ActionExecutor.java
@@ -18,6 +18,7 @@
 
 package org.apache.oozie.action;
 
+import com.google.common.base.Charsets;
 import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -34,6 +35,7 @@ import org.apache.oozie.service.Services;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
 import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
@@ -58,13 +60,12 @@ public abstract class ActionExecutor {
 
     public static final String OOZIE_ACTION_YARN_TAG = "oozie.action.yarn.tag";
 
-
     /**
      * Error code used by {@link #convertException} when there is not register error information for an exception.
      */
     public static final String ERROR_OTHER = "OTHER";
 
-    public static enum RETRYPOLICY {
+    public enum RETRYPOLICY {
         EXPONENTIAL, PERIODIC
     }
 
@@ -81,7 +82,7 @@ public abstract class ActionExecutor {
     }
 
     private static boolean initMode = false;
-    private static Map<String, Map<String, ErrorInfo>> ERROR_INFOS = new HashMap<String, Map<String, ErrorInfo>>();
+    private static Map<String, Map<String, ErrorInfo>> ERROR_INFOS = new HashMap<>();
 
     /**
      * Context information passed to the ActionExecutor methods.
@@ -350,8 +351,13 @@ public abstract class ActionExecutor {
         }
         catch (java.lang.NoClassDefFoundError err) {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            err.printStackTrace(new PrintStream(baos));
-            XLog.getLog(getClass()).warn(baos.toString());
+
+            try {
+                err.printStackTrace(new PrintStream(baos, false, Charsets.UTF_8.name()));
+                XLog.getLog(getClass()).warn(baos.toString(Charsets.UTF_8.name()));
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/action/hadoop/LauncherHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/action/hadoop/LauncherHelper.java b/core/src/main/java/org/apache/oozie/action/hadoop/LauncherHelper.java
index 21c9b7e..a71d930 100644
--- a/core/src/main/java/org/apache/oozie/action/hadoop/LauncherHelper.java
+++ b/core/src/main/java/org/apache/oozie/action/hadoop/LauncherHelper.java
@@ -22,6 +22,7 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -33,7 +34,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import com.google.common.base.Charsets;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.SequenceFile;
@@ -64,12 +67,11 @@ public class LauncherHelper {
 
         if (fs.exists(recoveryFile)) {
             InputStream is = fs.open(recoveryFile);
-            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+            BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
             jobId = reader.readLine();
             reader.close();
         }
         return jobId;
-
     }
 
     public static void setupMainClass(Configuration launcherConf, String javaMainClass) {
@@ -130,7 +132,7 @@ public class LauncherHelper {
         actionConf.set(LauncherAMUtils.OOZIE_ACTION_ID, actionId);
 
         if (Services.get().getConf().getBoolean("oozie.hadoop-2.0.2-alpha.workaround.for.distributed.cache", false)) {
-          List<String> purgedEntries = new ArrayList<String>();
+          List<String> purgedEntries = new ArrayList<>();
           Collection<String> entries = actionConf.getStringCollection("mapreduce.job.cache.files");
           for (String entry : entries) {
             if (entry.contains("#")) {
@@ -155,9 +157,8 @@ public class LauncherHelper {
 
     public static String getTag(String launcherTag) throws NoSuchAlgorithmException {
         MessageDigest digest = MessageDigest.getInstance("MD5");
-        digest.update(launcherTag.getBytes(), 0, launcherTag.length());
-        String md5 = "oozie-" + new BigInteger(1, digest.digest()).toString(16);
-        return md5;
+        digest.update(launcherTag.getBytes(Charsets.UTF_8), 0, launcherTag.length());
+        return "oozie-" + new BigInteger(1, digest.digest()).toString(16);
     }
 
     public static boolean isMainDone(RunningJob runningJob) throws IOException {
@@ -246,7 +247,7 @@ public class LauncherHelper {
         return ugi.doAs(new PrivilegedExceptionAction<Map<String, String>>() {
             @Override
             public Map<String, String> run() throws IOException {
-                Map<String, String> ret = new HashMap<String, String>();
+                Map<String, String> ret = new HashMap<>();
                 Path seqFilePath = getActionDataSequenceFilePath(actionDir);
                 if (fs.exists(seqFilePath)) {
                     SequenceFile.Reader seqFile = new SequenceFile.Reader(fs, seqFilePath, conf);
@@ -259,42 +260,41 @@ public class LauncherHelper {
                 else { // maintain backward-compatibility. to be deprecated
                     org.apache.hadoop.fs.FileStatus[] files = fs.listStatus(actionDir);
                     InputStream is;
-                    BufferedReader reader = null;
+                    BufferedReader reader;
                     Properties props;
                     if (files != null && files.length > 0) {
-                        for (int x = 0; x < files.length; x++) {
-                            Path file = files[x].getPath();
-                            if (file.equals(new Path(actionDir, "externalChildIds.properties"))) {
-                                is = fs.open(file);
-                                reader = new BufferedReader(new InputStreamReader(is));
+                        for (FileStatus fileStatus : files) {
+                            Path path = fileStatus.getPath();
+                            if (path.equals(new Path(actionDir, "externalChildIds.properties"))) {
+                                is = fs.open(path);
+                                reader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
                                 ret.put(LauncherAMUtils.ACTION_DATA_EXTERNAL_CHILD_IDS,
                                         IOUtils.getReaderAsString(reader, -1));
-                            }
-                            else if (file.equals(new Path(actionDir, "newId.properties"))) {
-                                is = fs.open(file);
-                                reader = new BufferedReader(new InputStreamReader(is));
+                            } else if (path.equals(new Path(actionDir, "newId.properties"))) {
+                                is = fs.open(path);
+                                reader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
                                 props = PropertiesUtils.readProperties(reader, -1);
                                 ret.put(LauncherAMUtils.ACTION_DATA_NEW_ID, props.getProperty("id"));
                             }
-                            else if (file.equals(new Path(actionDir, LauncherAMUtils.ACTION_DATA_OUTPUT_PROPS))) {
+                            else if (path.equals(new Path(actionDir, LauncherAMUtils.ACTION_DATA_OUTPUT_PROPS))) {
                                 int maxOutputData = conf.getInt(LauncherAMUtils.CONF_OOZIE_ACTION_MAX_OUTPUT_DATA,
                                         2 * 1024);
-                                is = fs.open(file);
-                                reader = new BufferedReader(new InputStreamReader(is));
+                                is = fs.open(path);
+                                reader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
                                 ret.put(LauncherAMUtils.ACTION_DATA_OUTPUT_PROPS, PropertiesUtils
                                         .propertiesToString(PropertiesUtils.readProperties(reader, maxOutputData)));
                             }
-                            else if (file.equals(new Path(actionDir, LauncherAMUtils.ACTION_DATA_STATS))) {
+                            else if (path.equals(new Path(actionDir, LauncherAMUtils.ACTION_DATA_STATS))) {
                                 int statsMaxOutputData = conf.getInt(LauncherAMUtils.CONF_OOZIE_EXTERNAL_STATS_MAX_SIZE,
                                         Integer.MAX_VALUE);
-                                is = fs.open(file);
-                                reader = new BufferedReader(new InputStreamReader(is));
+                                is = fs.open(path);
+                                reader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
                                 ret.put(LauncherAMUtils.ACTION_DATA_STATS, PropertiesUtils
                                         .propertiesToString(PropertiesUtils.readProperties(reader, statsMaxOutputData)));
                             }
-                            else if (file.equals(new Path(actionDir, LauncherAMUtils.ACTION_DATA_ERROR_PROPS))) {
-                                is = fs.open(file);
-                                reader = new BufferedReader(new InputStreamReader(is));
+                            else if (path.equals(new Path(actionDir, LauncherAMUtils.ACTION_DATA_ERROR_PROPS))) {
+                                is = fs.open(path);
+                                reader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
                                 ret.put(LauncherAMUtils.ACTION_DATA_ERROR_PROPS, IOUtils.getReaderAsString(reader, -1));
                             }
                         }

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/action/hadoop/MapReduceActionExecutor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/action/hadoop/MapReduceActionExecutor.java b/core/src/main/java/org/apache/oozie/action/hadoop/MapReduceActionExecutor.java
index d0b8074..83a23f5 100644
--- a/core/src/main/java/org/apache/oozie/action/hadoop/MapReduceActionExecutor.java
+++ b/core/src/main/java/org/apache/oozie/action/hadoop/MapReduceActionExecutor.java
@@ -21,10 +21,10 @@ package org.apache.oozie.action.hadoop;
 import java.io.IOException;
 import java.io.StringReader;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
+import com.google.common.base.Charsets;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -59,7 +59,7 @@ public class MapReduceActionExecutor extends JavaActionExecutor {
 
     @Override
     public List<Class<?>> getLauncherClasses() {
-        List<Class<?>> classes = new ArrayList<Class<?>>();
+        List<Class<?>> classes = new ArrayList<>();
         try {
             classes.add(Class.forName(STREAMING_MAIN_CLASS_NAME));
         }
@@ -118,8 +118,7 @@ public class MapReduceActionExecutor extends JavaActionExecutor {
 
     @Override
     protected Configuration createBaseHadoopConf(Context context, Element actionXml, boolean loadResources) {
-        Configuration conf = super.createBaseHadoopConf(context, actionXml, loadResources);
-        return conf;
+        return super.createBaseHadoopConf(context, actionXml, loadResources);
     }
 
     @Override
@@ -242,7 +241,7 @@ public class MapReduceActionExecutor extends JavaActionExecutor {
                     // do not store the action stats
                     if (Boolean.parseBoolean(evaluateConfigurationProperty(actionXml,
                             OOZIE_ACTION_EXTERNAL_STATS_WRITE, "false"))
-                            && (statsJsonString.getBytes().length <= getMaxExternalStatsSize())) {
+                            && (statsJsonString.getBytes(Charsets.UTF_8).length <= getMaxExternalStatsSize())) {
                         context.setExecutionStats(statsJsonString);
                         log.debug(
                                 "Printing stats for Map-Reduce action as a JSON string : [{0}]", statsJsonString);
@@ -339,8 +338,8 @@ public class MapReduceActionExecutor extends JavaActionExecutor {
 
     @Override
     public void check(Context context, WorkflowAction action) throws ActionExecutorException {
-        Map<String, String> actionData = Collections.emptyMap();
-        Configuration jobConf = null;
+        Map<String, String> actionData;
+        Configuration jobConf;
 
         try {
             FileSystem actionFs = context.getAppFileSystem();

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/action/hadoop/SqoopActionExecutor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/action/hadoop/SqoopActionExecutor.java b/core/src/main/java/org/apache/oozie/action/hadoop/SqoopActionExecutor.java
index 69d5e7e..556f2cf 100644
--- a/core/src/main/java/org/apache/oozie/action/hadoop/SqoopActionExecutor.java
+++ b/core/src/main/java/org/apache/oozie/action/hadoop/SqoopActionExecutor.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
 
+import com.google.common.base.Charsets;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.mapred.Counters;
@@ -51,7 +52,7 @@ public class SqoopActionExecutor extends JavaActionExecutor {
 
     @Override
     public List<Class<?>> getLauncherClasses() {
-        List<Class<?>> classes = new ArrayList<Class<?>>();
+        List<Class<?>> classes = new ArrayList<>();
         try {
             classes.add(Class.forName(SQOOP_MAIN_CLASS_NAME));
         }
@@ -182,7 +183,7 @@ public class SqoopActionExecutor extends JavaActionExecutor {
                     // do not store the action stats
                     if (Boolean.parseBoolean(evaluateConfigurationProperty(actionXml,
                             OOZIE_ACTION_EXTERNAL_STATS_WRITE, "true"))
-                            && (statsJsonString.getBytes().length <= getMaxExternalStatsSize())) {
+                            && (statsJsonString.getBytes(Charsets.UTF_8).length <= getMaxExternalStatsSize())) {
                         context.setExecutionStats(statsJsonString);
                         LOG.debug(
                           "Printing stats for sqoop action as a JSON string : [{0}]", statsJsonString);

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/action/ssh/SshActionExecutor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/action/ssh/SshActionExecutor.java b/core/src/main/java/org/apache/oozie/action/ssh/SshActionExecutor.java
index 128feee..1c76a87 100644
--- a/core/src/main/java/org/apache/oozie/action/ssh/SshActionExecutor.java
+++ b/core/src/main/java/org/apache/oozie/action/ssh/SshActionExecutor.java
@@ -20,12 +20,16 @@ package org.apache.oozie.action.ssh;
 
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
 import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.Callable;
+
+import com.google.common.base.Charsets;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.apache.hadoop.util.StringUtils;
 
 import org.apache.oozie.client.WorkflowAction;
@@ -118,11 +122,13 @@ public class SshActionExecutor extends ActionExecutor {
      * @param action action object.
      * @throws org.apache.oozie.action.ActionExecutorException
      */
+    @SuppressFBWarnings(value = {"COMMAND_INJECTION", "PATH_TRAVERSAL_OUT"},
+            justification = "Tracker URI is specified in the WF action, and action dir path is from context")
     @Override
     public void check(Context context, WorkflowAction action) throws ActionExecutorException {
         LOG.trace("check() start for action={0}", action.getId());
         Status status = getActionStatus(context, action);
-        boolean captureOutput = false;
+        boolean captureOutput;
         try {
             Element eConf = XmlUtils.parseXml(action.getConf());
             Namespace ns = eConf.getNamespace();
@@ -228,7 +234,6 @@ public class SshActionExecutor extends ActionExecutor {
             public String call() throws Exception {
                 return setupRemote(host, context, action);
             }
-
         });
 
         String runningPid = execute(new Callable<String>() {
@@ -286,7 +291,6 @@ public class SshActionExecutor extends ActionExecutor {
                         return doExecute(host, dirLocation, commandElement.getValue(), argsF, ignoreOutput, action, recoveryId,
                                 preserveF);
                     }
-
                 });
             }
             context.setStartData(pid, host, host);
@@ -299,14 +303,13 @@ public class SshActionExecutor extends ActionExecutor {
     }
 
     private String checkIfRunning(String host, final Context context, final WorkflowAction action) {
-        String pid = null;
         String outFile = getRemoteFileName(context, action, "pid", false, false);
         String getOutputCmd = SSH_COMMAND_BASE + host + " cat " + outFile;
         try {
             Process process = Runtime.getRuntime().exec(getOutputCmd.split("\\s"));
             StringBuffer buffer = new StringBuffer();
             drainBuffers(process, buffer, null, maxLen);
-            pid = getFirstLine(buffer);
+            String pid = getFirstLine(buffer);
 
             if (Long.valueOf(pid) > 0) {
                 return pid;
@@ -358,9 +361,8 @@ public class SshActionExecutor extends ActionExecutor {
         StringBuffer errorBuffer = new StringBuffer();
         int exitValue = drainBuffers(p, null, errorBuffer, maxLen);
 
-        String error = null;
         if (exitValue != 0) {
-            error = getTruncatedString(errorBuffer);
+            String error = getTruncatedString(errorBuffer);
             throw new IOException(XLog.format("Not able to perform operation [{0}]", command) + " | " + "ErrorStream: "
                     + error);
         }
@@ -444,17 +446,15 @@ public class SshActionExecutor extends ActionExecutor {
 
         LOG.trace("Executing SSH command [finalCommand={0}]", Arrays.toString(finalCommand));
         final Process p = runtime.exec(finalCommand);
-        final String pid;
 
         final StringBuffer inputBuffer = new StringBuffer();
         final StringBuffer errorBuffer = new StringBuffer();
         final int exitValue = drainBuffers(p, inputBuffer, errorBuffer, maxLen);
 
-        pid = getFirstLine(inputBuffer);
+        final String pid = getFirstLine(inputBuffer);
 
-        String error = null;
         if (exitValue != 0) {
-            error = getTruncatedString(errorBuffer);
+            String error = getTruncatedString(errorBuffer);
             throw new IOException(XLog.format("Not able to execute ssh-base.sh on {0}", host) + " | " + "ErrorStream: "
                     + error);
         }
@@ -522,6 +522,7 @@ public class SshActionExecutor extends ActionExecutor {
     /**
      * Copy the ssh base and wrapper scripts to the local directory.
      */
+    @SuppressFBWarnings(value ="PATH_TRAVERSAL_OUT", justification = "Path is created runtime")
     private void initSshScripts() {
         String dirLocation = Services.get().getRuntimeDir() + "/ssh";
         File path = new File(dirLocation);
@@ -530,10 +531,10 @@ public class SshActionExecutor extends ActionExecutor {
             throw new RuntimeException(XLog.format("Not able to create required directory {0}", dirLocation));
         }
         try {
-            IOUtils.copyCharStream(IOUtils.getResourceAsReader("ssh-base.sh", -1), new FileWriter(dirLocation
-                    + "/ssh-base.sh"));
-            IOUtils.copyCharStream(IOUtils.getResourceAsReader("ssh-wrapper.sh", -1), new FileWriter(dirLocation
-                    + "/ssh-wrapper.sh"));
+            IOUtils.copyCharStream(IOUtils.getResourceAsReader("ssh-base.sh", -1), new OutputStreamWriter(
+                    new FileOutputStream(dirLocation + "/ssh-base.sh"), Charsets.UTF_8));
+            IOUtils.copyCharStream(IOUtils.getResourceAsReader("ssh-wrapper.sh", -1), new OutputStreamWriter(
+                    new FileOutputStream(dirLocation + "/ssh-wrapper.sh"), Charsets.UTF_8));
         }
         catch (IOException ie) {
             throw new RuntimeException(XLog.format("Not able to copy required scripts file to {0} "
@@ -719,7 +720,6 @@ public class SshActionExecutor extends ActionExecutor {
      * @return truncated string string
      */
     private String getTruncatedString(StringBuffer strBuffer) {
-
         if (strBuffer.length() <= maxLen) {
             return strBuffer.toString();
         }
@@ -743,15 +743,14 @@ public class SshActionExecutor extends ActionExecutor {
     private int drainBuffers(Process p, StringBuffer inputBuffer, StringBuffer errorBuffer, int maxLength)
             throws IOException {
         int exitValue = -1;
-        BufferedReader ir = new BufferedReader(new InputStreamReader(p.getInputStream()));
-        BufferedReader er = new BufferedReader(new InputStreamReader(p.getErrorStream()));
 
         int inBytesRead = 0;
         int errBytesRead = 0;
 
         boolean processEnded = false;
 
-        try {
+        try (BufferedReader ir = new BufferedReader(new InputStreamReader(p.getInputStream(), Charsets.UTF_8));
+             BufferedReader er = new BufferedReader(new InputStreamReader(p.getErrorStream(), Charsets.UTF_8))) {
             while (!processEnded) {
                 try {
                     exitValue = p.waitFor();
@@ -766,11 +765,6 @@ public class SshActionExecutor extends ActionExecutor {
                 errBytesRead += drainBuffer(er, errorBuffer, maxLength, errBytesRead, processEnded);
             }
         }
-        finally {
-            ir.close();
-            er.close();
-        }
-
         return exitValue;
     }
 
@@ -810,8 +804,7 @@ public class SshActionExecutor extends ActionExecutor {
      * @return The first line of the buffer.
      */
     private String getFirstLine(StringBuffer buffer) {
-        int newLineIndex = 0;
-        newLineIndex = buffer.indexOf("\n");
+        int newLineIndex = buffer.indexOf("\n");
         if (newLineIndex == -1) {
             return buffer.toString();
         }

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/command/bundle/BundleSubmitXCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/command/bundle/BundleSubmitXCommand.java b/core/src/main/java/org/apache/oozie/command/bundle/BundleSubmitXCommand.java
index 80e7d5d..f94e871 100644
--- a/core/src/main/java/org/apache/oozie/command/bundle/BundleSubmitXCommand.java
+++ b/core/src/main/java/org/apache/oozie/command/bundle/BundleSubmitXCommand.java
@@ -34,6 +34,7 @@ import java.util.Set;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.Validator;
 
+import com.google.common.base.Charsets;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -80,8 +81,8 @@ public class BundleSubmitXCommand extends SubmitTransitionXCommand {
     public static final String BUNDLE_XML_FILE = "bundle.xml";
     private final BundleJobBean bundleBean = new BundleJobBean();
     private String jobId;
-    private static final Set<String> DISALLOWED_USER_PROPERTIES = new HashSet<String>();
-    private static final Set<String> DISALLOWED_DEFAULT_PROPERTIES = new HashSet<String>();
+    private static final Set<String> DISALLOWED_USER_PROPERTIES = new HashSet<>();
+    private static final Set<String> DISALLOWED_DEFAULT_PROPERTIES = new HashSet<>();
 
     static {
         String[] badUserProps = { PropertiesUtils.YEAR, PropertiesUtils.MONTH, PropertiesUtils.DAY,
@@ -159,8 +160,8 @@ public class BundleSubmitXCommand extends SubmitTransitionXCommand {
                 catch (IOException e1) {
                     LOG.warn("Configuration parse error. read from DB :" + bundleBean.getConf(), e1);
                 }
-                String output = bundleBean.getJobXml() + System.getProperty("line.separator");
-                return output;
+
+                return bundleBean.getJobXml() + System.getProperty("line.separator");
             }
             else {
                 if (bundleBean.getKickoffTime() == null) {
@@ -297,7 +298,7 @@ public class BundleSubmitXCommand extends SubmitTransitionXCommand {
             HadoopAccessorService has = Services.get().get(HadoopAccessorService.class);
             Configuration fsConf = has.createConfiguration(uri.getAuthority());
             FileSystem fs = has.createFileSystem(user, uri, fsConf);
-            Path appDefPath = null;
+            Path appDefPath;
 
             // app path could be a directory
             Path path = new Path(uri.getPath());
@@ -307,7 +308,7 @@ public class BundleSubmitXCommand extends SubmitTransitionXCommand {
                 appDefPath = path;
             }
 
-            Reader reader = new InputStreamReader(fs.open(appDefPath));
+            Reader reader = new InputStreamReader(fs.open(appDefPath), Charsets.UTF_8);
             StringWriter writer = new StringWriter();
             IOUtils.copyCharStream(reader, writer);
             return writer.toString();
@@ -353,7 +354,7 @@ public class BundleSubmitXCommand extends SubmitTransitionXCommand {
     /**
      * Write a Bundle Job into database
      *
-     * @param Bundle job bean
+     * @param bundleJob job bean
      * @return job id
      * @throws CommandException thrown if failed to store bundle job bean to db
      */
@@ -456,19 +457,19 @@ public class BundleSubmitXCommand extends SubmitTransitionXCommand {
     /**
      * Verify the uniqueness of coordinator names
      *
-     * @param resolved job xml
+     * @param resolvedJobXml job xml
      * @throws CommandException thrown if failed to verify the uniqueness of coordinator names
      */
     @SuppressWarnings("unchecked")
     private Void verifyCoordNameUnique(String resolvedJobXml) throws CommandException {
-        Set<String> set = new HashSet<String>();
+        Set<String> set = new HashSet<>();
         try {
             Element bAppXml = XmlUtils.parseXml(resolvedJobXml);
             List<Element> coordElems = bAppXml.getChildren("coordinator", bAppXml.getNamespace());
             for (Element elem : coordElems) {
                 Attribute name = elem.getAttribute("name");
                 if (name != null) {
-                    String coordName = name.getValue();
+                    String coordName;
                     try {
                         coordName = ELUtils.resolveAppName(name.getValue(), conf);
                     }

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java b/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java
index 8bfa634..2e25e03 100644
--- a/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java
+++ b/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java
@@ -39,6 +39,7 @@ import java.util.TreeSet;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.Validator;
 
+import com.google.common.base.Charsets;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -113,8 +114,8 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
     public final String COORD_INPUT_EVENTS_DATA_IN ="data-in";
     public final String COORD_OUTPUT_EVENTS_DATA_OUT = "data-out";
 
-    private static final Set<String> DISALLOWED_USER_PROPERTIES = new HashSet<String>();
-    private static final Set<String> DISALLOWED_DEFAULT_PROPERTIES = new HashSet<String>();
+    private static final Set<String> DISALLOWED_USER_PROPERTIES = new HashSet<>();
+    private static final Set<String> DISALLOWED_DEFAULT_PROPERTIES = new HashSet<>();
 
     protected CoordinatorJobBean coordJob = null;
     /**
@@ -206,7 +207,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
     }
 
     protected String submitJob() throws CommandException {
-        String jobId = null;
+        String jobId;
         InstrumentUtils.incrJobCounter(getName(), 1, getInstrumentation());
 
         boolean exceptionOccured = false;
@@ -315,9 +316,8 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
         }
         String action = new CoordMaterializeTransitionXCommand(coordJob, materializationWindow, startTime,
                 endTime).materializeActions(true);
-        String output = coordJob.getJobXml() + System.getProperty("line.separator")
-        + "***actions for instance***" + action;
-        return output;
+
+        return coordJob.getJobXml() + System.getProperty("line.separator") + "***actions for instance***" + action;
     }
 
     /**
@@ -488,6 +488,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
         throw new CoordinatorJobException(ErrorCode.E1021, eventType + " end-instance '" + instanceValue
                 + "' contains more than one date end-instance. Coordinator job NOT SUBMITTED. " + correctAction);
     }
+
     /**
      * Read the application XML and validate against coordinator Schema
      *
@@ -606,7 +607,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
      * @throws Exception thrown if failed to resolve basic entities or include referred datasets
      */
     public Element basicResolveAndIncludeDS(String appXml, Configuration conf, CoordinatorJobBean coordJob)
-    throws CoordinatorJobException, Exception {
+            throws Exception {
         Element basicResolvedApp = resolveInitial(conf, appXml, coordJob);
         includeDataSets(basicResolvedApp, conf);
         return basicResolvedApp;
@@ -666,7 +667,6 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
         evalAction = CoordELEvaluator.createELEvaluatorForGroup(conf, "coord-action-start");
         evalTimeout = CoordELEvaluator.createELEvaluatorForGroup(conf, "coord-job-wait-timeout");
         evalInitialInstance = CoordELEvaluator.createELEvaluatorForGroup(conf, "coord-job-submit-initial-instance");
-
     }
 
     /**
@@ -681,12 +681,11 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
      */
     @SuppressWarnings("unchecked")
     protected Element resolveInitial(Configuration conf, String appXml, CoordinatorJobBean coordJob)
-    throws CoordinatorJobException, Exception {
+            throws Exception {
         Element eAppXml = XmlUtils.parseXml(appXml);
         // job's main attributes
         // frequency
         String val = resolveAttribute("frequency", eAppXml, evalFreq);
-        int ival = 0;
 
         val = ParamChecker.checkFrequency(val);
         coordJob.setFrequency(val);
@@ -755,7 +754,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
             val = ConfigurationService.get(CONF_DEFAULT_TIMEOUT_NORMAL);
         }
 
-        ival = ParamChecker.checkInteger(val, "timeout");
+        int ival = ParamChecker.checkInteger(val, "timeout");
         if (ival < 0 || ival > ConfigurationService.getInt(CONF_DEFAULT_MAX_TIMEOUT)) {
             ival = ConfigurationService.getInt(CONF_DEFAULT_MAX_TIMEOUT);
         }
@@ -770,8 +769,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
 
         val = resolveTagContents("throttle", eAppXml.getChild("controls", eAppXml.getNamespace()), evalNofuncs);
         if (val == null || val.isEmpty()) {
-            int defaultThrottle = ConfigurationService.getInt(CONF_DEFAULT_THROTTLE);
-            ival = defaultThrottle;
+            ival = ConfigurationService.getInt(CONF_DEFAULT_THROTTLE);
         }
         else {
             ival = ParamChecker.checkInteger(val, "throttle");
@@ -887,7 +885,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
         Element eJob = (Element) eJobOrg.clone();
         Element inputList = eJob.getChild("input-events", eJob.getNamespace());
         if (inputList != null) {
-            TreeSet<String> eventNameSet = new TreeSet<String>();
+            TreeSet<String> eventNameSet = new TreeSet<>();
             for (Element dataIn : (List<Element>) inputList.getChildren("data-in", eJob.getNamespace())) {
                 String dataInName = dataIn.getAttributeValue("name");
                 dataNameList.put(dataInName, "data-in");
@@ -907,7 +905,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
         // Resolving output-events/data-out
         Element outputList = eJob.getChild("output-events", eJob.getNamespace());
         if (outputList != null) {
-            TreeSet<String> eventNameSet = new TreeSet<String>();
+            TreeSet<String> eventNameSet = new TreeSet<>();
             for (Element dataOut : (List<Element>) outputList.getChildren("data-out", eJob.getNamespace())) {
                 String dataOutName = dataOut.getAttributeValue("name");
                 dataNameList.put(dataOutName, "data-out");
@@ -948,7 +946,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
     /**
      * Resolve input-events/dataset and output-events/dataset tags.
      *
-     * @param eJob : Job element
+     * @param eAppXml : Job element
      * @throws CoordinatorJobException thrown if failed to resolve input and output events
      */
     @SuppressWarnings("unchecked")
@@ -966,10 +964,8 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
         if (outputList != null) {
             for (Element dataOut : (List<Element>) outputList.getChildren("data-out", eAppXml.getNamespace())) {
                 resolveAttribute("dataset", dataOut, evalInst);
-
             }
         }
-
     }
 
 
@@ -994,7 +990,6 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
     private void resolveDataSets(Element eAppXml) throws Exception {
         Element datasetList = eAppXml.getChild("datasets", eAppXml.getNamespace());
         if (datasetList != null) {
-
             List<Element> dsElems = datasetList.getChildren("dataset", eAppXml.getNamespace());
             resolveDataSets(dsElems);
             resolveTagContents("app-path", eAppXml.getChild("action", eAppXml.getNamespace()).getChild("workflow",
@@ -1018,9 +1013,9 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
             int ival = ParamChecker.checkInteger(val, "frequency");
             ParamChecker.checkGTZero(ival, "frequency");
             addAnAttribute("freq_timeunit", dsElem, evalFreq.getVariable("timeunit") == null ? TimeUnit.MINUTE
-                    .toString() : ((TimeUnit) evalFreq.getVariable("timeunit")).toString());
+                    .toString() : evalFreq.getVariable("timeunit").toString());
             addAnAttribute("end_of_duration", dsElem, evalFreq.getVariable("endOfDuration") == null ? TimeUnit.NONE
-                    .toString() : ((TimeUnit) evalFreq.getVariable("endOfDuration")).toString());
+                    .toString() : evalFreq.getVariable("endOfDuration").toString());
             val = resolveAttribute("initial-instance", dsElem, evalInitialInstance);
             ParamChecker.checkDateOozieTZ(val, "initial-instance");
             checkInitialInstance(val);
@@ -1098,7 +1093,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
     protected void includeDataSets(Element resolvedXml, Configuration conf) throws CoordinatorJobException {
         Element datasets = resolvedXml.getChild("datasets", resolvedXml.getNamespace());
         Element allDataSets = new Element("all_datasets", resolvedXml.getNamespace());
-        List<String> dsList = new ArrayList<String>();
+        List<String> dsList = new ArrayList<>();
         if (datasets != null) {
             for (Element includeElem : (List<Element>) datasets.getChildren("include", datasets.getNamespace())) {
                 String incDSFile = includeElem.getTextTrim();
@@ -1132,7 +1127,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
     @SuppressWarnings("unchecked")
     private void includeOneDSFile(String incDSFile, List<String> dsList, Element allDataSets, Namespace dsNameSpace)
     throws CoordinatorJobException {
-        Element tmpDataSets = null;
+        Element tmpDataSets;
         try {
             String dsXml = readDefinition(incDSFile);
             LOG.debug("DSFILE :" + incDSFile + "\n" + dsXml);
@@ -1198,7 +1193,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
             HadoopAccessorService has = Services.get().get(HadoopAccessorService.class);
             Configuration fsConf = has.createConfiguration(uri.getAuthority());
             FileSystem fs = has.createFileSystem(user, uri, fsConf);
-            Path appDefPath = null;
+            Path appDefPath;
 
             // app path could be a directory
             Path path = new Path(uri.getPath());
@@ -1212,7 +1207,7 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
                 appDefPath = path;
             }
 
-            Reader reader = new InputStreamReader(fs.open(appDefPath));
+            Reader reader = new InputStreamReader(fs.open(appDefPath), Charsets.UTF_8);
             StringWriter writer = new StringWriter();
             IOUtils.copyCharStream(reader, writer);
             return writer.toString();
@@ -1319,12 +1314,10 @@ public class CoordSubmitXCommand extends SubmitTransitionXCommand {
             coordJob.setAppName(this.coordName);
         }
         setJob(coordJob);
-
     }
 
     @Override
     protected void verifyPrecondition() throws CommandException {
-
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/command/coord/CoordUpdateXCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/command/coord/CoordUpdateXCommand.java b/core/src/main/java/org/apache/oozie/command/coord/CoordUpdateXCommand.java
index 502a800..9efff12 100644
--- a/core/src/main/java/org/apache/oozie/command/coord/CoordUpdateXCommand.java
+++ b/core/src/main/java/org/apache/oozie/command/coord/CoordUpdateXCommand.java
@@ -16,7 +16,6 @@
  * limitations under the License.
  */
 
-
 package org.apache.oozie.command.coord;
 
 import java.io.ByteArrayOutputStream;
@@ -24,6 +23,7 @@ import java.io.IOException;
 import java.io.StringReader;
 import java.util.Date;
 
+import com.google.common.base.Charsets;
 import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.oozie.CoordinatorJobBean;
@@ -65,14 +65,14 @@ public class CoordUpdateXCommand extends CoordSubmitXCommand {
     public CoordUpdateXCommand(boolean dryrun, Configuration conf, String jobId) {
         super(dryrun, conf);
         this.jobId = jobId;
-        isConfChange = conf.size() == 0 ? false : true;
+        isConfChange = conf.size() != 0;
     }
 
     public CoordUpdateXCommand(boolean dryrun, Configuration conf, String jobId, boolean showDiff) {
         super(dryrun, conf);
         this.jobId = jobId;
         this.showDiff = showDiff;
-        isConfChange = conf.size() == 0 ? false : true;
+        isConfChange = conf.size() != 0;
     }
 
     @Override
@@ -90,7 +90,6 @@ public class CoordUpdateXCommand extends CoordSubmitXCommand {
         oldCoordJob.setTimeout(coordJob.getTimeout());
         oldCoordJob.setJobXml(XmlUtils.prettyPrint(eJob).toString());
 
-
         if (!dryrun) {
             oldCoordJob.setLastModifiedTime(new Date());
             // Should log the changes, this should be useful for debugging.
@@ -146,7 +145,6 @@ public class CoordUpdateXCommand extends CoordSubmitXCommand {
         coordJob.setConf(XmlUtils.prettyPrint(conf).toString());
         setJob(coordJob);
         LogUtils.setLogInfo(coordJob);
-
     }
 
     @Override
@@ -164,7 +162,6 @@ public class CoordUpdateXCommand extends CoordSubmitXCommand {
      * @param eJob the e job
      * @return the diff
      */
-
     private void computeDiff(Element eJob) {
         try {
             diff.append("**********Job definition changes**********").append(System.getProperty("line.separator"));
@@ -195,12 +192,12 @@ public class CoordUpdateXCommand extends CoordSubmitXCommand {
      */
     private String getDiffinGitFormat(String string1, String string2) throws IOException {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        RawText rt1 = new RawText(string1.getBytes());
-        RawText rt2 = new RawText(string2.getBytes());
+        RawText rt1 = new RawText(string1.getBytes(Charsets.UTF_8));
+        RawText rt2 = new RawText(string2.getBytes(Charsets.UTF_8));
         EditList diffList = new EditList();
         diffList.addAll(new HistogramDiff().diff(RawTextComparator.DEFAULT, rt1, rt2));
         new DiffFormatter(out).format(diffList, rt1, rt2);
-        return out.toString();
+        return out.toString(Charsets.UTF_8.name());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/service/AuthorizationService.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/service/AuthorizationService.java b/core/src/main/java/org/apache/oozie/service/AuthorizationService.java
index 251838c..6f72c41 100644
--- a/core/src/main/java/org/apache/oozie/service/AuthorizationService.java
+++ b/core/src/main/java/org/apache/oozie/service/AuthorizationService.java
@@ -21,17 +21,16 @@ package org.apache.oozie.service;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.net.URI;
-import java.nio.charset.StandardCharsets;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.ArrayList;
 import java.util.Set;
 import java.util.LinkedHashSet;
+
+import com.google.common.base.Charsets;
 import com.google.common.collect.Sets;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang.StringUtils;
@@ -140,14 +139,14 @@ public class AuthorizationService implements Service {
             String[] str = getTrimmedStrings(Services.get().getConf().get(CONF_ADMIN_GROUPS));
             if (str.length > 0) {
                 log.info("Admin users will be checked against the defined admin groups");
-                adminGroups = new HashSet<String>();
+                adminGroups = new HashSet<>();
                 for (String s : str) {
                     adminGroups.add(s.trim());
                 }
             }
             else {
                 log.info("Admin users will be checked against the 'adminusers.txt' file contents");
-                adminUsers = new HashSet<String>();
+                adminUsers = new HashSet<>();
                 loadAdminUsersFromFile();
                 loadAdminUsersFromConfiguration();
             }
@@ -194,7 +193,7 @@ public class AuthorizationService implements Service {
             if (file.exists()) {
                 try {
                     BufferedReader br = new BufferedReader(
-                            new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
+                            new InputStreamReader(new FileInputStream(file), Charsets.UTF_8));
                     try {
                         String line = br.readLine();
                         while (line != null) {
@@ -486,7 +485,7 @@ public class AuthorizationService implements Service {
             try {
                 // handle workflow jobs
                 if (jobId.endsWith("-W")) {
-                    WorkflowJobBean jobBean = null;
+                    WorkflowJobBean jobBean;
                     JPAService jpaService = Services.get().get(JPAService.class);
                     if (jpaService != null) {
                         try {
@@ -530,7 +529,7 @@ public class AuthorizationService implements Service {
                 }
                 // handle coordinator jobs
                 else {
-                    CoordinatorJobBean jobBean = null;
+                    CoordinatorJobBean jobBean;
                     JPAService jpaService = Services.get().get(JPAService.class);
                     if (jpaService != null) {
                         try {
@@ -573,76 +572,74 @@ public class AuthorizationService implements Service {
         if (authorizationEnabled && write && !isAdmin(user)) {
             try {
                 // handle workflow jobs
-                if (jobType.equals("wf")) {
-                    List<WorkflowJobBean> jobBeans = new ArrayList<WorkflowJobBean>();
-                    JPAService jpaService = Services.get().get(JPAService.class);
-                    if (jpaService != null) {
-                        try {
-                            jobBeans = jpaService.execute(new WorkflowsJobGetJPAExecutor(
-                                    filter, start, len)).getWorkflows();
-                        }
-                        catch (JPAExecutorException je) {
-                            throw new AuthorizationException(je);
+                switch (jobType) {
+                    case "wf": {
+                        List<WorkflowJobBean> jobBeans;
+                        JPAService jpaService = Services.get().get(JPAService.class);
+                        if (jpaService != null) {
+                            try {
+                                jobBeans = jpaService.execute(new WorkflowsJobGetJPAExecutor(
+                                        filter, start, len)).getWorkflows();
+                            } catch (JPAExecutorException je) {
+                                throw new AuthorizationException(je);
+                            }
+                        } else {
+                            throw new AuthorizationException(ErrorCode.E0610);
                         }
-                    }
-                    else {
-                        throw new AuthorizationException(ErrorCode.E0610);
-                    }
-                    for (WorkflowJobBean jobBean : jobBeans) {
-                        if (jobBean != null && !jobBean.getUser().equals(user)) {
-                            if (!isUserInAcl(user, jobBean.getGroup())) {
+                        for (WorkflowJobBean jobBean : jobBeans) {
+                            if (jobBean != null && !jobBean.getUser().equals(user)) {
+                                if (!isUserInAcl(user, jobBean.getGroup())) {
                                     incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
-                                throw new AuthorizationException(ErrorCode.E0508, user, jobBean.getId());
+                                    throw new AuthorizationException(ErrorCode.E0508, user, jobBean.getId());
+                                }
                             }
                         }
+                        break;
                     }
-                }
-                // handle bundle jobs
-                else if (jobType.equals("bundle")) {
-                    List<BundleJobBean> jobBeans = new ArrayList<BundleJobBean>();
-                    JPAService jpaService = Services.get().get(JPAService.class);
-                    if (jpaService != null) {
-                        try {
-                            jobBeans = jpaService.execute(new BundleJobInfoGetJPAExecutor(
-                                    filter, start, len)).getBundleJobs();
-                        }
-                        catch (JPAExecutorException je) {
-                            throw new AuthorizationException(je);
+                    // handle bundle jobs
+                    case "bundle": {
+                        List<BundleJobBean> jobBeans;
+                        JPAService jpaService = Services.get().get(JPAService.class);
+                        if (jpaService != null) {
+                            try {
+                                jobBeans = jpaService.execute(new BundleJobInfoGetJPAExecutor(
+                                        filter, start, len)).getBundleJobs();
+                            } catch (JPAExecutorException je) {
+                                throw new AuthorizationException(je);
+                            }
+                        } else {
+                            throw new AuthorizationException(ErrorCode.E0610);
                         }
-                    }
-                    else {
-                        throw new AuthorizationException(ErrorCode.E0610);
-                    }
-                    for (BundleJobBean jobBean : jobBeans){
-                        if (jobBean != null && !jobBean.getUser().equals(user)) {
-                            if (!isUserInAcl(user, jobBean.getGroup())) {
-                                incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
-                                throw new AuthorizationException(ErrorCode.E0509, user, jobBean.getId());
+                        for (BundleJobBean jobBean : jobBeans) {
+                            if (jobBean != null && !jobBean.getUser().equals(user)) {
+                                if (!isUserInAcl(user, jobBean.getGroup())) {
+                                    incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
+                                    throw new AuthorizationException(ErrorCode.E0509, user, jobBean.getId());
+                                }
                             }
                         }
+                        break;
                     }
-                }
-                // handle coordinator jobs
-                else {
-                    List<CoordinatorJobBean> jobBeans = new ArrayList<CoordinatorJobBean>();
-                    JPAService jpaService = Services.get().get(JPAService.class);
-                    if (jpaService != null) {
-                        try {
-                            jobBeans = jpaService.execute(new CoordJobInfoGetJPAExecutor(
-                                    filter, start, len)).getCoordJobs();
-                        }
-                        catch (JPAExecutorException je) {
-                            throw new AuthorizationException(je);
+                    // handle coordinator jobs
+                    default: {
+                        List<CoordinatorJobBean> jobBeans;
+                        JPAService jpaService = Services.get().get(JPAService.class);
+                        if (jpaService != null) {
+                            try {
+                                jobBeans = jpaService.execute(new CoordJobInfoGetJPAExecutor(
+                                        filter, start, len)).getCoordJobs();
+                            } catch (JPAExecutorException je) {
+                                throw new AuthorizationException(je);
+                            }
+                        } else {
+                            throw new AuthorizationException(ErrorCode.E0610);
                         }
-                    }
-                    else {
-                        throw new AuthorizationException(ErrorCode.E0610);
-                    }
-                    for (CoordinatorJobBean jobBean : jobBeans) {
-                        if (jobBean != null && !jobBean.getUser().equals(user)) {
-                            if (!isUserInAcl(user, jobBean.getGroup())) {
-                                incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
-                                throw new AuthorizationException(ErrorCode.E0509, user, jobBean.getId());
+                        for (CoordinatorJobBean jobBean : jobBeans) {
+                            if (jobBean != null && !jobBean.getUser().equals(user)) {
+                                if (!isUserInAcl(user, jobBean.getGroup())) {
+                                    incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
+                                    throw new AuthorizationException(ErrorCode.E0509, user, jobBean.getId());
+                                }
                             }
                         }
                     }

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/service/WorkflowAppService.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/service/WorkflowAppService.java b/core/src/main/java/org/apache/oozie/service/WorkflowAppService.java
index c725f49..17d1d2e 100644
--- a/core/src/main/java/org/apache/oozie/service/WorkflowAppService.java
+++ b/core/src/main/java/org/apache/oozie/service/WorkflowAppService.java
@@ -18,6 +18,7 @@
 
 package org.apache.oozie.service;
 
+import com.google.common.base.Charsets;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
@@ -104,7 +105,6 @@ public abstract class WorkflowAppService implements Service {
     /**
      * Read workflow definition.
      *
-     *
      * @param appPath application path.
      * @param user user name.
      * @return workflow definition.
@@ -129,7 +129,7 @@ public abstract class WorkflowAppService implements Service {
                 throw new WorkflowException(ErrorCode.E0736, fsStatus.getLen(), this.maxWFLength);
             }
 
-            Reader reader = new InputStreamReader(fs.open(path));
+            Reader reader = new InputStreamReader(fs.open(path), Charsets.UTF_8);
             StringWriter writer = new StringWriter();
             IOUtils.copyCharStream(reader, writer);
             return writer.toString();
@@ -151,6 +151,7 @@ public abstract class WorkflowAppService implements Service {
             throw new WorkflowException(ErrorCode.E0710, ex.getMessage(), ex);
         }
     }
+
     /**
      * Create proto configuration. <p> The proto configuration includes the user,group and the paths which need to be
      * added to distributed cache. These paths include .jar,.so and the resource file paths.
@@ -169,7 +170,6 @@ public abstract class WorkflowAppService implements Service {
             Configuration conf = has.createConfiguration(uri.getAuthority());
             XConfiguration protoConf = new XConfiguration();
 
-
             String user = jobConf.get(OozieClient.USER_NAME);
             conf.set(OozieClient.USER_NAME, user);
             protoConf.set(OozieClient.USER_NAME, user);
@@ -191,15 +191,15 @@ public abstract class WorkflowAppService implements Service {
                 }
             }
             else {
-                filePaths = new LinkedHashSet<String>();
+                filePaths = new LinkedHashSet<>();
             }
 
             String[] libPaths = jobConf.getStrings(OozieClient.LIBPATH);
             if (libPaths != null && libPaths.length > 0) {
-                for (int i = 0; i < libPaths.length; i++) {
-                    if (libPaths[i].trim().length() > 0) {
-                        Path libPath = new Path(libPaths[i].trim());
-                        Collection<String> libFilePaths = getLibFiles(fs, libPath);
+                for (String libPath : libPaths) {
+                    if (libPath.trim().length() > 0) {
+                        Path path = new Path(libPath.trim());
+                        Collection<String> libFilePaths = getLibFiles(fs, path);
                         filePaths.addAll(libFilePaths);
                     }
                 }
@@ -218,7 +218,7 @@ public abstract class WorkflowAppService implements Service {
                         filePathsNames[i] = p.getName();
                     }
                     Arrays.sort(filePathsNames);
-                    List<String> nonDuplicateParentFilePaths = new ArrayList<String>();
+                    List<String> nonDuplicateParentFilePaths = new ArrayList<>();
                     for (String parentFilePath : parentFilePaths) {
                         Path p = new Path(parentFilePath);
                         if (Arrays.binarySearch(filePathsNames, p.getName()) < 0) {
@@ -297,7 +297,7 @@ public abstract class WorkflowAppService implements Service {
      * @throws IOException thrown if the lib paths could not be obtained.
      */
     private Collection<String> getLibFiles(FileSystem fs, Path libPath) throws IOException {
-        Set<String> libPaths = new LinkedHashSet<String>();
+        Set<String> libPaths = new LinkedHashSet<>();
         if (fs.exists(libPath)) {
             FileStatus[] files = fs.listStatus(libPath, new NoPathFilter());
 

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java b/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
index 361141b..9acd571 100644
--- a/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
+++ b/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
@@ -26,6 +26,7 @@ import javax.servlet.ServletInputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.google.common.base.Charsets;
 import com.google.common.base.Strings;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.oozie.*;
@@ -49,7 +50,6 @@ import org.apache.oozie.util.graph.OutputFormat;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 
-
 @SuppressWarnings("serial")
 public class V1JobServlet extends BaseJobServlet {
 
@@ -58,7 +58,6 @@ public class V1JobServlet extends BaseJobServlet {
 
     final static String NOT_SUPPORTED_MESSAGE = "Not supported in v1";
 
-
     public V1JobServlet() {
         super(INSTRUMENTATION_NAME);
     }
@@ -91,7 +90,6 @@ public class V1JobServlet extends BaseJobServlet {
             throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0303, RestConstants.ACTION_PARAM,
                     RestConstants.JOB_ACTION_START);
         }
-
     }
 
     /*
@@ -227,10 +225,10 @@ public class V1JobServlet extends BaseJobServlet {
         ServletInputStream is = request.getInputStream();
         byte[] b = new byte[101];
         while (is.readLine(b, 0, 100) != -1) {
-            XLog.getLog(getClass()).warn("Printing :" + new String(b));
+            XLog.getLog(getClass()).warn("Printing :" + new String(b, Charsets.UTF_8));
         }
 
-        JsonBean jobBean = null;
+        JsonBean jobBean;
         String jobId = getResourceName(request);
         if (jobId.endsWith("-B")) {
             jobBean = getBundleJob(request, response);
@@ -591,10 +589,7 @@ public class V1JobServlet extends BaseJobServlet {
                 coordEngine.kill(jobId);
             }
         }
-        catch (CoordinatorEngineException ex) {
-            throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
-        }
-        catch (CommandException ex) {
+        catch (CoordinatorEngineException | CommandException ex) {
             throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
         }
         return json;
@@ -690,7 +685,6 @@ public class V1JobServlet extends BaseJobServlet {
      */
     private void rerunBundleJob(HttpServletRequest request, HttpServletResponse response, Configuration conf)
             throws XServletException {
-        JSONObject json = new JSONObject();
         BundleEngine bundleEngine = Services.get().get(BundleEngineService.class).getBundleEngine(getUser(request));
         String jobId = getResourceName(request);
 
@@ -753,18 +747,13 @@ public class V1JobServlet extends BaseJobServlet {
             }
             json.put(JsonTags.COORDINATOR_ACTIONS, CoordinatorActionBean.toJSONArray(coordActions, "GMT"));
         }
-        catch (BaseEngineException ex) {
-            throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
-        }
-        catch (CommandException ex) {
+        catch (BaseEngineException | CommandException ex) {
             throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
         }
 
         return json;
     }
 
-
-
     /**
      * Get workflow job
      *
@@ -789,7 +778,7 @@ public class V1JobServlet extends BaseJobServlet {
      * @throws XServletException
      */
     protected JsonBean getWorkflowJobBean(HttpServletRequest request, HttpServletResponse response) throws XServletException {
-        JsonBean jobBean = null;
+        JsonBean jobBean;
         String jobId = getResourceName(request);
         String startStr = request.getParameter(RestConstants.OFFSET_PARAM);
         String lenStr = request.getParameter(RestConstants.LEN_PARAM);
@@ -829,7 +818,7 @@ public class V1JobServlet extends BaseJobServlet {
     }
 
     private String getConsoleBase(String url) {
-        String consoleBase = null;
+        String consoleBase;
         if (url.indexOf("application") != -1) {
             consoleBase = url.split("application_[0-9]+_[0-9]+")[0];
         }
@@ -849,7 +838,6 @@ public class V1JobServlet extends BaseJobServlet {
      */
     protected JsonBean getWorkflowAction(HttpServletRequest request, HttpServletResponse response)
             throws XServletException {
-
         JsonBean actionBean = getWorkflowActionBean(request, response);
         // for backward compatibility (OOZIE-1231)
         swapMRActionID((WorkflowAction)actionBean);
@@ -882,7 +870,7 @@ public class V1JobServlet extends BaseJobServlet {
      */
     protected JsonBean getCoordinatorJob(HttpServletRequest request, HttpServletResponse response)
             throws XServletException, BaseEngineException {
-        JsonBean jobBean = null;
+        JsonBean jobBean;
         CoordinatorEngine coordEngine = Services.get().get(CoordinatorEngineService.class).getCoordinatorEngine(
                 getUser(request));
         String jobId = getResourceName(request);
@@ -931,12 +919,12 @@ public class V1JobServlet extends BaseJobServlet {
      */
     private JsonBean getBundleJob(HttpServletRequest request, HttpServletResponse response) throws XServletException,
             BaseEngineException {
-        JsonBean jobBean = null;
+        JsonBean jobBean;
         BundleEngine bundleEngine = Services.get().get(BundleEngineService.class).getBundleEngine(getUser(request));
         String jobId = getResourceName(request);
 
         try {
-            jobBean = (JsonBean) bundleEngine.getBundleJob(jobId);
+            jobBean = bundleEngine.getBundleJob(jobId);
 
             return jobBean;
         }
@@ -956,7 +944,7 @@ public class V1JobServlet extends BaseJobServlet {
      */
     private JsonBean getCoordinatorAction(HttpServletRequest request, HttpServletResponse response)
             throws XServletException, BaseEngineException {
-        JsonBean actionBean = null;
+        JsonBean actionBean;
         CoordinatorEngine coordEngine = Services.get().get(CoordinatorEngineService.class).getCoordinatorEngine(
                 getUser(request));
         String actionId = getResourceName(request);
@@ -1098,10 +1086,7 @@ public class V1JobServlet extends BaseJobServlet {
         try {
             coordEngine.streamLog(jobId, logRetrievalScope, logRetrievalType, response.getWriter(), request.getParameterMap());
         }
-        catch (BaseEngineException ex) {
-            throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
-        }
-        catch (CommandException ex) {
+        catch (BaseEngineException | CommandException ex) {
             throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
         }
     }

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/servlet/V2ValidateServlet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/servlet/V2ValidateServlet.java b/core/src/main/java/org/apache/oozie/servlet/V2ValidateServlet.java
index 36a9de2..8a0da93 100644
--- a/core/src/main/java/org/apache/oozie/servlet/V2ValidateServlet.java
+++ b/core/src/main/java/org/apache/oozie/servlet/V2ValidateServlet.java
@@ -18,6 +18,7 @@
 
 package org.apache.oozie.servlet;
 
+import com.google.common.base.Charsets;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -55,7 +56,6 @@ public class V2ValidateServlet extends JsonRestServlet {
                     new ParameterInfo(RestConstants.USER_PARAM, String.class, true, Arrays.asList("POST"))));
     public static final String VALID_WORKFLOW_APP = "Valid workflow-app";
 
-
     public V2ValidateServlet() {
         super(INSTRUMENTATION_NAME, RESOURCE_INFO);
     }
@@ -82,15 +82,14 @@ public class V2ValidateServlet extends JsonRestServlet {
                 FileSystem fs = has.createFileSystem(user, uri, fsConf);
 
                 Path path = new Path(uri.getPath());
-                IOUtils.copyCharStream(new InputStreamReader(fs.open(path)), stringWriter);
-
+                IOUtils.copyCharStream(new InputStreamReader(fs.open(path), Charsets.UTF_8), stringWriter);
             } catch (Exception e) {
                 throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0505,
                         "File does not exist, "+ file);
             }
         }
         else {
-            IOUtils.copyCharStream(new InputStreamReader(request.getInputStream()), stringWriter);
+            IOUtils.copyCharStream(new InputStreamReader(request.getInputStream(), Charsets.UTF_8), stringWriter);
         }
         try {
             validate(stringWriter.toString());
@@ -147,5 +146,4 @@ public class V2ValidateServlet extends JsonRestServlet {
         jsonObject.put(JsonTags.VALIDATE, content);
         return jsonObject;
     }
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/util/AuthUrlClient.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/util/AuthUrlClient.java b/core/src/main/java/org/apache/oozie/util/AuthUrlClient.java
index 4fc8f57..d7f19b2 100644
--- a/core/src/main/java/org/apache/oozie/util/AuthUrlClient.java
+++ b/core/src/main/java/org/apache/oozie/util/AuthUrlClient.java
@@ -16,7 +16,6 @@
  * limitations under the License.
  */
 
-
 package org.apache.oozie.util;
 
 import java.io.BufferedReader;
@@ -30,6 +29,7 @@ import java.net.URLEncoder;
 import java.security.PrivilegedExceptionAction;
 import java.util.Map;
 
+import com.google.common.base.Charsets;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.authentication.client.AuthenticatedURL;
 import org.apache.hadoop.security.authentication.client.AuthenticationException;
@@ -64,13 +64,7 @@ public class AuthUrlClient {
         try {
             conn = new AuthenticatedURL(AuthenticatorClass.newInstance()).openConnection(url, token);
         }
-        catch (AuthenticationException ex) {
-            throw new IOException("Could not authenticate, " + ex.getMessage(), ex);
-        }
-        catch (InstantiationException ex) {
-            throw new IOException("Could not authenticate, " + ex.getMessage(), ex);
-        }
-        catch (IllegalAccessException ex) {
+        catch (AuthenticationException | InstantiationException | IllegalAccessException ex) {
             throw new IOException("Could not authenticate, " + ex.getMessage(), ex);
         }
         if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
@@ -94,14 +88,16 @@ public class AuthUrlClient {
             throw new IOException("Authentication type must be specified: simple|kerberos|<class>");
         }
         authName = authName.trim();
-        if (authName.equals("simple")) {
-            authClassName = PseudoAuthenticator.class.getName();
-        }
-        else if (authName.equals("kerberos")) {
-            authClassName = KerberosAuthenticator.class.getName();
-        }
-        else {
-            authClassName = authName;
+        switch (authName) {
+            case "simple":
+                authClassName = PseudoAuthenticator.class.getName();
+                break;
+            case "kerberos":
+                authClassName = KerberosAuthenticator.class.getName();
+                break;
+            default:
+                authClassName = authName;
+                break;
         }
 
         authClass = (Class<? extends Authenticator>) Thread.currentThread().getContextClassLoader()
@@ -123,7 +119,7 @@ public class AuthUrlClient {
         }
 
         final URL url = new URL(server);
-        BufferedReader reader = null;
+        BufferedReader reader;
         try {
             reader = UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<BufferedReader>() {
                 @Override
@@ -133,7 +129,7 @@ public class AuthUrlClient {
                     BufferedReader reader = null;
                     if ((conn.getResponseCode() == HttpURLConnection.HTTP_OK)) {
                         InputStream is = conn.getInputStream();
-                        reader = new BufferedReader(new InputStreamReader(is));
+                        reader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
                     }
                     return reader;
                 }
@@ -156,10 +152,9 @@ public class AuthUrlClient {
                 String value = params.get(key)[0]; // We don't support multi value.
                 stringBuilder.append(key);
                 stringBuilder.append("=");
-                stringBuilder.append(URLEncoder.encode(value,"UTF-8"));
+                stringBuilder.append(URLEncoder.encode(value,Charsets.UTF_8.name()));
             }
         }
         return stringBuilder.toString();
     }
-
 }

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/util/IOUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/util/IOUtils.java b/core/src/main/java/org/apache/oozie/util/IOUtils.java
index 3674dc4..94db257 100644
--- a/core/src/main/java/org/apache/oozie/util/IOUtils.java
+++ b/core/src/main/java/org/apache/oozie/util/IOUtils.java
@@ -18,6 +18,8 @@
 
 package org.apache.oozie.util;
 
+import com.google.common.base.Charsets;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -116,7 +118,7 @@ public abstract class IOUtils {
      * @throws IOException thrown if the resource could not be read.
      */
     public static Reader getResourceAsReader(String path, int maxLen) throws IOException {
-        return new InputStreamReader(getResourceAsStream(path, maxLen));
+        return new InputStreamReader(getResourceAsStream(path, maxLen), Charsets.UTF_8);
     }
 
     /**
@@ -133,7 +135,7 @@ public abstract class IOUtils {
         if (is == null) {
             throw new IllegalArgumentException(XLog.format("resource [{0}] not found", path));
         }
-        Reader reader = new InputStreamReader(is);
+        Reader reader = new InputStreamReader(is, Charsets.UTF_8);
         return getReaderAsString(reader, maxLen);
     }
 

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/util/MultiFileReader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/util/MultiFileReader.java b/core/src/main/java/org/apache/oozie/util/MultiFileReader.java
index 1ab5a7a..9078f36 100644
--- a/core/src/main/java/org/apache/oozie/util/MultiFileReader.java
+++ b/core/src/main/java/org/apache/oozie/util/MultiFileReader.java
@@ -18,6 +18,8 @@
 
 package org.apache.oozie.util;
 
+import com.google.common.base.Charsets;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileReader;
@@ -79,11 +81,11 @@ public class MultiFileReader extends Reader {
             // gzip files
             if (files.get(index).getName().endsWith(".gz")) {
                 GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(files.get(index)));
-                reader = new InputStreamReader(gzipInputStream);
+                reader = new InputStreamReader(gzipInputStream, Charsets.UTF_8);
             }
             // regular files
             else {
-                reader = new FileReader(files.get(index));
+                reader = new InputStreamReader(new FileInputStream(files.get(index)), Charsets.UTF_8);
             }
             index++;
         }

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/util/XConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/util/XConfiguration.java b/core/src/main/java/org/apache/oozie/util/XConfiguration.java
index e3591db..d9e16e9 100644
--- a/core/src/main/java/org/apache/oozie/util/XConfiguration.java
+++ b/core/src/main/java/org/apache/oozie/util/XConfiguration.java
@@ -18,6 +18,7 @@
 
 package org.apache.oozie.util;
 
+import com.google.common.base.Charsets;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.oozie.service.ConfigurationService;
 import org.apache.oozie.service.Services;
@@ -283,10 +284,7 @@ public class XConfiguration extends Configuration {
             parseDocument(doc);
 
         }
-        catch (SAXException e) {
-            throw new IOException(e);
-        }
-        catch (ParserConfigurationException e) {
+        catch (SAXException | ParserConfigurationException e) {
             throw new IOException(e);
         }
     }
@@ -297,10 +295,7 @@ public class XConfiguration extends Configuration {
             Document doc = getDocumentBuilder().parse(new InputSource(reader));
             parseDocument(doc);
         }
-        catch (SAXException e) {
-            throw new IOException(e);
-        }
-        catch (ParserConfigurationException e) {
+        catch (SAXException | ParserConfigurationException e) {
             throw new IOException(e);
         }
     }
@@ -351,7 +346,6 @@ public class XConfiguration extends Configuration {
                     set(attr, value);
                 }
             }
-
         }
         catch (DOMException e) {
             throw new IOException(e);
@@ -373,7 +367,7 @@ public class XConfiguration extends Configuration {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             this.writeXml(baos);
             baos.close();
-            xml = new String(baos.toByteArray());
+            xml = new String(baos.toByteArray(), Charsets.UTF_8);
         }
         catch (IOException ex) {
             throw new RuntimeException("It should not happen, " + ex.getMessage(), ex);

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/core/src/main/java/org/apache/oozie/util/XmlUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/util/XmlUtils.java b/core/src/main/java/org/apache/oozie/util/XmlUtils.java
index 9db46b3..054d5d9 100644
--- a/core/src/main/java/org/apache/oozie/util/XmlUtils.java
+++ b/core/src/main/java/org/apache/oozie/util/XmlUtils.java
@@ -46,6 +46,7 @@ import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
 
+import com.google.common.base.Charsets;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.oozie.service.SchemaService;
 import org.apache.oozie.service.SchemaService.SchemaName;
@@ -164,10 +165,7 @@ public class XmlUtils {
             Document doc = saxBuilder.build(Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath));
             return doc.getRootElement().getAttributeValue(attributeName);
         }
-        catch (JDOMException e) {
-            throw new RuntimeException();
-        }
-        catch (IOException e) {
+        catch (JDOMException | IOException e) {
             throw new RuntimeException();
         }
     }
@@ -221,7 +219,6 @@ public class XmlUtils {
      */
     public static PrettyPrint prettyPrint(Element element) {
         return new PrettyPrint(element);
-
     }
 
     /**
@@ -271,7 +268,7 @@ public class XmlUtils {
      */
     public static void validateXml(Schema schema, String xml) throws SAXException, IOException {
         Validator validator = SchemaService.getValidator(schema);
-        validator.validate(new StreamSource(new ByteArrayInputStream(xml.getBytes())));
+        validator.validate(new StreamSource(new ByteArrayInputStream(xml.getBytes(Charsets.UTF_8))));
     }
 
     public static void validateData(String xmlData, SchemaName xsdFile) throws SAXException, IOException {
@@ -402,9 +399,8 @@ public class XmlUtils {
     public static Element getSLAElement(Element elem) {
         Element eSla_1 = elem.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI));
         Element eSla_2 = elem.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAMESPACE_URI_2));
-        Element eSla = (eSla_2 != null) ? eSla_2 : eSla_1;
 
-        return eSla;
+        return (eSla_2 != null) ? eSla_2 : eSla_1;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/oozie/blob/2f6bced4/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 9847b7b..5bb8fad 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 5.1.0 release (trunk - unreleased)
 
+OOZIE-2956 Fix Findbugs warnings related to reliance on default encoding in oozie-core (Jan Hentschel, kmarton via andras.piros)
 OOZIE-3295 Flaky test TestSLACalculatorMemory#testAddMultipleRestartRemoveMultipleInstrumentedCorrectly (pbacsko via andras.piros)
 OOZIE-3289 TestJMSAccessorService#testConnectionRetry is still flaky (pbacsko via andras.piros)
 OOZIE-3270 Upgrade Derby to 10.14.1.0 (gezapeti)