HDFS-8686. WebHdfsFileSystem#getXAttr(Path p, final String name) doesn't work if namespace is in capitals (Contributed by kanaka kumar avvaru)
This commit is contained in:
parent
233cab89ad
commit
fc92d3e651
|
@ -413,6 +413,20 @@ class JsonUtilClient {
|
|||
return null;
|
||||
}
|
||||
|
||||
/** Expecting only single XAttr in the map. return its value */
|
||||
static byte[] getXAttr(final Map<?, ?> json) throws IOException {
|
||||
if (json == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String, byte[]> xAttrs = toXAttrs(json);
|
||||
if (xAttrs != null && !xAttrs.values().isEmpty()) {
|
||||
return xAttrs.values().iterator().next();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static Map<String, byte[]> toXAttrs(final Map<?, ?> json)
|
||||
throws IOException {
|
||||
if (json == null) {
|
||||
|
|
|
@ -963,7 +963,7 @@ public class WebHdfsFileSystem extends FileSystem
|
|||
new XAttrEncodingParam(XAttrCodec.HEX)) {
|
||||
@Override
|
||||
byte[] decodeResponse(Map<?, ?> json) throws IOException {
|
||||
return JsonUtilClient.getXAttr(json, name);
|
||||
return JsonUtilClient.getXAttr(json);
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
|
|
@ -1005,6 +1005,9 @@ Release 2.8.0 - UNRELEASED
|
|||
HDFS-8577. Avoid retrying to recover lease on a file which does not exist
|
||||
(J.Andreina via vinayakumarb)
|
||||
|
||||
HDFS-8686. WebHdfsFileSystem#getXAttr(Path p, final String name) doesn't
|
||||
work if namespace is in capitals (kanaka kumar avvaru via vinayakumarb)
|
||||
|
||||
Release 2.7.2 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -396,6 +396,9 @@ public class FSXAttrBaseTest {
|
|||
fs.setXAttr(path, name1, value1, EnumSet.of(XAttrSetFlag.CREATE));
|
||||
fs.setXAttr(path, name2, value2, EnumSet.of(XAttrSetFlag.CREATE));
|
||||
|
||||
final byte[] theValue = fs.getXAttr(path, "USER.a2");
|
||||
Assert.assertArrayEquals(value2, theValue);
|
||||
|
||||
/* An XAttr that was requested does not exist. */
|
||||
try {
|
||||
final byte[] value = fs.getXAttr(path, name3);
|
||||
|
|
|
@ -231,6 +231,9 @@ public class TestOfflineImageViewerForXAttr {
|
|||
"user.attr1"));
|
||||
assertEquals("value1", value);
|
||||
|
||||
value = new String(webhdfs.getXAttr(new Path("/dir1"), "USER.attr1"));
|
||||
assertEquals("value1", value);
|
||||
|
||||
Map<String, byte[]> contentMap = webhdfs.getXAttrs(new Path("/dir1"),
|
||||
names);
|
||||
|
||||
|
|
Loading…
Reference in New Issue