Skip to content

Apply Java naming conventions and behavior-preserving idiom cleanup#10

Merged
marevol merged 1 commit into
mainfrom
refactor-java-conventions
Jul 5, 2026
Merged

Apply Java naming conventions and behavior-preserving idiom cleanup#10
marevol merged 1 commit into
mainfrom
refactor-java-conventions

Conversation

@marevol

@marevol marevol commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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/protected class,
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:

  • The trigger case: the leading-uppercase local AssertionDataNodes
    assertionDataNodes in SamlResponse.
  • snake_case → camelCase (cert_begin/end_certcertBegin/certEnd).
  • acronym casing on private fields (nameID, spX509cert,
    wantXMLValidation, uniqueIDPrefix, idpx509cert, …) — public getters
    such as getWantXMLValidation / getUniqueIDPrefix / getSPcert are
    unchanged; only the private fields they read were renamed.
  • typos (errorAcumulator, stausCode, childs, decompresser,
    idpDescryptorXPath, idvalue, …).

Idioms (behavior-preserving)

  • size() != 0isEmpty(); x != null && !x.isEmpty()
    StringUtils.isNotEmpty(x).
  • Hoisted per-call HashSet construction into static Set.of(...) fields.
  • if (…) return true; return false;return <expr>;; if/else
    assign-then-return → ternary.
  • Dropped redundant boxing / .toString() / parentheses / generic
    type-witnesses.
  • Explicit "UTF-8" / Charset.forName("UTF-8")StandardCharsets.UTF_8
    (byte-identical output).
  • Parameterized SLF4J logging ("… " + v"… {}", v) with identical
    rendered text and identical throwable handling.
  • Canonical modifier order public static final (was public final static)
    on the SettingsBuilder property-key constants — names, types, and values
    unchanged.

Dead code

  • Removed an unused LOGGER field and its imports in IdPMetadataParser.
  • Deleted a commented-out method block and an unused parameter in
    SettingsBuilder.
  • Removed dead commented-out debug lines in SamlResponse.

Samples and tests

  • Fixed broken package imports in the sample JSPs — they referenced a
    non-existent package (a leftover rename artifact) and could not have
    compiled at runtime.
  • Corrected stale @see javadoc package paths in AuthTest (comment-only).

Compatibility and safety notes

  • One null-contract subtlety was handled explicitly: after hoisting the
    algorithm whitelist to an immutable Set.of(...),
    Util.isAlgorithmWhitelisted(null) is guarded to keep returning false
    (an immutable set would otherwise throw on contains(null), where the
    previous HashSet returned false).
  • The public API surface was independently reviewed to confirm no accessor
    name, constant name/value, return type, or throws clause changed.

Testing

  • mvn -B testcore 415, toolkit 92, 0 failures / 0 errors / 0 skipped,
    matching the pre-refactor baseline (no tests added or removed; behavior
    unchanged).

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`.
@marevol marevol merged commit b389dec into main Jul 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant