code: private SecretKeyFactorySpi nextSpi(SecretKeyFactorySpi oldSpi) {
          synchronized (lock) {
              // somebody else did a failover concurrently
              // try that spi now
              if ((oldSpi != null) && (oldSpi != spi)) {
                  return spi;
              }
              if (serviceIterator == null) {
                  return null;
              }
              while (serviceIterator.hasNext()) {
                  Service s = serviceIterator.next();
                  if (JceSecurity.canUseProvider(s.getProvider()) == false) {
                      continue;
                  }
                  try {
                      Object obj = s.newInstance(null);
                      if (obj instanceof SecretKeyFactorySpi == false) {
                          continue;
                      }
                      SecretKeyFactorySpi spi = (SecretKeyFactorySpi)obj;
                      provider = s.getProvider();
                      this.spi = spi;
                      return spi;
                  } catch (NoSuchAlgorithmException e) {
                      // ignore
                  }
              }
              serviceIterator = null;
              return null;
          }
      }
docs: Update the active spi of this class and return the next
  implementation for failover. If no more implemenations are
  available, this method returns null. However, the active spi of
  this class is never set to null.