diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java index 6dd1949eaf..728ac528c4 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java @@ -200,7 +200,7 @@ public List listContainer(ContainerID startContainerID, Collections.sort(containersIds); return containersIds.stream() - .filter(id -> id.getId() >= startId) + .filter(id -> id.getId() > startId) .limit(count) .map(id -> { try { diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java index e85da540fd..8330f701d4 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java @@ -294,8 +294,13 @@ public List listContainer(long startContainerID, auditMap.put("startContainerID", String.valueOf(startContainerID)); auditMap.put("count", String.valueOf(count)); try { + // To allow startcontainerId to take the value "0", + // "null" is assigned, so that its handled in the + // scm.getContainerManager().listContainer method + final ContainerID containerId = startContainerID != 0 ? ContainerID + .valueof(startContainerID) : null; return scm.getContainerManager(). - listContainer(ContainerID.valueof(startContainerID), count); + listContainer(containerId, count); } catch (Exception ex) { auditSuccess = false; AUDIT.logReadFailure(