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: Update current UI instance upon locale change #11725

Merged
merged 6 commits into from
Sep 7, 2021

Conversation

mshabarov
Copy link
Contributor

@mshabarov mshabarov commented Sep 2, 2021

Description

Sets the UI on which the locale is being changed as a current UI for the thread. This is needed to have a proper UI.getCurrent() instance inside the executed locale change observers in components.

Fixes #11599

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

Additional for Feature type of change

  • Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.

@denis-anisimov denis-anisimov self-requested a review September 6, 2021 11:04

private void registerLocaleUpdate(boolean sameUIcheckUp) {
VaadinSession session = VaadinSession.getCurrent();
session.lock();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it needed ?
Every Flow listener should be called under the session lock arelady.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's not needed. VaadinSession::setLocale checks that it already has a lock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


private LocaleUpdates getLocaleUpdates() {
VaadinSession session = VaadinSession.getCurrent();
session.lock();
Copy link
Contributor

Choose a reason for hiding this comment

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

Again: is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No.
Done.

@vaadin-bot
Copy link
Collaborator

SonarQube analysis reported 3 issues

  1. MAJOR VaadinSession.java#L201: This block of commented-out lines of code should be removed. rule
  2. MAJOR VaadinSession.java#L1066: Make the "java.util.Map" class "Serializable" or don't write it. rule
  3. INFO VaadinSession.java#L79: Do not forget to remove this deprecated code someday. rule

@vaadin-bot
Copy link
Collaborator

Hi @mshabarov and @mshabarov, when i performed cherry-pick to this commit to 2.7, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick 18dc465
error: could not apply 18dc465... fix: Update current UI instance upon locale change (#11725)
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add ' or 'git rm '
hint: and commit the result with 'git commit'

@vaadin-bot
Copy link
Collaborator

Hi @mshabarov and @mshabarov, when i performed cherry-pick to this commit to 2.6, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick 18dc465
error: could not apply 18dc465... fix: Update current UI instance upon locale change (#11725)
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add ' or 'git rm '
hint: and commit the result with 'git commit'

vaadin-bot added a commit that referenced this pull request Sep 7, 2021
vaadin-bot added a commit that referenced this pull request Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NullPointerException in StateNode when setting locale and using UI.getCurrent() inside localeChange callback.
4 participants