You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of returning null when failing to read file properties, throw an unchecked exception to prevent null blob names from being added to the upload list. This ensures error propagation and avoids later NPEs or confusing log entries.
} catch (IOException e) {
classLogger.error("Failed to read file properties: " + file, e);
- return null;+ throw new RuntimeException("Failed to read file properties: " + file, e);
}
Suggestion importance[1-10]: 8
__
Why: Throwing a runtime exception instead of returning null ensures that failures in uploadFileToBlob are immediately visible and avoids later NPEs or invalid entries in the upload list.
Medium
General
Handle empty-prefix blob listing
Move the paths.isEmpty() check outside the loop so that when no prefixes are provided you list all blobs once, rather than skipping the entire loop. This ensures container-wide listing works correctly.
Why: The current loop skips container-wide listing when paths is empty, leading to no downloads; moving the empty check outside fixes a critical logic bug.
Medium
Close Files.walk stream
Use a try-with-resources block for Files.walk so the stream is closed properly after iteration. This avoids potential resource leaks when walking large directory trees.
When paths is empty, the loop never runs and no blobs are processed. Extract the listing logic to handle the empty-prefix case before iterating, ensuring all blobs are listed when no specific prefix is provided.
Why: The current loop skips all blobs when paths is empty, so fixes to handle the empty-prefix case are critical to ensure files are processed correctly.
Medium
Move empty-blob cleanup outside loop
Calling deleteEmptyBlobs inside the per-blob iteration can remove items during listing and degrade performance. Move the cleanup call outside the loop so it runs only once before or after processing all blob items.
Why: Removing deleteEmptyBlobs from inside the per-blob loop reduces unnecessary repeated cleanup calls and improves performance without changing behavior.
Low
General
Strip all leading slashes
The call to replaceFirst("^/", "") only strips a single leading slash. Use replaceAll("^/+", "") to remove any number of leading slashes and ensure correct normalization of cloud paths.
protected List<String> parseStorageObjectPaths(String commaSeparatedPaths) {
List<String> result = new ArrayList<>();
String[] parts = commaSeparatedPaths.split(",");
for (String part : parts) {
String trimmed = part.trim();
if (!trimmed.isEmpty()) {
- String normalized = trimmed.replace("\\", "/").replaceFirst("^/", "");+ String normalized = trimmed.replace("\\", "/").replaceAll("^/+", "");
result.add(normalized);
}
}
return result;
}
Suggestion importance[1-10]: 4
__
Why: Switching from replaceFirst("^/", "") to replaceAll("^/+", "") correctly normalizes paths with multiple leading slashes, improving robustness.
Low
Guard against null input
If commaSeparatedPaths is null or empty, calling split will throw a NullPointerException or return an unexpected array. Add a guard clause to return an empty list safely when input is null or blank.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implementation for azure blob storage.
syncing, upload, download, copying, delete operations