cxorm opened a new pull request #437: HDDS-2845. Fix listing keys for setting --start with last key URL: https://github.com/apache/hadoop-ozone/pull/437 ## What changes were proposed in this pull request? Cause listing keys with `--start` means that we would get keys after the `--start`, we should get empty result when we set `--start` with last key. But we get all keys for now, this is caused by this [method](https://github.com/apache/hadoop-ozone/blob/master/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java#L592#L600). When we set `--start` with last key, [`getNextListOfKeys(prevKey)`](https://github.com/apache/hadoop-ozone/blob/master/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java#L589) would be empty list, so the first call of [`hasNext()`](https://github.com/apache/hadoop-ozone/blob/master/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java#L593#L600) would enter the `if-block` and `currentValue` is `null`. This situation results in calling `getNextListOfKeys(null)`, and [`currentIterator`](https://github.com/apache/hadoop-ozone/blob/master/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java#L595#L597) would be iterator of all keys, so we get all keys for now. #### Proposed fix. The `currentValue` in [`if-block`](https://github.com/apache/hadoop-ozone/blob/master/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java#L594#L598) would be `null` if and only if first call [`hasNext()`](https://github.com/apache/hadoop-ozone/blob/master/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java#L593#L600) of empty list, so`currentValue` is tested ahead by this fix. ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-2845 ## How was this patch tested? [Github action passed](https://github.com/cxorm/hadoop-ozone/runs/376387142).
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
