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

Christian Möller dcmoeller at gmx.de
Mon Jun 20 15:30:29 PDT 2005

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) {

		socket = null; // <== HERE


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) {
		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.

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


More information about the BEEPbuilders mailing list