[JCBC-157] Unsure if CouchbaseConnectionFactory.pastReconnThreshold really does what it's suppose to do Created: 28/Nov/12  Updated: 03/Dec/12  Resolved: 03/Dec/12

Status: Resolved
Project: Couchbase Java Client
Component/s: Core
Affects Version/s: 1.0.3
Fix Version/s: 1.1-beta
Security Level: Public

Type: Bug Priority: Major
Reporter: Marcus Nylander Assignee: Matt Ingenthron
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment: Oracle Jdk 1.6.0_26

  private boolean pastReconnThreshold() {
    long currentTime = System.nanoTime();
    if (currentTime - thresholdLastCheck > 100000000) { //if longer than 10 sec
      configThresholdCount = 0; // it's been more than 10 sec since last
                                // tried, so don't try again just yet.
    thresholdLastCheck = currentTime;

    if (configThresholdCount >= maxConfigCheck) {
      return true;
    return false;

Does the above really work as expected? It looks strange. 100000000 in nanos is only 100 millis and not 10 seconds as stated in comments.
If there is more than 100 millis between calls we always reset configThresholdCount and will never return true, which seems very strange.

Comment by Michael Nitschinger [ 28/Nov/12 ]
can you take a look at this?
Comment by Michael Nitschinger [ 29/Nov/12 ]
Comment by Marcus Nylander [ 29/Nov/12 ]
Checking the fix. Not that I've looked deeply into what pastReconnThreshold() should do, but just increasing the timeout?
Isn't it more like it should return true every maxConfigCheck calls or return true if last call was more than 10 seconds ago?

Comment by Michael Nitschinger [ 03/Dec/12 ]
fixed and pushed to master, will be available in beta.
Generated at Sat Sep 20 17:34:49 CDT 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.