Open yudnkuku opened 5 years ago
- In your
HttpUtil.parseHttpRequest()
method: the variablebodyEndIndex
should bebodyStartIndex + httpHeaders.contentLength + 1
rather thanbodyStartIndex + httpHeaders.contentLength
- In your
Message.writePartialMessageToMessage
method: the variablestartIndexOfPartialMessage
should just beendIndex + 1
rather thanmessage.offset + endIndex
. the variablelengthOfPartialMessage
should be(message.offset + message.length) - endIndex + 1
rather than(message.offset + message.length) - endIndex
- I got a NPE when invoking the
HttpMessageReader.read()
.The code snippet is shown below:Message message = this.messageBuffer.getMessage; //the return message might be null message.metadata = new HttpHeaders(); //the NPE occurs here
To solve the problem,I add some code in your
QueueIntFlip.take()
method:if(!flipped){ //add this if if(readPos == capacity) { readPos = 0; } if(readPos < writePos){ return elements[readPos++]; } else { return -1; } }
I think the variable startIndexOfPartialMessage
should be endIndex
, not bodyStartIndex + httpHeaders.contentLength
or endIndex + 1
, since the endIndex does point to the next byte of a http message body end(the implementation can be found in the HttpUtil.parseHttpRequest
method),
Additionally, I dont think the code
if(!flipped){
//add this if
if(readPos == capacity) {
readPos = 0;
}
if(readPos < writePos){
return elements[readPos++];
} else {
return -1;
}
}
``` that you mentioned is right, because if you do that, in the case ` writePos == capacity readPos == capacity flipped == false` which means the all the MessageBuffer blocks are free, then you call the `take()` function again, the `readPos` will be 0, and the writePos and flipped wont be changed, that cause a repeated reading.
In your
HttpUtil.parseHttpRequest()
method: the variablebodyEndIndex
should bebodyStartIndex + httpHeaders.contentLength + 1
rather thanbodyStartIndex + httpHeaders.contentLength
In your
Message.writePartialMessageToMessage
method: the variablestartIndexOfPartialMessage
should just beendIndex + 1
rather thanmessage.offset + endIndex
. the variablelengthOfPartialMessage
should be(message.offset + message.length) - endIndex + 1
rather than(message.offset + message.length) - endIndex
I got a NPE when invoking the
HttpMessageReader.read()
.The code snippet is shown below:To solve the problem,I add some code in your
QueueIntFlip.take()
method: