HDFS-7709. Fix findbug warnings in httpfs. Contributed by Rakesh R.
(cherry picked from commit 20660b7a67
)
This commit is contained in:
parent
f59b698fc9
commit
970fdc3ad9
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.fs.http.client;
|
package org.apache.hadoop.fs.http.client;
|
||||||
|
|
||||||
|
import org.apache.commons.io.Charsets;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
|
@ -127,7 +128,7 @@ public class HttpFSUtils {
|
||||||
static Object jsonParse(HttpURLConnection conn) throws IOException {
|
static Object jsonParse(HttpURLConnection conn) throws IOException {
|
||||||
try {
|
try {
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
return parser.parse(new InputStreamReader(conn.getInputStream()));
|
return parser.parse(new InputStreamReader(conn.getInputStream(), Charsets.UTF_8));
|
||||||
} catch (ParseException ex) {
|
} catch (ParseException ex) {
|
||||||
throw new IOException("JSON parser error, " + ex.getMessage(), ex);
|
throw new IOException("JSON parser error, " + ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.fs.http.server;
|
package org.apache.hadoop.fs.http.server;
|
||||||
|
|
||||||
|
import org.apache.commons.io.Charsets;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
|
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.FilterConfig;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import java.io.FileReader;
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -77,7 +80,8 @@ public class HttpFSAuthenticationFilter
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StringBuilder secret = new StringBuilder();
|
StringBuilder secret = new StringBuilder();
|
||||||
Reader reader = new FileReader(signatureSecretFile);
|
Reader reader = new InputStreamReader(new FileInputStream(
|
||||||
|
signatureSecretFile), Charsets.UTF_8);
|
||||||
int c = reader.read();
|
int c = reader.read();
|
||||||
while (c > -1) {
|
while (c > -1) {
|
||||||
secret.append((char)c);
|
secret.append((char)c);
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class FileSystemAccessService extends BaseService implements FileSystemAc
|
||||||
|
|
||||||
String hadoopConfDirProp = getServiceConfig().get(HADOOP_CONF_DIR, getServer().getConfigDir());
|
String hadoopConfDirProp = getServiceConfig().get(HADOOP_CONF_DIR, getServer().getConfigDir());
|
||||||
File hadoopConfDir = new File(hadoopConfDirProp).getAbsoluteFile();
|
File hadoopConfDir = new File(hadoopConfDirProp).getAbsoluteFile();
|
||||||
if (hadoopConfDir == null) {
|
if (!hadoopConfDir.exists()) {
|
||||||
hadoopConfDir = new File(getServer().getConfigDir()).getAbsoluteFile();
|
hadoopConfDir = new File(getServer().getConfigDir()).getAbsoluteFile();
|
||||||
}
|
}
|
||||||
if (!hadoopConfDir.exists()) {
|
if (!hadoopConfDir.exists()) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package org.apache.hadoop.lib.wsrs;
|
package org.apache.hadoop.lib.wsrs;
|
||||||
|
|
||||||
|
import org.apache.commons.io.Charsets;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.json.simple.JSONObject;
|
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,
|
public void writeTo(Map map, Class<?> aClass, Type type, Annotation[] annotations,
|
||||||
MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap,
|
MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap,
|
||||||
OutputStream outputStream) throws IOException, WebApplicationException {
|
OutputStream outputStream) throws IOException, WebApplicationException {
|
||||||
Writer writer = new OutputStreamWriter(outputStream);
|
Writer writer = new OutputStreamWriter(outputStream, Charsets.UTF_8);
|
||||||
JSONObject.writeJSONString(map, writer);
|
JSONObject.writeJSONString(map, writer);
|
||||||
writer.write(ENTER);
|
writer.write(ENTER);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package org.apache.hadoop.lib.wsrs;
|
package org.apache.hadoop.lib.wsrs;
|
||||||
|
|
||||||
|
import org.apache.commons.io.Charsets;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.json.simple.JSONStreamAware;
|
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,
|
public void writeTo(JSONStreamAware jsonStreamAware, Class<?> aClass, Type type, Annotation[] annotations,
|
||||||
MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap,
|
MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap,
|
||||||
OutputStream outputStream) throws IOException, WebApplicationException {
|
OutputStream outputStream) throws IOException, WebApplicationException {
|
||||||
Writer writer = new OutputStreamWriter(outputStream);
|
Writer writer = new OutputStreamWriter(outputStream, Charsets.UTF_8);
|
||||||
jsonStreamAware.writeJSONString(writer);
|
jsonStreamAware.writeJSONString(writer);
|
||||||
writer.write(ENTER);
|
writer.write(ENTER);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
|
|
@ -559,6 +559,8 @@ Release 2.7.0 - UNRELEASED
|
||||||
in-memory state associated with volumes. (Lei (Eddy) Xu via Colin P.
|
in-memory state associated with volumes. (Lei (Eddy) Xu via Colin P.
|
||||||
McCabe)
|
McCabe)
|
||||||
|
|
||||||
|
HDFS-7709. Fix findbug warnings in httpfs. (Rakesh R via ozawa)
|
||||||
|
|
||||||
Release 2.6.1 - UNRELEASED
|
Release 2.6.1 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
Loading…
Reference in New Issue