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

Fix Windows bug on getComponentMessages #913

Merged
merged 34 commits into from
Dec 9, 2020

Conversation

jessiejuachon
Copy link
Contributor

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.

Copy link
Contributor

@huihuiw01 huihuiw01 left a 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("/"))
Copy link
Contributor

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?

Copy link
Contributor Author

@jessiejuachon jessiejuachon Dec 8, 2020

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.

@Xiaochao8 Xiaochao8 merged commit 3678872 into vmware:g11n-java-client Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants