code: void gatherMessageData(int maxPos) throws IOException {
          try {
              while(this.bufferPosition < maxPos) {
                  int possible = maxPos - this.bufferPosition;
                  int want = msgData.length - msgDataPosition;
  
                  // Grab all we can, until we get to the CR/LF
                  if (want > 0 && want <= possible) {
                      System.arraycopy(this.buffer, this.bufferPosition, this.msgData, this.msgDataPosition, want);
                      msgDataPosition += want;
                      this.bufferPosition += want;
                      continue;
                  } else if (want > 0) {
                      System.arraycopy(this.buffer, this.bufferPosition, this.msgData, this.msgDataPosition, possible);
                      msgDataPosition += possible;
                      this.bufferPosition += possible;
                      continue;
                  }
  
                  byte b = this.buffer[this.bufferPosition];
                  this.bufferPosition++;
  
                  if (gotCR) {
                      if (b == NatsConnection.LF) {
                          incoming.setData(msgData);
                          this.connection.deliverMessage(incoming);
                          msgData = null;
                          msgDataPosition = 0;
                          incoming = null;
                          gotCR = false;
                          this.op = UNKNOWN_OP;
                          this.mode = Mode.GATHER_OP;
                          break;
                      } else {
                          throw new IllegalStateException("Bad socket data, no LF after CR");
                      }
                  } else if (b == NatsConnection.CR) {
                      gotCR = true;
                  } else {
                      throw new IllegalStateException("Bad socket data, no CRLF after data");
                  }
              }
          } catch (IllegalStateException | NullPointerException ex) {
              this.encounteredProtocolError(ex);
          }
      }
docs: given to the message object