Buggy code:
Assert . assertFalse ( response . containsHeader ( REPLACED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( REMOVED_ATTRIBUTES ) ) ; Assert . assertTrue ( response . containsHeader ( BOUND_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( UNBOUND_ATTRIBUTES ) ) ; Assert . assertEquals ( response . getFirstHeader ( SESSION_ID ) . getValue ( ) , response . getFirstHeader ( CREATED_SESSIONS ) . getValue ( ) ) ; Assert . assertEquals ( "a" , response . getFirstHeader ( ADDED_ATTRIBUTES ) . getValue ( ) ) ; Assert . assertEquals ( "6" , response . getFirstHeader ( BOUND_ATTRIBUTES ) . getValue ( ) ) ; } finally { org . apache . http . client . utils . HttpClientUtils . closeQuietly ( response ) ; } response = client . execute ( new org . apache . http . client . methods . HttpGet ( SessionOperationServlet . createGetURI ( baseURL2 , "a" , "7" ) ) ) ; try { Assert . assertEquals ( SC_OK , response . getStatusLine ( ) . getStatusCode ( ) ) ; Assert . assertTrue ( response . containsHeader ( RESULT ) ) ; Assert . assertEquals ( "6" , response . getFirstHeader ( RESULT ) . getValue ( ) ) ; Assert . assertTrue ( response . containsHeader ( SESSION_ID ) ) ; Assert . assertFalse ( response . containsHeader ( CREATED_SESSIONS ) ) ; Assert . assertFalse ( response . containsHeader ( DESTROYED_SESSIONS ) ) ; Assert . assertFalse ( response . containsHeader ( ADDED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( REPLACED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( REMOVED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( BOUND_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( UNBOUND_ATTRIBUTES ) ) ; } finally { org . apache . http . client . utils . HttpClientUtils . closeQuietly ( response ) ; } response = client . execute ( new org . apache . http . client . methods . HttpGet ( SessionOperationServlet . createGetURI ( baseURL2 , "a" ) ) ) ; try { Assert . assertEquals ( SC_OK , response . getStatusLine ( ) . getStatusCode ( ) ) ; Assert . assertTrue ( response . containsHeader ( RESULT ) ) ; Assert . assertEquals ( "7" , response . getFirstHeader ( RESULT ) . getValue ( ) ) ; Assert . assertTrue ( response . containsHeader ( SESSION_ID ) ) ; Assert . assertFalse ( response . containsHeader ( CREATED_SESSIONS ) ) ; Assert . assertFalse ( response . containsHeader ( DESTROYED_SESSIONS ) ) ; Assert . assertFalse ( response . containsHeader ( ADDED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( REPLACED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( REMOVED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( BOUND_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( UNBOUND_ATTRIBUTES ) ) ; } finally { org . apache . http . client . utils . HttpClientUtils . closeQuietly ( response ) ; } response = client . execute ( new org . apache . http . client . methods . HttpGet ( SessionOperationServlet . createTimeoutURI ( baseURL1 , 1 ) ) ) ; String sessionId = null ; try { Assert . assertEquals ( SC_OK , response . getStatusLine ( ) . getStatusCode ( ) ) ; Assert . assertFalse ( response . containsHeader ( RESULT ) ) ; Assert . assertTrue ( response . containsHeader ( SESSION_ID ) ) ; Assert . assertFalse ( response . containsHeader ( CREATED_SESSIONS ) ) ; Assert . assertFalse ( response . containsHeader ( DESTROYED_SESSIONS ) ) ; Assert . assertFalse ( response . containsHeader ( ADDED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( REPLACED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( REMOVED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( BOUND_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( UNBOUND_ATTRIBUTES ) ) ; sessionId = response . getFirstHeader ( SESSION_ID ) . getValue ( ) ; } finally { org . apache . http . client . utils . HttpClientUtils . closeQuietly ( response ) ; } Thread . sleep ( 2000 ) ; <START_BUG> response = client . execute ( new org . apache . http . client . methods . HttpGet ( SessionOperationServlet . createGetURI ( baseURL1 , "a" ) ) ) ; <END_BUG> try { Assert . assertEquals ( SC_OK , response . getStatusLine ( ) . getStatusCode ( ) ) ; Assert . assertFalse ( response . containsHeader ( RESULT ) ) ; Assert . assertTrue ( response . containsHeader ( SESSION_ID ) ) ; Assert . assertTrue ( response . containsHeader ( CREATED_SESSIONS ) ) ; Assert . assertTrue ( response . containsHeader ( DESTROYED_SESSIONS ) ) ; Assert . assertFalse ( response . containsHeader ( ADDED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( REPLACED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( REMOVED_ATTRIBUTES ) ) ; Assert . assertFalse ( response . containsHeader ( BOUND_ATTRIBUTES ) ) ; Assert . assertTrue ( response . containsHeader ( UNBOUND_ATTRIBUTES ) ) ; Assert . assertEquals ( sessionId , response . getFirstHeader ( DESTROYED_SESSIONS ) . getValue ( ) ) ; Assert . assertEquals ( response . getFirstHeader ( SESSION_ID ) . getValue ( ) , response . getFirstHeader ( CREATED_SESSIONS ) . getValue ( ) ) ; Assert . assertEquals ( "7" , response . getFirstHeader ( UNBOUND_ATTRIBUTES ) . getValue ( ) ) ; } finally { org . apache . http . client . utils . HttpClientUtils . closeQuietly ( response ) ; } } finally { org . apache . http . client . utils . HttpClientUtils . closeQuietly ( client ) ; } } }

Fix:
response = client . execute ( new org . apache . http . client . methods . HttpGet ( SessionOperationServlet . createGetURI ( baseURL2 , "a" ) ) ) ;