HDFS-12610. Ozone: OzoneClient: RpcClient list calls throw NPE when iterating over empty list. Contributed by Nandakumar.
This commit is contained in:
parent
c3ef381011
commit
9630621be7
@ -174,7 +174,8 @@ private class VolumeIterator implements Iterator<OzoneVolume> {
|
|||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if(!currentIterator.hasNext()) {
|
if(!currentIterator.hasNext()) {
|
||||||
currentIterator = getNextListOfVolumes(
|
currentIterator = getNextListOfVolumes(
|
||||||
currentValue.getName()).iterator();
|
currentValue != null ? currentValue.getName() : null)
|
||||||
|
.iterator();
|
||||||
}
|
}
|
||||||
return currentIterator.hasNext();
|
return currentIterator.hasNext();
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,8 @@ private class KeyIterator implements Iterator<OzoneKey> {
|
|||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if(!currentIterator.hasNext()) {
|
if(!currentIterator.hasNext()) {
|
||||||
currentIterator = getNextListOfKeys(
|
currentIterator = getNextListOfKeys(
|
||||||
currentValue.getName()).iterator();
|
currentValue != null ? currentValue.getName() : null)
|
||||||
|
.iterator();
|
||||||
}
|
}
|
||||||
return currentIterator.hasNext();
|
return currentIterator.hasNext();
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,8 @@ private class BucketIterator implements Iterator<OzoneBucket> {
|
|||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if(!currentIterator.hasNext()) {
|
if(!currentIterator.hasNext()) {
|
||||||
currentIterator = getNextListOfBuckets(
|
currentIterator = getNextListOfBuckets(
|
||||||
currentValue.getName()).iterator();
|
currentValue != null ? currentValue.getName() : null)
|
||||||
|
.iterator();
|
||||||
}
|
}
|
||||||
return currentIterator.hasNext();
|
return currentIterator.hasNext();
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ public void testDeleteKey()
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listVolumeTest() throws IOException, OzoneException {
|
public void testListVolume() throws IOException, OzoneException {
|
||||||
String volBase = "vol-" + RandomStringUtils.randomNumeric(3);
|
String volBase = "vol-" + RandomStringUtils.randomNumeric(3);
|
||||||
//Create 10 volume vol-<random>-a-0-<random> to vol-<random>-a-9-<random>
|
//Create 10 volume vol-<random>-a-0-<random> to vol-<random>-a-9-<random>
|
||||||
String volBaseNameA = volBase + "-a-";
|
String volBaseNameA = volBase + "-a-";
|
||||||
@ -448,7 +448,7 @@ public void listVolumeTest() throws IOException, OzoneException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listBucketTest()
|
public void testListBucket()
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
String volumeA = "vol-a-" + RandomStringUtils.randomNumeric(5);
|
String volumeA = "vol-a-" + RandomStringUtils.randomNumeric(5);
|
||||||
String volumeB = "vol-b-" + RandomStringUtils.randomNumeric(5);
|
String volumeB = "vol-b-" + RandomStringUtils.randomNumeric(5);
|
||||||
@ -522,7 +522,19 @@ public void listBucketTest()
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listKeyTest()
|
public void testListBucketsOnEmptyVolume()
|
||||||
|
throws IOException, OzoneException {
|
||||||
|
String volume = "vol-" + RandomStringUtils.randomNumeric(5);
|
||||||
|
store.createVolume(volume);
|
||||||
|
OzoneVolume vol = store.getVolume(volume);
|
||||||
|
Iterator<OzoneBucket> buckets = vol.listBuckets("");
|
||||||
|
while(buckets.hasNext()) {
|
||||||
|
Assert.fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListKey()
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
String volumeA = "vol-a-" + RandomStringUtils.randomNumeric(5);
|
String volumeA = "vol-a-" + RandomStringUtils.randomNumeric(5);
|
||||||
String volumeB = "vol-b-" + RandomStringUtils.randomNumeric(5);
|
String volumeB = "vol-b-" + RandomStringUtils.randomNumeric(5);
|
||||||
@ -656,6 +668,21 @@ public void listKeyTest()
|
|||||||
Assert.assertFalse(volABucketBIter.hasNext());
|
Assert.assertFalse(volABucketBIter.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListKeyOnEmptyBucket()
|
||||||
|
throws IOException, OzoneException {
|
||||||
|
String volume = "vol-" + RandomStringUtils.randomNumeric(5);
|
||||||
|
String bucket = "buc-" + RandomStringUtils.randomNumeric(5);
|
||||||
|
store.createVolume(volume);
|
||||||
|
OzoneVolume vol = store.getVolume(volume);
|
||||||
|
vol.createBucket(bucket);
|
||||||
|
OzoneBucket buc = vol.getBucket(bucket);
|
||||||
|
Iterator<OzoneKey> keys = buc.listKeys("");
|
||||||
|
while(keys.hasNext()) {
|
||||||
|
Assert.fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close OzoneClient and shutdown MiniOzoneCluster.
|
* Close OzoneClient and shutdown MiniOzoneCluster.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user