Skip to content

Commit e49d4a9

Browse files
committed
8271447: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters
Reviewed-by: mgronlun
1 parent 713fbeb commit e49d4a9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/jdk.jfr/share/classes/jdk/jfr/internal/management/ChunkFilename.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public String next(LocalDateTime time) throws IOException {
7474

7575
// If more than one file per second
7676
while (counter < MAX_CHUNK_NAMES) {
77-
String extendedName = String.format("%s_%02d%s", filename, counter, FILE_EXTENSION);
77+
String extendedName = makeExtendedName(filename, counter);
7878
p = directory.resolve(extendedName);
7979
counter++;
8080
if (!fileAcess.exists(p)) {
@@ -83,4 +83,16 @@ public String next(LocalDateTime time) throws IOException {
8383
}
8484
throw new IOException("Unable to find unused filename after " + counter + " attempts");
8585
}
86+
87+
private String makeExtendedName(String filename, int counter) {
88+
StringBuilder sb = new StringBuilder();
89+
sb.append(filename);
90+
sb.append('_');
91+
if (counter < 10) { // chronological sorted
92+
sb.append('0');
93+
}
94+
sb.append(counter);
95+
sb.append(FILE_EXTENSION);
96+
return sb.toString();
97+
}
8698
}

0 commit comments

Comments
 (0)