#Fix bug. File system error `Illegal char <:> at i...
# troubleshooting
j
#Fix bug. File system error
Illegal char <:> at index 2: /X:/XXX
When I tested the filesystem source in Windows, an exception occurred due to an
illegal char'<:>' at index 2: /D:/kotlintworkspace.
My enviroument , Flink 1.16,
flink-connector-files 1.16.2
. This issue was caused by this line (`FlileSystemTableSource.java` line: 499):
Copy code
FILENAME(
                "file.name",
                DataTypes.STRING().notNull(),
                new FileInfoAccessor() {
                    private static final long serialVersionUID = 1L;
                    @Override
                    public Object getValue(FileSourceSplit split) {
                      return StringData.fromString(
                                Paths.get(split.path().getPath()).getFileName().toString());
                    }
                }),
Update the code as follows:
Copy code
FILENAME(
                "file.name",
                DataTypes.STRING().notNull(),
                new FileInfoAccessor() {
                    private static final long serialVersionUID = 1L;
                    private final Pattern windowsPath = Pattern.compile("^/(\\w):");
                    @Override
                    public Object getValue(FileSourceSplit split) {
                        // TODO: Need fix
                        // There might be a bug, as in the windows system,the file path will look like this:
                        // /C:/file/temp.txt
                        String path = split.path().getPath();
                        // create pattern
                        Matcher m = windowsPath.matcher(path);
                        if (m.find()) {
                            // replace
                            path = m.replaceAll("$1:/");
                        }
                        return StringData.fromString(Paths.get(path).getFileName().toString());
                    }
                }),