JInterface exception handling problem

Gordon Beaton <>
Tue Mar 6 10:39:29 CET 2001


On 2 Mar 2001 23:18:35 GMT, Alexis Lê-Quôc wrote:
> I ran into a problem using Jinterface to send a message to an erlang node,
> and I managed to track it down; I attached a small patch which correct an
> exception handling problem. In order to avoid others spending hours on the
> same problem, here's the how and why:
> 
> I'm using a J-node to send a message using a mailbox to a node called
>  The erlang emulator has been started with the
> flag -sname n1 on the machine called  Thus the node
> will be known by erlang as  This does not look really harmful of a
> mismatch but it actually is and the syptoms are that only one message is
> successfully transmitted to the erlang emulator.
> 
> In OtpNode.getConnection(String node), since there is no initial connection
> between the two nodes, a new OtpCookedConnection will be created and added
> to the connection pool (of the OtpNode) with the name  instead of
>  because in AbstractConnection.receiveChallenge(...)
> overwrites the peer name which will be subsquently inserted into the
> connection pool. The new name is extracted from the erlang emulator reply.
> Nice side effect :-)
> 
> Thus we end up having the 'connections' member of OtpNode have {'':
> ...}. And subsequent calls to mbox.send(, ...) will fail
> because it'll lookup for the full name and not notice that there is already
> a connection to the node.
> 
> This is not quite a bug in JInterface, but detecting the problem is
> particularly difficult because exceptions are black-holed... That's what the
> patch is for.

Actually there is already a mechanism for notifying the application
about this kind of exception, they aren't black-holed. See
OtpNodeStatus.

However through an unfortunate oversight, OtpNode.registerStatusHandler()  
was declared private so it was impossible to register the necessary
callback object (this is now fixed). So a simpler patch would be to
change "private" to "public" in the method declaration.

/gordon

-- 
[ do not send me private copies of your followups ]
g o r d o n . b e a t o n @ e r i c s s o n . c o m
ericsson research
stockholm, sweden



More information about the erlang-questions mailing list