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 singleton CoreContext usage #5292

Merged
merged 1 commit into from
Mar 11, 2021

Conversation

ghubstan
Copy link
Member

@ghubstan ghubstan commented Mar 10, 2021

After GrpcServer builds a gRPC server instance, it calls injected CoreContext#setApiUser(true). The same, singleton CoreContext instance is injected into CoreService constructors, which use the coreContext#isApiUser value (set true by the server builder) to set their own class level boolean isApiUser fields.

When CoreContext was added, I was fooled by the correct behavior I saw while stepping through the server debugger. But now I see that the correct boolean value in CoreContext is only available after CoreService constructors have finished instantiating themselves -- not in time.

In this change, the isApiUser field is removed from CoreServices, CoreContext coreContext becomes a class level final field in CoreServices, and the correct coreContex.isApiUser value is available in the CoreService methods.

This PR is the first in a new API PR chain.

After GrpcServer builds a gRPC server instance, it calls injected
CoreContext#setApiUser(true).  The same, singleton CoreContext object
is injected into CoreService constructors, which use the coreContext#
isApiUser value (set true by the server builder) to set their own class
level boolean isApiUser fields.

When CoreContext was added, I was fooled by the correct behavior I
saw while stepping through the server debugger.  But now I see that
the correct boolean value in CoreContext is only available after
CoreService constructors have finished instantiating themselves -
- not in time.

In this change, the CoreContext becomes a class level final field
in CoreServices, and the correct coreContex.isApiUser value is available
in the CoreService methods.
Copy link
Member

@sqrrm sqrrm left a comment

Choose a reason for hiding this comment

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

utACK

@sqrrm sqrrm merged commit edbac95 into bisq-network:master Mar 11, 2021
@ghubstan ghubstan deleted the 00-fix-corecontext-usage branch March 18, 2021 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants