-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Hi,I feel that there may be a problem with this code.
If the line is short, for example ,"a", when the file is exhausted, starting recursion, "" will be passed in.
There will be a stringIndexOutOfBoundsException
protected File getFile(String prefix, String line) {
char start = line.charAt(0);
String filename = (prefix + start).toLowerCase();
File file = fileSplitter.getTempFiles().get(filename);
if (file == null) {
file = Paths.get(tempFilesDir, filename + ".txt").toFile();
file.deleteOnExit();
fileSplitter.addTempFile(filename, file);
} else {
Long maxTempFileSize = Long.valueOf(ExternalSortingProperties.MAX_TEMP_FILE_SIZE.value());
if (fileSplitter.isFileExhausted(filename) || file.length() >= maxTempFileSize) {
fileSplitter.addExhaustedFile(filename);
file = getFile(filename, line.substring(1));
}
}
fileSplitter.checkSameFirstCharFilename(file);
return file;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels