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

[g11n-java-client] Fix for issue #717 - non-supported locales trigger a request to VIP service in a separate thread for every getMessage/getMessages request #738

Merged

Conversation

jessiejuachon
Copy link
Contributor

No description provided.

@jessiejuachon jessiejuachon changed the title Fix for issue #717 [g11n-java-client] Fix for issue #717 - non-supported locales always triggers a request to VIP service in a separate thread Aug 25, 2020
Copy link
Contributor

@Xiaochao8 Xiaochao8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI fails, could you check/

@jessiejuachon
Copy link
Contributor Author

jessiejuachon commented Aug 25, 2020

CI fails, could you check/

@Xiaochao8, it seems like the new license header check is in place even if your PR that updates the year hasn't been merged? Anyway, I have updated for those 2 files.

MessagesDTO fallbackLocaleDTO = new MessagesDTO(dto.getComponent(), cacheItem.getLocale(), dto.getProductID(), dto.getVersion());
cacheItem = new ComponentService(fallbackLocaleDTO).getMessages(null);
}
if (cacheItem.isExpired()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add an 'else' before if?

Copy link
Contributor Author

@jessiejuachon jessiejuachon Aug 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we still want to refresh expired cacheItem even if it is for the fallback locale (returned in line 115).

Copy link
Contributor Author

@jessiejuachon jessiejuachon Aug 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 117-119 is actually not new. It is the fix for #664 and #662

Lines 108-116 is only a replacement for lines 113-115 of old code. See that in old code, there is also no "else", only 2 "ifs"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's necessary to add it because the cache of fallback locale will be refreshed in line 115 because of the call getMessages with default locale.
If no 'else', it will be refreshed twice, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I have updated it.

huihuiw01
huihuiw01 previously approved these changes Aug 25, 2020
@jessiejuachon jessiejuachon changed the title [g11n-java-client] Fix for issue #717 - non-supported locales always triggers a request to VIP service in a separate thread [g11n-java-client] Fix for issue #717 - non-supported locales always trigger a request to VIP service in a separate thread Aug 26, 2020
@jessiejuachon jessiejuachon changed the title [g11n-java-client] Fix for issue #717 - non-supported locales always trigger a request to VIP service in a separate thread [g11n-java-client] Fix for issue #717 - non-supported locales trigger a request to VIP service in a separate thread for every getMessage/getMessages request Aug 26, 2020
if (cacheItem.getCachedData().isEmpty()) { // This means that the data to be used is from a fallback locale.
// If expired, try to first create and store cacheItem for the requested locale in a separate thread.
if (cacheItem.isExpired())
this.createCacheItemTask(fallbackLocalesIter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For creating second time, it doesn't need to do fallback. How about using 'resreshCache' without locale fallback? This will improve performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed line 111 to this.createCacheItemTask(null); Passing null means locale fallback will not be applied.

MessagesDTO fallbackLocaleDTO = new MessagesDTO(dto.getComponent(), cacheItem.getLocale(), dto.getProductID(), dto.getVersion());
cacheItem = new ComponentService(fallbackLocaleDTO).getMessages(null);
}
if (cacheItem.isExpired()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's necessary to add it because the cache of fallback locale will be refreshed in line 115 because of the call getMessages with default locale.
If no 'else', it will be refreshed twice, right?

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