rhtyd commented on a change in pull request #4186:
URL: https://github.com/apache/cloudstack/pull/4186#discussion_r448090314



##########
File path: engine/schema/src/main/java/com/cloud/user/dao/AccountDaoImpl.java
##########
@@ -157,9 +157,16 @@ public AccountDaoImpl() {
 
     @Override
     public List<AccountVO> findAccountsLike(String accountName) {
+        return findAccountsLike(accountName, null);
+    }
+
+    @Override
+    public List<AccountVO> findAccountsLike(String accountName, Filter filter) 
{
         SearchCriteria<AccountVO> sc = createSearchCriteria();
-        sc.addAnd("accountName", SearchCriteria.Op.LIKE, "%" + accountName + 
"%");
-        return listBy(sc);
+        if (accountName != null) {

Review comment:
       @davidjumani Optional [1] allows avoiding NPEs while gives a way to 
check if say a String is present, null etc. Your check is okay, but maybe add a 
`Strings.isNullOrEmpty` instead to avoid search criteria clause for empty 
accountName.
   [1] https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to