BerDecoder readReply(LdapRequest ldr) throws IOException, NamingException {
  BerDecoder rber;
  long elapsedMilli=0;
  long elapsedNano=0;
  while (((rber=ldr.getReplyBer()) == null) && (readTimeout <= 0 || elapsedMilli < readTimeout)) {
    try {
synchronized (this) {
        if (sock == null) {
          throw new ServiceUnavailableException(host + ":" + port+ "; socket closed");
        }
      }
synchronized (ldr) {
        rber=ldr.getReplyBer();
        if (rber == null) {
          if (readTimeout > 0) {
            long beginNano=System.nanoTime();
            ldr.wait(readTimeout - elapsedMilli);
            elapsedNano+=(System.nanoTime() - beginNano);
            elapsedMilli+=elapsedNano / 1000_000;
            elapsedNano%=1000_000;
          }
 else {
            ldr.wait();
          }
        }
 else {
          break;
        }
      }
    }
 catch (    InterruptedException ex) {
      throw new InterruptedNamingException("Interrupted during LDAP operation");
    }
  }
  if ((rber == null) && (elapsedMilli >= readTimeout)) {
    abandonRequest(ldr,null);
    throw new NamingException("LDAP response read timed out, timeout used:" + readTimeout + "ms.");
  }
  return rber;
}

BerDecoder readReply ( LdapRequest ldr ) throws IOException , NamingException { BerDecoder rber ; long elapsedMilli = 0 ; long elapsedNano = 0 ; while ( ( ( rber = ldr . getReplyBer ( ) ) == null ) && ( readTimeout <= 0 || elapsedMilli < readTimeout ) ) { try { synchronized ( this ) { if ( sock == null ) { throw new ServiceUnavailableException ( host + ":" + port + "; socket closed" ) ; } } synchronized ( ldr ) { rber = ldr . getReplyBer ( ) ; if ( rber == null ) { if ( readTimeout > 0 ) { long beginNano = System . nanoTime ( ) ; ldr . wait ( readTimeout - elapsedMilli ) ; elapsedNano += ( System . nanoTime ( ) - beginNano ) ; elapsedMilli += elapsedNano / 1000_000 ; elapsedNano %= 1000_000 ; } else { ldr . wait ( ) ; } } else { break ; } } } catch ( InterruptedException ex ) { throw new InterruptedNamingException ( "Interrupted during LDAP operation" ) ; } } if ( ( rber == null ) && ( elapsedMilli >= readTimeout ) ) { abandonRequest ( ldr , null ) ; throw new NamingException ( "LDAP response read timed out, timeout used:" + readTimeout + "ms." ) ; } return rber ; }
reads a reply ; waits until one is ready .
