You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Mushthaq Rumy (Jira)" <ji...@apache.org> on 2021/09/30 07:19:00 UTC

[jira] [Updated] (HTTPCORE-687) High CPU usage noticed for requests with newline characters

     [ https://issues.apache.org/jira/browse/HTTPCORE-687?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mushthaq Rumy updated HTTPCORE-687:
-----------------------------------
    Description: 
We are using the 4.4.14 of HttpCore NIO. We are having an issue while sending a request to the server with additional newline characters where the CPU usage seems to increase and stays on forever. We debugged and found out that after the HTTPS response is written back to the client, the server tries to close the connection and the SSLIOSession. Furthermore, we found out that the condition [1] which gets executed in order to make the state as closed becomes false forever and hence it keeps on trying to close and results in the CPU spike.

After further debugging we found out that the after a certain point the *position* is always less than the *limit* and the state is set to *COMPLETED* in the parse method of AbstractMessageParser.java [2], even though there are more lines to be read.

In order to resolve this we did a small fix as shown in *FixCPUSpike.png.*

We have attached a sample client and a server in order to reproduce the issue.

Appreciate your help on this in resolving this issue.

 

[1] - [https://github.com/apache/httpcomponents-core/blob/rel/v4.4.14/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java#L389]

[2] - [https://github.com/apache/httpcomponents-core/blob/rel/v4.4.14/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java#L186-L241]

 

Thanks,
 Mushthaq

 

  was:
We are using the 4.4.14 of HttpCore NIO. We are having an issue while sending a request to the server with additional newline characters where the CPU usage seems to increase and stays on forever. We debugged and found out that after the HTTPS response is written back to the client, the server tries to close the connection and the SSLIOSession. Furthermore, we found out that the condition [1] which gets executed in order to make the state as closed becomes false forever and hence it keeps on trying to close and results in the CPU spike.

After further debugging we found out that the after a certain point the *position* is always less than the *limit* and the state is set to *COMPLETED* in** parse method in AbstractMessageParser.java [2], even though there are more lines to be read.

In order to resolve this we did a small fix as shown in *FixCPUSpike.png*

We have attached a sample client and a server in order to reproduce the issue.


Appreciate your help on this.

 

[1] - [https://github.com/apache/httpcomponents-core/blob/rel/v4.4.14/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java#L389]

[2] - [https://github.com/apache/httpcomponents-core/blob/rel/v4.4.14/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java#L186-L241]

 

Thanks,
Mushthaq

 


> High CPU usage noticed for requests with newline characters
> -----------------------------------------------------------
>
>                 Key: HTTPCORE-687
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-687
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore, HttpCore NIO
>    Affects Versions: 4.4.14
>         Environment: Oracle JDK 1.8.0_211
> Oracle JDK 11.0.9
>            Reporter: Mushthaq Rumy
>            Priority: Major
>         Attachments: CPUHigh-ScreenRecording.mov, FixCPUSpike.png, HttpNIOTestServer.zip, testclient 2.zip
>
>
> We are using the 4.4.14 of HttpCore NIO. We are having an issue while sending a request to the server with additional newline characters where the CPU usage seems to increase and stays on forever. We debugged and found out that after the HTTPS response is written back to the client, the server tries to close the connection and the SSLIOSession. Furthermore, we found out that the condition [1] which gets executed in order to make the state as closed becomes false forever and hence it keeps on trying to close and results in the CPU spike.
> After further debugging we found out that the after a certain point the *position* is always less than the *limit* and the state is set to *COMPLETED* in the parse method of AbstractMessageParser.java [2], even though there are more lines to be read.
> In order to resolve this we did a small fix as shown in *FixCPUSpike.png.*
> We have attached a sample client and a server in order to reproduce the issue.
> Appreciate your help on this in resolving this issue.
>  
> [1] - [https://github.com/apache/httpcomponents-core/blob/rel/v4.4.14/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java#L389]
> [2] - [https://github.com/apache/httpcomponents-core/blob/rel/v4.4.14/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java#L186-L241]
>  
> Thanks,
>  Mushthaq
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org