Sorry for the long post, I need to share each line of code.
I created a JAX-RS application using a jersey hosted on a pier server. However, my following code is suitable for an infinite loop. Jetty continues to post messages and removes memory. This only happens when connecting to a CURL client.
Berth server:
public class HttpServer { public static void main(String[] args) throws Exception {
Resource Jax-RS
@Path("/test") public class TestResource { @POST @Consumes("application/json") @Produces("text/html") public Response fillData(String json) { System.out.println(json); return Response.status(200).entity("Successfully updated").build(); } }
Remarks:
- curl query:
curl -H "Content-Type: application/json" -d '{"username":"xyz","password":"xyz"}' http://localhost:8888/test - Posting a request using crome-poster does not cause this problem. Only with CURL!
- CURL returns an OK response and safely exits, but the berth continues to remain in the loop.
- I tried several types of content, but the problem persists.
- The problem is resolved by lowering the berth from 9.3.0.M1 to 9.2.0.M1
Endless loop debug logs:
11:21:40.760 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG org.eclipse.jetty.io.SelectorManager - Selector loop woken up from select, 0/1 selected 11:21:40.761 [qtp1669 854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG org.eclipse.jetty.io.SelectorManager - Running change org.eclipse.jetty.io.SelectChannelEndPoint$1@54ddf089 11:21:40.761 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG oejetty.io.SelectChannelEndPoint - Updating key, state UPDATE_PENDING for SelectChannelEndPoint@55446de5 {/127.0.0.1:55160<->8888,Open,ISHUT,out,R,-,30000,HttpConnection}{io=1,kio=0,kro=1} 11:21:40.761 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG oejetty.io.SelectChannelEndPoint - Key interests update 0 -> 1 for SelectChannelEndPoint@55446de5 {/127.0.0.1:55160<->8888,Open,ISHUT,out,R,-,30000,HttpConnection}{io=1,kio=0,kro=1} 11:21:40.761 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG org.eclipse.jetty.io.SelectorManager - Selector loop waiting on select 11:21:40.761 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG org.eclipse.jetty.io.SelectorManager - Selector loop woken up from select, 1/1 selected 11:21:40.761 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG oejetty.io.SelectChannelEndPoint - Processing, state UPDATED for SelectChannelEndPoint@55446de5 {/127.0.0.1:55160<->8888,Open,ISHUT,out,R,-,30000,HttpConnection}{io=1,kio=1,kro=1} 11:21:40.761 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG oejetty.io.SelectChannelEndPoint - onSelected 1->0 for SelectChannelEndPoint@55446de5 {/127.0.0.1:55160<->8888,Open,ISHUT,out,R,-,30000,HttpConnection}{io=0,kio=1,kro=1} 11:21:40.761 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG oejetty.io.AbstractConnection - FILL_INTERESTED-->FILLING HttpConnection@21c7226e {FILLING} 11:21:40.762 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG oejetty.io.SelectChannelEndPoint - Updating key, state UPDATE_PENDING for SelectChannelEndPoint@55446de5 {/127.0.0.1:55160<->8888,Open,ISHUT,out,-,-,30000,HttpConnection}{io=0,kio=1,kro=1} 11:21:40.762 [qtp1669854350-19] DEBUG oejetty.server.HttpConnection - HttpConnection@21c7226e {FILLING} onFillable HttpChannelState@36dadde6 {s=IDLE i=true a=null} 11:21:40.762 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG oejetty.io.SelectChannelEndPoint - Key interests update 1 -> 0 for SelectChannelEndPoint@55446de5 {/127.0.0.1:55160<->8888,Open,ISHUT,out,-,-,30000,HttpConnection}{io=0,kio=1,kro=1} 11:21:40.762 [qtp1669854350-19] DEBUG org.eclipse.jetty.http.HttpParser - atEOF HttpParser{s=CLOSED,0 of -1} 11:21:40.762 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG org.eclipse.jetty.io.SelectorManager - Selector loop waiting on select 11:21:40.762 [qtp1669854350-19] DEBUG org.eclipse.jetty.http.HttpParser - parseNext s=CLOSED HeapByteBuffer@1 [p=0,l=0,c=0,r=0]={<<<>>>} 11:21:40.762 [qtp1669854350-19] DEBUG oejetty.io.AbstractConnection - fillInterested HttpConnection@21c7226e {FILLING} 11:21:40.762 [qtp1669854350-19] DEBUG oejetty.io.AbstractConnection - FILLING-->FILLING_FILL_INTERESTED HttpConnection@21c7226e {FILLING_FILL_INTERESTED} 11:21:40.762 [qtp1669854350-19] DEBUG oejetty.io.AbstractConnection - FILLING_FILL_INTERESTED-->FILL_INTERESTED HttpConnection@21c7226e {FILL_INTERESTED} 11:21:40.762 [qtp1669854350-19] DEBUG oejetty.io.SelectChannelEndPoint - Changing interests in state UPDATED for SelectChannelEndPoint@55446de5 {/127.0.0.1:55160<->8888,Open,ISHUT,out,R,-,30000,HttpConnection}{io=0,kio=0,kro=1} 11:21:40.762 [qtp1669854350-19] DEBUG oejetty.io.SelectChannelEndPoint - changeInterests s=UPDATED 0->1 for SelectChannelEndPoint@55446de5 {/127.0.0.1:55160<->8888,Open,ISHUT,out,R,-,30000,HttpConnection}{io=0,kio=0,kro=1} 11:21:40.762 [qtp1669854350-19] DEBUG org.eclipse.jetty.io.SelectorManager - Queued change org.eclipse.jetty.io.SelectChannelEndPoint$1@54ddf089 11:21:40.762 [ qtp1669854350-14-selector-ServerConnectorManager@62dfb098 /0] DEBUG org.eclipse.jetty.io.SelectorManager - Selector loop woken
I cannot make much sense from the logs, but there is confidence that Jetty does not close the connection, even when the client has safely logged off. I tried setting a timeout on the marina, but to no avail.
Are there any problems with the code, or there seems to be some bug with the latest version of Jetty. Please note that I am completely naive when developing JAVA EE applications. If this is a mistake, I will report on the Jetty forums.