Skip to content

Commit baa13f2

Browse files
committed
Use startsWith overload
1 parent 969a78c commit baa13f2

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/FileAccessTree.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,7 @@
2121

2222
public final class FileAccessTree {
2323
public static final FileAccessTree EMPTY = new FileAccessTree(List.of());
24-
private static final char FILE_SEPARATOR;
25-
26-
static {
27-
String separator = getDefaultFileSystem().getSeparator();
28-
if (separator.length() == 1) {
29-
FILE_SEPARATOR = separator.charAt(0);
30-
} else {
31-
throw new IllegalStateException("Multi-character file separator not supported: [" + separator + "]");
32-
}
33-
}
24+
private static final String FILE_SEPARATOR = getDefaultFileSystem().getSeparator();
3425

3526
private final String[] readPaths;
3627
private final String[] writePaths;
@@ -82,7 +73,7 @@ private static boolean checkPath(String path, String[] paths) {
8273
int ndx = Arrays.binarySearch(paths, path);
8374
if (ndx < -1) {
8475
String maybeParent = paths[-ndx - 2];
85-
return path.startsWith(maybeParent) && path.charAt(maybeParent.length()) == FILE_SEPARATOR;
76+
return path.startsWith(maybeParent) && path.startsWith(FILE_SEPARATOR, maybeParent.length());
8677
}
8778
return ndx >= 0;
8879
}

0 commit comments

Comments
 (0)