-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix Windows bug on getComponentMessages #913
Fix Windows bug on getComponentMessages #913
Conversation
…/LocalMessagesOpt.java Co-authored-by: Xiaochao Li <48587632+Xiaochao8@users.noreply.github.com>
…into non-block-cache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the change in this PR is not correct, include many changes in last PR (878).
Path path = Paths.get(VIPCfg.getInstance().getOfflineResourcesBaseUrl(), filePath); | ||
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path.toString()); | ||
String offlineResourcePath = VIPCfg.getInstance().getOfflineResourcesBaseUrl(); | ||
if(!offlineResourcePath.endsWith("/")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can "/" be suitable for all systems? Should it be FileSeparator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that is the root cause of the bug. If we use FileSeparator (same as Paths.get), then '' (backslash) will be used in Windows platform. However, the forward slash in jar is not platform dependent. Even if the application is run on a Windows platform, the jar files will still have forward slashes. The use of Paths.get (or FileSeparator) was causing the issue of not finding the message bundles.
Paths.get must not be use here because the defined path separator in JAR files is '/' (forward slash). Paths.get will use '' (backslash) in Windows which results to not finding the messages_xx.json path inside the jar.