diff --git a/server/src/main/java/org/gluu/oxtrust/action/SearchClientAction.java b/server/src/main/java/org/gluu/oxtrust/action/SearchClientAction.java index b8536350d..25b78ed9b 100644 --- a/server/src/main/java/org/gluu/oxtrust/action/SearchClientAction.java +++ b/server/src/main/java/org/gluu/oxtrust/action/SearchClientAction.java @@ -9,6 +9,7 @@ import java.io.Serializable; import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; import javax.enterprise.context.ConversationScoped; import javax.faces.application.FacesMessage; @@ -76,7 +77,10 @@ protected String searchImpl() { } else { this.clientList = clientService.searchClients(this.searchPattern, 100); } - this.clientList.sort(Comparator.comparing(OxAuthClient::getDisplayName)); + this.clientList = this.clientList.stream() + .sorted(Comparator.comparing(OxAuthClient::getDisplayName, + Comparator.nullsFirst(Comparator.naturalOrder()))) + .collect(Collectors.toList()); this.oldSearchPattern = this.searchPattern; this.searchPattern = ""; } catch (Exception ex) {