Skip to content

Commit 47eccd5

Browse files
committed
Check on backslash on isKeyForDirectorySet method
1 parent 6f5a3a3 commit 47eccd5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AbfsConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public class AbfsConfiguration{
415415
private int producerQueueMaxSize;
416416

417417
@IntegerConfigurationValidatorAnnotation(ConfigurationKey =
418-
FS_AZURE_CONSUMER_MAX_LAG, DefaultValue = DEFAULT_FS_AZURE_CONSUMER_MAX_LAG)
418+
FS_AZURE_CONSUMER_MAX_LAG, DefaultValue = DEFAULT_FS_AZURE_CONSUMER_MAX_LAG)
419419
private int listingMaxConsumptionLag;
420420

421421
@IntegerConfigurationValidatorAnnotation(ConfigurationKey =

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/utils/UriUtils.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,13 @@ private static String replacedUrl(String baseUrl, String oldString, String newSt
248248
*/
249249
public static boolean isKeyForDirectorySet(String key, Set<String> dirSet) {
250250
for (String dir : dirSet) {
251-
if (dir.isEmpty() || key.startsWith(
252-
dir + AbfsHttpConstants.FORWARD_SLASH)) {
251+
// Ensure the directory ends with a forward slash
252+
if (StringUtils.isNotEmpty(dir)
253+
&& !dir.endsWith(AbfsHttpConstants.FORWARD_SLASH)) {
254+
dir += AbfsHttpConstants.FORWARD_SLASH;
255+
}
256+
// Return true if the directory is empty or the key starts with the directory
257+
if (dir.isEmpty() || key.startsWith(dir)) {
253258
return true;
254259
}
255260

0 commit comments

Comments
 (0)