code: @Override
      public synchronized Map<String, List<Object>> getHandles(String projectId) throws IOException {
          Map<String, List<Object>> result = new HashMap<String, List<Object>>();
          for (Map.Entry<String, List<Long>> entry : collectionIds.entrySet()) {
              String key = entry.getKey();
  
              // Skip collections for different projects.
              if (!key.startsWith(projectId)) {
                  continue;
              }
  
              // Extract the collection name from the key.
              String eventCollection = key.substring(projectId.length() + 1);
  
              // Iterate over the list of handles, removing any "dead" events and adding the rest to
              // the result map.
              List<Long> ids = entry.getValue();
              List<Object> handles = new ArrayList<Object>();
              Iterator<Long> iterator = ids.iterator();
              while (iterator.hasNext()) {
                  Long id = iterator.next();
                  if (events.get(id) == null) {
                      iterator.remove();
                  } else {
                      handles.add(id);
                  }
              }
              if (handles.size() > 0) {
                  result.put(eventCollection, handles);
              }
          }
          return result;
      }
docs: {@inheritDoc}