code: private static List<DiscoveryIncomingMessage> collectIncomingMessages(int pTimeout, List<Future<List<DiscoveryIncomingMessage>>> pFutures, LogHandler pLogHandler) throws UnknownHostException {
          List<DiscoveryIncomingMessage> ret = new ArrayList<DiscoveryIncomingMessage>();
          Set<String> seen = new HashSet<String>();
          int nrCouldntSend = 0;
          for (Future<List<DiscoveryIncomingMessage>> future : pFutures) {
              try {
                  List<DiscoveryIncomingMessage> inMsgs = future.get(pTimeout + 500 /* some additional buffer */, TimeUnit.MILLISECONDS);
                  for (DiscoveryIncomingMessage inMsg : inMsgs) {
                      AgentDetails details = inMsg.getAgentDetails();
                      String id = details.getAgentId();
                      // There can be multiples answers with the same message id
                      if (!seen.contains(id)) {
                          ret.add(inMsg);
                          seen.add(id);
                      }
                  }
              } catch (InterruptedException exp) {
                  // Try next one ...
              } catch (ExecutionException e) {
                  Throwable exp = e.getCause();
                  if (exp instanceof CouldntSendDiscoveryPacketException) {
                      nrCouldntSend++;
                      pLogHandler.debug("--> Couldnt send discovery message from " +
                                        ((CouldntSendDiscoveryPacketException) exp).getAddress() + ": " + exp.getCause());
                  }
                  // Didn't worked a given address, which can happen e.g. when multicast is not routed or in other cases
                  // throw new IOException("Error while performing a discovery call " + e,e);
                  pLogHandler.debug("--> Exception during lookup: " + e);
              } catch (TimeoutException e) {
                  // Timeout occurred while waiting for the results. So we go to the next one ...
              }
          }
          if (nrCouldntSend == pFutures.size()) {
              // No a single discovery message could be send out
              throw new UnknownHostException("Cannot send a single multicast recovery request on any multicast enabled interface");
          }
          return ret;
      }
docs: Collect the incoming messages and filter out duplicates