Skip to content

Some bug in your code #10

@yudnkuku

Description

@yudnkuku
  • In your HttpUtil.parseHttpRequest() method:
    the variable bodyEndIndex should be bodyStartIndex + httpHeaders.contentLength + 1 rather than bodyStartIndex + httpHeaders.contentLength

  • In your Message.writePartialMessageToMessage method:
    the variable startIndexOfPartialMessage should just be endIndex + 1 rather than message.offset + endIndex.
    the variable lengthOfPartialMessage 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;
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions