Instance of current user in Business logic

When I get successful callback from loginWithGooglePlusSdk (with argument stayLoggedIn set to true) I’m calling some custom event from an Android client in this way:

    Backendless.Events.dispatch("createGroup", args, new AsyncCallback<Map>() {...})

At a server side, I would like to get an instance of a current user but the method Backendless.UserService.CurrentUser() always returns null value. But if I call Backendless.UserService.findById(context.getUserId()) then the instance of user is provided.

Business logic:

@BackendlessEvent("createGroup")
    public class GroupCreationEventHandler extends CustomEventHandler {
        @Override
        public Map handleEvent(final RunnerContext context, Map eventArgs) {
            try {
                BackendlessUser currentUser =  Backendless.UserService.CurrentUser(); // This is returning null value
                BackendlessUser user = Backendless.UserService.findById(context.getUserId()); // This returns instance of current user
            } catch(Exception e) {
                e.printStackTrace();
            }
            HashMap<String, String> bla = new HashMap<String, String>();
            bla.put("key", "behemoth");
            return bla;
        }
    }

I would like to know why is this happening?

Hello,

The implementation of the CurrentUser() method does not fetch any data from the server, it simply returns the user object if it is available:

What you’re doing with the findById call is exactly how a user object should be retrieved on the server-side.

Regards,
Mark

Cool, thank you Mark!

Regards