HDFS-7709. Fix findbug warnings in httpfs. Contributed by Rakesh R.

This commit is contained in:
Tsuyoshi Ozawa 2015-02-05 19:57:07 +09:00
parent ec950be173
commit 20660b7a67
6 changed files with 15 additions and 6 deletions

View File

@ -17,6 +17,7 @@
*/
package org.apache.hadoop.fs.http.client;
import org.apache.commons.io.Charsets;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.fs.Path;
import org.json.simple.parser.JSONParser;
@ -127,7 +128,7 @@ public class HttpFSUtils {
static Object jsonParse(HttpURLConnection conn) throws IOException {
try {
JSONParser parser = new JSONParser();
return parser.parse(new InputStreamReader(conn.getInputStream()));
return parser.parse(new InputStreamReader(conn.getInputStream(), Charsets.UTF_8));
} catch (ParseException ex) {
throw new IOException("JSON parser error, " + ex.getMessage(), ex);
}

View File

@ -17,6 +17,7 @@
*/
package org.apache.hadoop.fs.http.server;
import org.apache.commons.io.Charsets;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
@ -24,8 +25,10 @@ import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthentica
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import java.io.FileReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Map;
import java.util.Properties;
@ -77,7 +80,8 @@ public class HttpFSAuthenticationFilter
try {
StringBuilder secret = new StringBuilder();
Reader reader = new FileReader(signatureSecretFile);
Reader reader = new InputStreamReader(new FileInputStream(
signatureSecretFile), Charsets.UTF_8);
int c = reader.read();
while (c > -1) {
secret.append((char)c);

View File

@ -177,7 +177,7 @@ public class FileSystemAccessService extends BaseService implements FileSystemAc
String hadoopConfDirProp = getServiceConfig().get(HADOOP_CONF_DIR, getServer().getConfigDir());
File hadoopConfDir = new File(hadoopConfDirProp).getAbsoluteFile();
if (hadoopConfDir == null) {
if (!hadoopConfDir.exists()) {
hadoopConfDir = new File(getServer().getConfigDir()).getAbsoluteFile();
}
if (!hadoopConfDir.exists()) {

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.lib.wsrs;
import org.apache.commons.io.Charsets;
import org.apache.hadoop.classification.InterfaceAudience;
import org.json.simple.JSONObject;
@ -55,7 +56,7 @@ public class JSONMapProvider implements MessageBodyWriter<Map> {
public void writeTo(Map map, Class<?> aClass, Type type, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap,
OutputStream outputStream) throws IOException, WebApplicationException {
Writer writer = new OutputStreamWriter(outputStream);
Writer writer = new OutputStreamWriter(outputStream, Charsets.UTF_8);
JSONObject.writeJSONString(map, writer);
writer.write(ENTER);
writer.flush();

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.lib.wsrs;
import org.apache.commons.io.Charsets;
import org.apache.hadoop.classification.InterfaceAudience;
import org.json.simple.JSONStreamAware;
@ -55,7 +56,7 @@ public class JSONProvider implements MessageBodyWriter<JSONStreamAware> {
public void writeTo(JSONStreamAware jsonStreamAware, Class<?> aClass, Type type, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap,
OutputStream outputStream) throws IOException, WebApplicationException {
Writer writer = new OutputStreamWriter(outputStream);
Writer writer = new OutputStreamWriter(outputStream, Charsets.UTF_8);
jsonStreamAware.writeJSONString(writer);
writer.write(ENTER);
writer.flush();

View File

@ -841,6 +841,8 @@ Release 2.7.0 - UNRELEASED
in-memory state associated with volumes. (Lei (Eddy) Xu via Colin P.
McCabe)
HDFS-7709. Fix findbug warnings in httpfs. (Rakesh R via ozawa)
Release 2.6.1 - UNRELEASED
INCOMPATIBLE CHANGES