Exemple #1
0
    protected Object getNextMessage(Object resource) throws Exception {
      Object readMsg = null;
      try {
        readMsg = protocol.read(dataIn);

        if (dataIn.isStreaming()) {
          moreMessages = false;
        }

        return readMsg;
      } catch (SocketTimeoutException e) {
        if (!socket.getKeepAlive()) {
          return null;
        }
      } finally {
        if (readMsg == null) {
          // Protocols can return a null object, which means we're done
          // reading messages for now and can mark the stream for closing later.
          // Also, exceptions can be thrown, in which case we're done reading.
          dataIn.close();
        }
      }

      return null;
    }