Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-10367. Fix possible NullPointerException in listKeysLight method #6221

Merged
merged 11 commits into from
Feb 28, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ public final class OzoneManagerProtocolClientSideTranslatorPB
private OmTransport transport;
private ThreadLocal<S3Auth> threadLocalS3Auth
= new ThreadLocal<>();

private boolean s3AuthCheck;

public static final int BLOCK_ALLOCATION_RETRY_COUNT = 5;
Expand Down Expand Up @@ -1033,7 +1032,7 @@ public ListKeysLightResult listKeysLight(String volumeName,
reqBuilder.setBucketName(bucketName);
reqBuilder.setCount(maxKeys);

if (StringUtils.isNotEmpty(startKey)) {
if (startKey != null) {
ivanzlenko marked this conversation as resolved.
Show resolved Hide resolved
reqBuilder.setStartKey(startKey);
}

Expand Down Expand Up @@ -2261,9 +2260,12 @@ public List<OzoneFileStatus> listStatus(OmKeyArgs args, boolean recursive,
ListStatusRequest.newBuilder()
.setKeyArgs(keyArgs)
.setRecursive(recursive)
.setStartKey(startKey)
.setNumEntries(numEntries);

if (startKey != null) {
listStatusRequestBuilder.setStartKey(startKey);
ivanzlenko marked this conversation as resolved.
Show resolved Hide resolved
}

if (allowPartialPrefixes) {
listStatusRequestBuilder.setAllowPartialPrefix(allowPartialPrefixes);
}
Expand Down Expand Up @@ -2297,9 +2299,12 @@ public List<OzoneFileStatusLight> listStatusLight(OmKeyArgs args,
ListStatusRequest.newBuilder()
.setKeyArgs(keyArgs)
.setRecursive(recursive)
.setStartKey(startKey)
.setNumEntries(numEntries);

if (startKey != null) {
listStatusRequestBuilder.setStartKey(startKey);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is also a ListStatusRequest, I think we need to set "" in else branch here, too.


if (allowPartialPrefixes) {
listStatusRequestBuilder.setAllowPartialPrefix(allowPartialPrefixes);
}
Expand Down