apache/hadoop · error · IllegalStateException

Factory is not in CLIENT mode. Actual mode is

Error message

Factory is not in CLIENT mode. Actual mode is {}

What it means

SSLFactory.createSSLSocketFactory requires the factory to be configured in CLIENT mode; the mode is SERVER (or unreadable), so a client SSLSocketFactory cannot be produced from this instance — createSSLServerSocketFactory should be used instead.

Solutions

  1. Initialize the SSLFactory in CLIENT mode (sslFactory.init with Mode.CLIENT) before requesting client SSL socket factories.
  2. Check the calling code path: server-mode code is invoking a client-only SSLFactory method.
  3. Use separate SSLFactory instances for client and server usage.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLFactory.java:321 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/d3b4dc4bb0405619. Report an issue: GitHub.

Appendix: source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLFactory.java:321

      throw new IllegalStateException(
          "Factory is not in SERVER mode. Actual mode is " + mode.toString());
    }
    return context.getServerSocketFactory();
  }

  /**
   * Returns a configured SSLSocketFactory.
   *
   * @return the configured SSLSocketFactory.
   * @throws GeneralSecurityException thrown if the SSLSocketFactory could not
   * be initialized.
   * @throws IOException thrown if and IO error occurred while loading
   * the server keystore.
   */
  public SSLSocketFactory createSSLSocketFactory()
    throws GeneralSecurityException, IOException {
    if (mode != Mode.CLIENT) {
      throw new IllegalStateException(
          "Factory is not in CLIENT mode. Actual mode is " + mode.toString());
    }
    return socketFactory;
  }

  /**
   * Returns the hostname verifier it should be used in HttpsURLConnections.
   *
   * @return the hostname verifier.
   */
  public HostnameVerifier getHostnameVerifier() {
    if (mode != Mode.CLIENT) {
      throw new IllegalStateException(
          "Factory is not in CLIENT mode. Actual mode is " + mode.toString());
    }
    return hostnameVerifier;
  }

View on GitHub (pinned to 2add963021)