JPPF Issue Tracker
Please log in to bookmark issues
CLOSED  Bug report JPPF-376  -  Method connectAndWait in JMXConnectionWrapper act not like expected
Posted Mar 12, 2015 - updated Aug 15, 2018
icon_info.png This issue has been closed with status "Closed" and resolution "RESOLVED".
Issue details
  • Type of issue
    Bug report
  • Status
  • Assigned to
  • Progress
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
  • Owned by
    Not owned by anyone
  • Category
    Management / Monitoring
  • Resolution
  • Priority
  • Reproducability
  • Severity
  • Targetted for
    icon_milestones.png JPPF 4.2.x
Issue description

mybay I am just wrong, but the method to connect to a JPPF server for management using JMX does not act like I smileys/8.png would expect it.

The javadoc says this:
 * Initiate the connection and wait until the connection is established or the timeout has expired, whichever comes first.
 * @param timeout the maximum time to wait for, a value of zero means no timeout and
 * this method just waits until the connection is established.
If I call the method with a timeout of 10 seconds but the connection is established after 2 seconds, I would expect that the method will return after 2 seconds. Instead the method first checks if the connection is already established. If not, the whole timeout (minus the few milliseconds for the connect()) is taken the value for the sleep. In our example above, the method waits the whole timeout of 10 seconds.

See the code here (taken from 4.2.7):
public void connectAndWait(final long timeout) {
  if (isConnected()) return;
  long start = System.currentTimeMillis();
  long max = timeout > 0 ? timeout : Long.MAX_VALUE;
  long elapsed;
  while (!isConnected() && ((elapsed = System.currentTimeMillis() - start) < max)) goToSleep(max - elapsed);
What is the intended behaviour of the method? Am I wrong?
Steps to reproduce this issue
Call the method connectAndWait() with a few long timeouts like 10, 20, 30 seconds and see, that the method call takes this 10, 20, 30 seconds.

Comment posted by
Mar 12, 23:37
Your analysis is perfectly correct. The problem is that the method performConnection() is missing a wakeUp() call to notify the waiting threads. I thought I had already fixed that, but after looking at the code I relaized it was only fixed in 5.0 but not in 4.2.x.

The fix is implemented in branch b4.2 revision 3627

I have also uploaded it in patch 01 for JPPF 4.2.7
Comment posted by
Mar 13, 08:43
Thanks for the fast explanation and the patch!