[BEEPbuilders] [beepcore] Caught NPE on SessionEvent.toString() when receivingsession close event

Daan Hoogland daan.hoogland at luminis.nl
Mon Jun 20 15:50:23 PDT 2005


Christian Möller wrote:

>Dann Martens schrieb:
>  
>
>>I'll start posting my patches ASAP, together with the rationale for each
>>change or fix.
>>    
>>
>
>OK, back to the initial problem: Seems that
>org.beepcore.beep.transport.tcp.TCPSession.processNextFrame(), line 464
>sets socket refernce to NULL prematurely:
>
>	} catch (IOException e) {
>		log.error(e);
>
>		socket = null; // <== HERE
>
>		terminate(e.getMessage());
>	}
>
>Next call to "terminate" method will invoke session listeners further
>down the call chain (via "super.terminate(reason)", line 213). On the
>other hand the "toString" method references the socket variable.
>Changing the calls according to this will banish the NPE:
>
>	} catch (IOException e) {
>		log.error(e);
>		terminate(e.getMessage());
>		socket = null;
>	}
>
>Maybe it would be better setting socket variable to NULL within a
>finally block? Maybe it's not worth the effort because within the body
>of "terminate" the socket will be closed and the reference discarded anyway.
>  
>
I see your point about the finally and I don't see how either the socket
field or the terminate method are ever going to be abstracted out of the
session class, so I'd go for moving of the "= null" line.

>  
>
>>P.S. Does everybody have the O'Reilly BEEP book, for reference ?
>>    
>>
>Yes
>
>Christian
>  
>


-- 
<insert your favorite astute quote here />
-----------------------------
Daan Hoogland
software architect
-----------------------------
daan.hoogland at luminis.nl
0620442544
www.luminis.nl
-----------------------------
<or here />



More information about the BEEPbuilders mailing list