diff --git a/polls/impl/src/java/org/sakaiproject/poll/service/impl/PollListManagerImpl.java b/polls/impl/src/java/org/sakaiproject/poll/service/impl/PollListManagerImpl.java index c9f07ff9622f..852b6609340e 100644 --- a/polls/impl/src/java/org/sakaiproject/poll/service/impl/PollListManagerImpl.java +++ b/polls/impl/src/java/org/sakaiproject/poll/service/impl/PollListManagerImpl.java @@ -124,16 +124,16 @@ public List findAllPollsForUserAndSitesAndPermission(String userId, String List polls = null; // get all allowed sites for this user List allowedSites = externalLogic.getSitesForUser(userId, permissionConstant); - - if(siteIds!=null && siteIds.length>0 && !allowedSites.isEmpty()){ - List requestedSiteIds = Arrays.asList(siteIds); - // filter down to just the requested ones - allowedSites.retainAll(requestedSiteIds); - if(allowedSites.isEmpty()){ + if (allowedSites.isEmpty()) { // no sites to search so EXIT here - return new ArrayList(); + return new ArrayList<>(); + } else { + if (siteIds != null && siteIds.length > 0) { + List requestedSiteIds = Arrays.asList(siteIds); + // filter down to just the requested ones + allowedSites.retainAll(requestedSiteIds); } - String[] siteIdsToSearch = allowedSites.toArray(new String[allowedSites.size()]); + String[] siteIdsToSearch = allowedSites.toArray(new String[0]); Search search = new Search(); if (siteIdsToSearch.length > 0) { search.addRestriction(new Restriction("siteId", siteIdsToSearch));