Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidPathException Throws when set GlobalSettings include many files #294

Open
sdliang1013 opened this issue Mar 19, 2021 · 0 comments
Open

Comments

@sdliang1013
Copy link

现象:

  1. globalsettings设置include为*.json
[{
    "context": "/mock/api",
    "file_root": "src/test/resources/moco",
    "include": "*.json"
  }]
  1. 启动报错:
java.nio.file.InvalidPathException: Illegal char <*> at index 24: src\test\resources\moco\*.json
	at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
	at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
	at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
	at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
	at java.nio.file.Paths.get(Paths.java:84)
	at com.github.dreamhead.moco.util.Globs.getGlobPath(Globs.java:31)
	at com.github.dreamhead.moco.util.Globs.glob(Globs.java:20)
	at com.github.dreamhead.moco.parser.model.GlobalSetting.includes(GlobalSetting.java:22)

问题分析:
GlobalSetting.includes -> Globs.glob -> Globs.getGlobPath -> Paths.get 方法在验证文件名时: *号为非法符号.

处理建议:
修改 Globs.glob方法, 不用Path做路径分析, 手动解析字符串实现searchPath的功能

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant