Source:
<code>public org.dspace.rest.common.Collection[] getCollections(@QueryParam("expand") String expand, @QueryParam("limit") @DefaultValue("100") Integer limit, @QueryParam("offset") @DefaultValue("0") Integer offset, @QueryParam("userIP") String user_ip, @QueryParam("userAgent") String user_agent, @QueryParam("xforwarderfor") String xforwarderfor, @Context HttpHeaders headers, @Context HttpServletRequest request) throws WebApplicationException { log.info("Reading all collections.(offset=" + offset + ",limit=" + limit + ")"); org.dspace.core.Context context = null; List<Collection> collections = new ArrayList<Collection>(); try { context = createContext(getUser(headers)); org.dspace.content.Collection[] dspaceCollections; if (!((limit != null) && (limit >= 0) && (offset != null) && (offset >= 0))) { log.warn("Pagging was badly set."); limit = 100; offset = 0; } dspaceCollections = org.dspace.content.Collection.findAll(context); for (int i = offset; i < limit + offset; i++) { <START> if (AuthorizeManager.authorizeActionBoolean(context, dspaceCollections[i], org.dspace.core.Constants.READ)) <END> { Collection collection = new org.dspace.rest.common.Collection(dspaceCollections[i], null, context, limit, offset); collections.add(collection); writeStats(dspaceCollections[i], UsageEvent.Action.VIEW, user_ip, user_agent, xforwarderfor, headers, request); } } context.complete(); } catch (SQLException e) { processException("Something went wrong while reading collections from database. Message: " + e, context); } catch (ContextException e) { processException("Something went wrong while reading collections, ContextError. Message: " + e.getMessage(), context); } finally { processFinally(context); } log.trace("All collections were successfully read."); return collections.toArray(new org.dspace.rest.common.Collection[0]); }</code><technical_language>dspaceCollections[i] NPE. i.e. if site 5 collections, limit is 100. So, 0,1,2,3,4, 5..99 NPE. If fix findAll(context, limit, offset) above, a safer way..</technical_language>

Target:
public org.dspace.rest.common.Collection[] getCollections(@QueryParam("expand") String expand, @QueryParam("limit") @DefaultValue("100") Integer limit, @QueryParam("offset") @DefaultValue("0") Integer offset, @QueryParam("userIP") String user_ip, @QueryParam("userAgent") String user_agent, @QueryParam("xforwarderfor") String xforwarderfor, @Context HttpHeaders headers, @Context HttpServletRequest request) throws WebApplicationException { log.info("Reading all collections.(offset=" + offset + ",limit=" + limit + ")"); org.dspace.core.Context context = null; List<Collection> collections = new ArrayList<Collection>(); try { context = createContext(getUser(headers)); if (!((limit != null) && (limit >= 0) && (offset != null) && (offset >= 0))) { log.warn("Paging was badly set."); limit = 100; offset = 0; } org.dspace.content.Collection[] dspaceCollections = org.dspace.content.Collection.findAll(context, limit, offset); for(org.dspace.content.Collection dspaceCollection : dspaceCollections) { if (AuthorizeManager.authorizeActionBoolean(context, dspaceCollection, org.dspace.core.Constants.READ)) { Collection collection = new org.dspace.rest.common.Collection(dspaceCollection, null, context, limit, offset); collections.add(collection); writeStats(dspaceCollection, UsageEvent.Action.VIEW, user_ip, user_agent, xforwarderfor, headers, request); } } context.complete(); } catch (SQLException e) { processException("Something went wrong while reading collections from database. Message: " + e, context); } catch (ContextException e) { processException("Something went wrong while reading collections, ContextError. Message: " + e.getMessage(), context); } finally { processFinally(context); } log.trace("All collections were successfully read."); return collections.toArray(new org.dspace.rest.common.Collection[0]); }