Apply Java naming conventions and behavior-preserving idiom cleanup#10
Merged
Conversation
Behavior-preserving cleanup of the java-saml sources. No public or
protected API changes (class/method/field/constant/enum names, signatures,
and constant values are all unchanged), so downstream consumers are
unaffected. The full test suite passes unchanged (core 415, toolkit 92).
Naming (locals, private fields, and private methods only; public accessor
names left untouched):
- Fix the leading-uppercase local `AssertionDataNodes` -> `assertionDataNodes`.
- Fix snake_case (`cert_begin`/`end_cert`), acronym casing (`nameID`,
`spX509cert`, `wantXMLValidation`, `uniqueIDPrefix`, ...), and typos
(`errorAcumulator`, `stausCode`, `childs`, `decompresser`,
`idpDescryptorXPath`, `idvalue`, ...).
Idioms (behavior-preserving):
- `size() != 0` -> `isEmpty()`; verbose null checks -> `StringUtils.isNotEmpty`.
- Hoist per-call `HashSet` builds to a static `Set.of(...)`; ternary returns;
drop redundant boxing / `toString()` / parentheses / generic type-witnesses.
- Explicit `"UTF-8"` / `Charset.forName("UTF-8")` -> `StandardCharsets.UTF_8`
(byte-identical); parameterized logging (identical rendered text);
`public final static` -> `public static final`.
Dead code:
- Remove an unused `LOGGER` field and its imports in `IdPMetadataParser`, a
commented-out block and an unused parameter in `SettingsBuilder`, and dead
comment lines in `SamlResponse`.
Samples and tests:
- Fix broken package imports in the sample JSPs (they referenced a
non-existent package and could not compile at runtime).
- Correct stale `@see` package paths in `AuthTest` javadoc.
Preserve the original null contract of `Util.isAlgorithmWhitelisted` (returns
false for a null algorithm) after hoisting its set to an immutable `Set.of`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Behavior-preserving refactor that brings the java-saml sources in line with
standard Java coding conventions and cleans up inconsistent / non-idiomatic
code. No external interface changes — every
public/protectedclass,method, field, constant, and enum keeps its name, signature, and value, so
downstream consumers compile and link unchanged. The full test suite passes
with the same counts as before (core 415, toolkit 92, 0 failures).
Scope was limited to naming fixes, safe idiom modernization, and dead-code
removal (no functional/behavioral changes, no default-value or security
changes).
Naming
Renamed only local variables, private fields, and private methods that
violated Java naming conventions; public accessor names were left exactly
as-is for compatibility:
AssertionDataNodes→assertionDataNodesinSamlResponse.cert_begin/end_cert→certBegin/certEnd).nameID,spX509cert,wantXMLValidation,uniqueIDPrefix,idpx509cert, …) — public getterssuch as
getWantXMLValidation/getUniqueIDPrefix/getSPcertareunchanged; only the private fields they read were renamed.
errorAcumulator,stausCode,childs,decompresser,idpDescryptorXPath,idvalue, …).Idioms (behavior-preserving)
size() != 0→isEmpty();x != null && !x.isEmpty()→StringUtils.isNotEmpty(x).HashSetconstruction into staticSet.of(...)fields.if (…) return true; return false;→return <expr>;;if/elseassign-then-return → ternary.
.toString()/ parentheses / generictype-witnesses.
"UTF-8"/Charset.forName("UTF-8")→StandardCharsets.UTF_8(byte-identical output).
"… " + v→"… {}", v) with identicalrendered text and identical throwable handling.
public static final(waspublic final static)on the
SettingsBuilderproperty-key constants — names, types, and valuesunchanged.
Dead code
LOGGERfield and its imports inIdPMetadataParser.SettingsBuilder.SamlResponse.Samples and tests
non-existent package (a leftover rename artifact) and could not have
compiled at runtime.
@seejavadoc package paths inAuthTest(comment-only).Compatibility and safety notes
algorithm whitelist to an immutable
Set.of(...),Util.isAlgorithmWhitelisted(null)is guarded to keep returningfalse(an immutable set would otherwise throw on
contains(null), where theprevious
HashSetreturnedfalse).name, constant name/value, return type, or
throwsclause changed.Testing
mvn -B test— core 415, toolkit 92, 0 failures / 0 errors / 0 skipped,matching the pre-refactor baseline (no tests added or removed; behavior
unchanged).