diff --git a/src/com/backendless/UserService.java b/src/com/backendless/UserService.java index cfe260ca..d318297c 100644 --- a/src/com/backendless/UserService.java +++ b/src/com/backendless/UserService.java @@ -35,6 +35,7 @@ import com.backendless.utils.ResponderHelper; import weborb.types.Types; +import java.util.Collections; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -686,7 +687,9 @@ public List getUserRoles( String userId ) if( userId == null || userId.isEmpty() ) throw new IllegalArgumentException( ExceptionMessage.NULL_IDENTITY ); - return Arrays.asList( (String[]) Invoker.invokeSync( USER_MANAGER_SERVER_ALIAS, "getUserRoles", new Object[] { userId } ) ); + Object[] objects = Invoker.invokeSync( USER_MANAGER_SERVER_ALIAS, "getUserRoles", new Object[] { userId } ); + + return objects.length == 0 ? Collections.emptyList() : Arrays.asList( (String[]) objects ); } public void getUserRoles( final AsyncCallback> responder ) @@ -709,7 +712,7 @@ public void handleFault( BackendlessFault fault ) responder.handleFault( fault ); } }; - Invoker.invokeAsync( USER_MANAGER_SERVER_ALIAS, "getUserRoles", new Object[] { }, callback ); + Invoker.invokeAsync( USER_MANAGER_SERVER_ALIAS, "getUserRoles", new Object[] {}, callback ); } catch( Throwable e ) { @@ -725,13 +728,13 @@ public void getUserRoles( String userId, final AsyncCallback> respo if( userId == null || userId.isEmpty() ) throw new IllegalArgumentException( ExceptionMessage.NULL_IDENTITY ); - AsyncCallback callback = new AsyncCallback() + AsyncCallback callback = new AsyncCallback() { @Override - public void handleResponse( String[] response ) + public void handleResponse( Object[] response ) { if( responder != null ) - responder.handleResponse( Arrays.asList( response ) ); + responder.handleResponse( response.length == 0 ? Collections.emptyList() : Arrays.asList( (String[]) response ) ); } @Override