Skip to content

Commit 8eabe29

Browse files
authored
HDDS-5826 [HTTPFSGW] Remove or replace Hadoop shaded guava dependencies. (#2735)
1 parent b015447 commit 8eabe29

6 files changed

Lines changed: 16 additions & 21 deletions

File tree

hadoop-ozone/httpfsgateway/src/main/java/org/apache/hadoop/fs/http/client/HttpFSFileSystem.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.List;
2525

2626
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
27-
import org.apache.hadoop.thirdparty.com.google.common.base.Charsets;
2827
import org.apache.hadoop.classification.InterfaceAudience;
2928
import org.apache.hadoop.conf.Configuration;
3029
import org.apache.hadoop.fs.CommonPathCapabilities;
@@ -66,15 +65,12 @@
6665
import org.apache.hadoop.util.Progressable;
6766
import org.apache.hadoop.util.ReflectionUtils;
6867
import org.apache.hadoop.util.StringUtils;
68+
import org.apache.ratis.thirdparty.com.google.common.base.Preconditions;
6969
import org.json.simple.JSONArray;
7070
import org.json.simple.JSONObject;
7171
import org.json.simple.parser.JSONParser;
7272
import org.json.simple.parser.ParseException;
7373

74-
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
75-
import org.apache.hadoop.thirdparty.com.google.common.collect.Lists;
76-
import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
77-
7874
import java.io.BufferedInputStream;
7975
import java.io.BufferedOutputStream;
8076
import java.io.DataInput;
@@ -88,6 +84,7 @@
8884
import java.net.URI;
8985
import java.net.URISyntaxException;
9086
import java.net.URL;
87+
import java.nio.charset.StandardCharsets;
9188
import java.security.PrivilegedExceptionAction;
9289
import java.text.MessageFormat;
9390
import java.util.HashMap;
@@ -802,7 +799,7 @@ public DirectoryEntries listStatusBatch(Path f, byte[] token) throws
802799
Map<String, String> params = new HashMap<String, String>();
803800
params.put(OP_PARAM, Operation.LISTSTATUS_BATCH.toString());
804801
if (token != null) {
805-
params.put(START_AFTER_PARAM, new String(token, Charsets.UTF_8));
802+
params.put(START_AFTER_PARAM, new String(token, StandardCharsets.UTF_8));
806803
}
807804
HttpURLConnection conn = getConnection(
808805
Operation.LISTSTATUS_BATCH.getMethod(),
@@ -817,7 +814,7 @@ public DirectoryEntries listStatusBatch(Path f, byte[] token) throws
817814
byte[] newToken = null;
818815
if (statuses.length > 0) {
819816
newToken = statuses[statuses.length - 1].getPath().getName().toString()
820-
.getBytes(Charsets.UTF_8);
817+
.getBytes(StandardCharsets.UTF_8);
821818
}
822819
// Parse the remainingEntries boolean into hasMore
823820
final long remainingEntries = (Long) listing.get(REMAINING_ENTRIES_JSON);
@@ -1402,13 +1399,13 @@ public byte[] getXAttr(Path f, String name) throws IOException {
14021399
JSONObject json = (JSONObject) HttpFSUtils.jsonParse(conn);
14031400
Map<String, byte[]> xAttrs = createXAttrMap(
14041401
(JSONArray) json.get(XATTRS_JSON));
1405-
return xAttrs != null ? xAttrs.get(name) : null;
1402+
return xAttrs.get(name);
14061403
}
14071404

14081405
/** Convert xAttrs json to xAttrs map. */
14091406
private Map<String, byte[]> createXAttrMap(JSONArray jsonArray)
14101407
throws IOException {
1411-
Map<String, byte[]> xAttrs = Maps.newHashMap();
1408+
Map<String, byte[]> xAttrs = new HashMap<>();
14121409
for (Object obj : jsonArray) {
14131410
JSONObject jsonObj = (JSONObject) obj;
14141411
final String name = (String)jsonObj.get(XATTR_NAME_JSON);
@@ -1427,7 +1424,7 @@ private List<String> createXAttrNames(String xattrNamesStr)
14271424
JSONArray jsonArray;
14281425
try {
14291426
jsonArray = (JSONArray)parser.parse(xattrNamesStr);
1430-
List<String> names = Lists.newArrayListWithCapacity(jsonArray.size());
1427+
List<String> names = new ArrayList<>(jsonArray.size());
14311428
for (Object name : jsonArray) {
14321429
names.add((String) name);
14331430
}
@@ -1455,7 +1452,7 @@ public Map<String, byte[]> getXAttrs(Path f, List<String> names)
14551452
"XAttr names cannot be null or empty.");
14561453
Map<String, String> params = new HashMap<String, String>();
14571454
params.put(OP_PARAM, Operation.GETXATTRS.toString());
1458-
Map<String, List<String>> multiValuedParams = Maps.newHashMap();
1455+
Map<String, List<String>> multiValuedParams = new HashMap<>();
14591456
multiValuedParams.put(XATTR_NAME_PARAM, names);
14601457
HttpURLConnection conn = getConnection(Operation.GETXATTRS.getMethod(),
14611458
params, multiValuedParams, f, true);

hadoop-ozone/httpfsgateway/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
package org.apache.hadoop.fs.http.server;
2020

21-
import org.apache.hadoop.thirdparty.com.google.common.base.Charsets;
2221
import org.apache.hadoop.classification.InterfaceAudience;
2322
import org.apache.hadoop.conf.Configuration;
2423
import org.apache.hadoop.fs.FileSystem;
@@ -89,6 +88,7 @@
8988
import java.io.IOException;
9089
import java.io.InputStream;
9190
import java.net.URI;
91+
import java.nio.charset.StandardCharsets;
9292
import java.security.AccessControlException;
9393
import java.security.PrivilegedExceptionAction;
9494
import java.text.MessageFormat;
@@ -452,7 +452,7 @@ private Response handleListStatusBatch(String path,
452452
HttpFSParametersProvider.StartAfterParam.class);
453453
byte[] token = HttpFSUtils.EMPTY_BYTES;
454454
if (startAfter != null) {
455-
token = startAfter.getBytes(Charsets.UTF_8);
455+
token = startAfter.getBytes(StandardCharsets.UTF_8);
456456
}
457457
FSOperations.FSListStatusBatch command = new FSOperations
458458
.FSListStatusBatch(path, token);

hadoop-ozone/httpfsgateway/src/main/java/org/apache/hadoop/fs/http/server/JsonUtil.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.hadoop.ipc.RemoteException;
2929
import org.apache.hadoop.security.token.Token;
3030
import org.apache.hadoop.security.token.TokenIdentifier;
31-
import org.apache.hadoop.thirdparty.com.google.common.collect.Lists;
3231
import org.apache.hadoop.util.StringUtils;
3332

3433
import java.io.IOException;
@@ -366,7 +365,7 @@ public static String toJsonString(final List<XAttr> xAttrs,
366365

367366
public static String toJsonString(final List<XAttr> xAttrs)
368367
throws IOException {
369-
final List<String> names = Lists.newArrayListWithCapacity(xAttrs.size());
368+
final List<String> names = new ArrayList<>(xAttrs.size());
370369
for (XAttr xAttr : xAttrs) {
371370
names.add(XAttrHelper.getPrefixedName(xAttr));
372371
}

hadoop-ozone/httpfsgateway/src/main/java/org/apache/hadoop/lib/servlet/ServerWebApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
package org.apache.hadoop.lib.servlet;
2020

21-
import org.apache.hadoop.thirdparty.com.google.common.annotations.VisibleForTesting;
2221
import org.apache.hadoop.classification.InterfaceAudience;
2322
import org.apache.hadoop.conf.Configuration;
2423
import org.apache.hadoop.lib.server.Server;
2524
import org.apache.hadoop.lib.server.ServerException;
25+
import org.apache.ratis.thirdparty.com.google.common.annotations.VisibleForTesting;
2626

2727
import javax.servlet.ServletContextEvent;
2828
import javax.servlet.ServletContextListener;

hadoop-ozone/httpfsgateway/src/main/java/org/apache/hadoop/lib/wsrs/Parameters.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020
import org.apache.hadoop.classification.InterfaceAudience;
2121

22-
import org.apache.hadoop.thirdparty.com.google.common.collect.Lists;
23-
22+
import java.util.ArrayList;
2423
import java.util.List;
2524
import java.util.Map;
2625

@@ -69,7 +68,7 @@ public <V, T extends Param<V>> V get(String name, Class<T> klass) {
6968
public <V, T extends Param<V>> List<V> getValues(String name,
7069
Class<T> klass) {
7170
List<Param<?>> multiParams = (List<Param<?>>)params.get(name);
72-
List<V> values = Lists.newArrayList();
71+
List<V> values = new ArrayList<>();
7372
if (multiParams != null) {
7473
for (Param<?> param : multiParams) {
7574
V value = ((T) param).value();

hadoop-ozone/httpfsgateway/src/main/java/org/apache/hadoop/lib/wsrs/ParametersProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
package org.apache.hadoop.lib.wsrs;
2020

21-
import org.apache.hadoop.thirdparty.com.google.common.collect.Lists;
2221
import com.sun.jersey.api.core.HttpContext;
2322
import com.sun.jersey.core.spi.component.ComponentContext;
2423
import com.sun.jersey.core.spi.component.ComponentScope;
@@ -32,6 +31,7 @@
3231
import javax.ws.rs.core.MultivaluedMap;
3332
import java.lang.reflect.Type;
3433
import java.text.MessageFormat;
34+
import java.util.ArrayList;
3535
import java.util.HashMap;
3636
import java.util.List;
3737
import java.util.Map;
@@ -82,7 +82,7 @@ public Parameters getValue(HttpContext httpContext) {
8282
}
8383
for (Class<Param<?>> paramClass : paramsDef.get(op)) {
8484
Param<?> param = newParam(paramClass);
85-
List<Param<?>> paramList = Lists.newArrayList();
85+
List<Param<?>> paramList = new ArrayList<>();
8686
List<String> ps = queryString.get(param.getName());
8787
if (ps != null) {
8888
for (String p : ps) {

0 commit comments

Comments
 (0)