251 |
251 |
252 // NOTE: The connection MUST be put in the cache BEFORE being |
252 // NOTE: The connection MUST be put in the cache BEFORE being |
253 // registered with the selector. Otherwise if the bytes |
253 // registered with the selector. Otherwise if the bytes |
254 // are read on the connection it will attempt a time stamp |
254 // are read on the connection it will attempt a time stamp |
255 // but the cache will be null, resulting in NPE. |
255 // but the cache will be null, resulting in NPE. |
|
256 |
|
257 // A connection needs to be timestamped before putting to the cache. |
|
258 // Otherwise the newly created connection (with 0 timestamp) could be |
|
259 // incorrectly reclaimed by concurrent reclaim() call OR if there |
|
260 // will be no events on this connection then it could be reclaimed |
|
261 // by upcoming reclaim() call. |
|
262 getConnectionCache().stampTime(connection); |
256 getConnectionCache().put(this, connection); |
263 getConnectionCache().put(this, connection); |
257 |
264 |
258 if (connection.shouldRegisterServerReadEvent()) { |
265 if (connection.shouldRegisterServerReadEvent()) { |
259 Selector selector = orb.getTransportManager().getSelector(0); |
266 Selector selector = orb.getTransportManager().getSelector(0); |
260 selector.registerForEvent(connection.getEventHandler()); |
267 selector.registerForEvent(connection.getEventHandler()); |