apache/hadoop · error · NoSuchAlgorithmException
No transformation given.
Error message
No transformation given.
What it means
tokenizeTransformation() parses the cipher transformation string before the native cipher is created. A null transformation is rejected immediately with NoSuchAlgorithmException("No transformation given.") rather than causing an NPE inside the parser.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/OpensslCipher.java:158
}
/** Nested class for algorithm, mode and padding. */
private static class Transform {
final String alg;
final String mode;
final String padding;
public Transform(String alg, String mode, String padding) {
this.alg = alg;
this.mode = mode;
this.padding = padding;
}
}
private static Transform tokenizeTransformation(String transformation)
throws NoSuchAlgorithmException {
if (transformation == null) {
throw new NoSuchAlgorithmException("No transformation given.");
}
/*
* Array containing the components of a Cipher transformation:
*
* index 0: algorithm (e.g., AES)
* index 1: mode (e.g., CTR)
* index 2: padding (e.g., NoPadding)
*/
String[] parts = new String[3];
int count = 0;
StringTokenizer parser = new StringTokenizer(transformation, "/");
while (parser.hasMoreTokens() && count < 3) {
parts[count++] = parser.nextToken().trim();
}
if (count != 3 || parser.hasMoreTokens()) {
throw new NoSuchAlgorithmException("Invalid transformation format: " +
transformation);View on GitHub (pinned to 2add963021)
Solutions
- Find why the transformation string is null — usually a missing configuration value — and supply it
- Default to CipherSuite.AES_CTR_NOPADDING.getName() when the config key is unset
- Null-check the transformation before calling getInstance and fail with a descriptive message
Example fix
// before
String suite = conf.get("my.cipher.suite"); // null if unset
Cipher c = OpensslCipher.getInstance(suite); // NoSuchAlgorithmException: No transformation given.
// after
String suite = conf.get("my.cipher.suite", CipherSuite.AES_CTR_NOPADDING.getName());
Cipher c = OpensslCipher.getInstance(suite); Defensive patterns
Strategy: validation
Validate before calling
// Fail fast on missing config
String suite = conf.get("hadoop.security.crypto.cipher.suite");
if (suite == null) {
suite = CipherSuite.AES_CTR_NOPADDING.getName();
}
Cipher c = OpensslCipher.getInstance(suite); Type guard
public String requireTransformation(String t) {
if (t == null || t.trim().isEmpty()) {
throw new IllegalArgumentException("Cipher transformation must be set");
}
return t;
} Try / catch
try {
cipher = OpensslCipher.getInstance(suite);
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("Cipher suite not configured or invalid: " + suite, e);
} Prevention
- Always provide a default when reading suite configuration
- Assert non-null inputs at API boundaries instead of letting them reach the native layer
- Log the effective suite at startup so null/missing values are visible immediately
When it happens
Trigger: Passing a null transformation to OpensslCipher.getInstance() — typically because a configuration key holding the suite name was unset and returned null, or a variable was never initialized.
Common situations: Building the transformation from hadoop.security.crypto.cipher.suite when that key is absent and no default was applied; unit tests passing null; refactors that dropped the suite argument.
Related errors
- Doesn't support algorithm: ${algorithm} and mode: ${mode}
- Doesn't support padding: ${padding}
- Invalid transformation format: ${transformation}
- The OpenSSL native library is built without SM4 CTR support
- tokenStr cannot be null
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/5c8fffa44255ae07.
Report an issue: GitHub.