@Override
  public void initCqListeners(CqListener[] addedListeners) {
    ArrayList<CqListener> oldListeners;
    synchronized (clSync) {
      oldListeners = cqListeners;
      if (addedListeners == null || addedListeners.length == 0) {
        setCqListeners(null);
      } else { // we have some listeners to add
        List nl = Arrays.asList(addedListeners);
        if (nl.contains(null)) {
          throw new IllegalArgumentException(
              "initCqListeners parameter had a null element");
        }
        setCqListeners(new ArrayList(nl));
      }
    }

    if (oldListeners != null) {
      CqListener cql = null;
      for (Iterator<CqListener> iter = oldListeners.iterator(); iter.hasNext();) {
        try {
          cql = iter.next();
          cql.close();
          // Handle client side exceptions.
        } catch (Exception ex) {
          logger.warn("Exception occurred while closing CQ Listener Error: {}",
              ex.getLocalizedMessage());
          if (logger.isDebugEnabled()) {
            logger.debug(ex.getMessage(), ex);
          }
        } catch (VirtualMachineError err) {
          SystemFailure.initiateFailure(err);
          // If this ever returns, rethrow the error. We're poisoned
          // now, so don't let this thread continue.
          throw err;
        } catch (Throwable t) {
          // Whenever you catch Error or Throwable, you must also
          // catch VirtualMachineError (see above). However, there is
          // _still_ a possibility that you are dealing with a cascading
          // error condition, so you also need to check to see if the JVM
          // is still usable:
          SystemFailure.checkFailure();
          logger.warn("Runtime Exception occurred while closing CQ Listener Error: {}",
              t.getLocalizedMessage());
          if (logger.isDebugEnabled()) {
            logger.debug(t.getMessage(), t);
          }
        }
      }
    }
  }
Removes all Cqlisteners, calling on each of them, and then adds each listener in the specified
array.

@param addedListeners a possibly null or empty array of listeners to add to this CqQuery.
@throws IllegalArgumentException if the <code>newListeners</code> array has a null element
geode-core/src/main/java/org/apache/geode/cache/query/internal/cq/CqAttributesImpl.java