Menu

#4 NOT_DISCOVERABLE discovery mode not handled correctly

open
nobody
None
5
2005-10-17
2005-10-17
No

I came across the following bug while trying to set the
discoverable mode to NOT_DISCOVERABLE:

java.lang.IllegalArgumentException: Invalid mode value!

I looked into the source and found that the following line
of code was throwing this error:

if((mode > 0x9E8B3F || mode < 0x9E8B00) &&
(mode != DiscoveryAgent.NOT_DISCOVERABLE ||
mode != DiscoveryAgent.GIAC ||
mode != DiscoveryAgent.LIAC)) throw new
IllegalArgumentException("Invalid mode value!");

I traced the problem back to the following specific part of
the if statement:

(mode > 0x9E8B3F || mode < 0x9E8B00)

The GIAC(0x9E8B33) en LIAC(0x9E8B00) modes are
handled correctly, but the NOT_DISCOVERABLE(0x0) is
not handled correctly by the first if statement

I think the sollutions is simple. Just change the first part
of the if statement to: (mode > 0x9E8B3F || mode <
0x9E8B00 || mode != 0x0).

That should fix it

Discussion


Log in to post a comment.

MongoDB Logo MongoDB