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

[BUG] Java client offline mode fails in nested-jar applications such as Spring Boot (initially reported by the Atlas team) #882

Closed
jessiejuachon opened this issue Nov 20, 2020 · 5 comments · Fixed by #869, #883, #878 or #913
Assignees
Labels
Milestone

Comments

@jessiejuachon
Copy link
Contributor

jessiejuachon commented Nov 20, 2020

Describe the bug
Java client offline mode fails in nested-jar applications such as Spring Boot.

After investigation, the root cause seems to be the following:

  1. The java client library tries to walk the file system when getting the list of supported locales. This fails when the file system is in a nested jar. Such is the case in Spring boot applications where the offline bundles directory may exist inside dependency jars which under BOOT-INV/libs. This is related to [ENHANCEMENT and BUG] Non-blocking getSupportedLocales when fetching messages #877
  2. The java client library tries to access the file system when reading the bundle (code is in LocalMessagesOpt.getComponentMessages). This fails when the file system is in a nested jar.

To Reproduce
Steps to reproduce the behavior:

  1. Build and run the https://github.com/vmware/singleton/tree/g11n-java-client/sample-client-app/sample-app-with-shared-lib as a Spring boot app:
    "gradle -b build-spring-boot.gradle build"
    "java -jar ./build/libs/sample-spring-boot-with-shared-lib-1.0.jar"
    Note: The build-spring-boot.gradle file has to be added. See Adding build file to sample-app-with-shared-lib to build it as Spring Boot app #883.
  2. See the exception.

Expected behavior
No exceptions.
Solutions:

  1. Even if getSupportedLocales had failed, message fetch should not be blocked. This is related to issue [ENHANCEMENT and BUG] Non-blocking getSupportedLocales when fetching messages #877
    Note: Java 11 and below does not support any way to "walk" the file system of a nested jar. Hence, getSupportedLocales is expected to fail for nested jars, but should not block message fetch from resource bundle.
  2. Use getResourceAsStream in LocaleMessagesOpt.getComponentMessages to read the local message bundle which should work for non-jar, jar and nested-jar applications.

Additional context
This was initially reported by the Atlas team.

@lyiyu66
Copy link

lyiyu66 commented Dec 7, 2020

@jessiejuachon
Checked with build on commit 8d7af99, there is an exception about "Failed to get any message for key: global_test_username of component default, requested locale: fr". Looks it can't get the translation from offlineBundles.

image

@jessiejuachon
Copy link
Contributor Author

jessiejuachon commented Dec 7, 2020

Hi @lyiyu66! I am not able to replicate the exception you are seeing. I just did a fresh git clone of the repo and checked out the commit. I did the steps that I put in the README. I did not get any exception:
Screen Shot 2020-12-07 at 8 39 33 AM

@jessiejuachon
Copy link
Contributor Author

jessiejuachon commented Dec 7, 2020

This is what I have before running "java -jar ...". Please check yours.

Screen Shot 2020-12-07 at 8 51 27 AM

If everything is same, could you please test on a Linux or MacOs environment? These are the only things I could think of that could be different between yours and mine.

@lyiyu66
Copy link

lyiyu66 commented Dec 8, 2020

Hi @jessiejuachon , as we talked in Slack, the issue can't be reproducible on Linux.

@jessiejuachon jessiejuachon linked a pull request Dec 8, 2020 that will close this issue
@lyiyu66
Copy link

lyiyu66 commented Dec 11, 2020

The issue and specific Windows issue have been fixed with commit 3678872.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment