Skip to content

Fix CodeQL unused-format-argument and boxed-variable warnings - #208

Open
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix-codeql-warnings-java-cleanups
Open

vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix-codeql-warnings-java-cleanups

Conversation

@vharseko

Copy link
Copy Markdown
Member

Summary

Second warning-level CodeQL batch: the mechanical Java cleanups — 23 alerts across 15 files, no behaviour change beyond log output. (#651/#652 in DateUtil are already covered by the rewrite in #207.)

java/unused-format-argument (#452–#468)

Placeholders reconciled with the arguments actually passed:

  • {} added where the argument was silently dropped: ManagedObjectSet, UpdateManagerImpl, RepoJobStore ×2, RouterConfig, ScriptedRequestHandler
  • ReverseRelationshipValidator: {0}…{3} (MessageFormat style, never expanded by SLF4J) → {}
  • Redundant argument removed instead: MessagingService (subscriber duplicated subscriber.getName()), Activator ×6 (the BundleContext object in "bundle starting/started/stopped" debug lines is noise)
  • FieldStorageSchemeImpl ×3 — the dropped argument was storedField, i.e. the stored password hash. Rather than making the placeholder work, the value is no longer logged at all; password hashes in error logs are an offline-cracking gift.

java/non-null-boxed-variable (#646–#650, #653)

Locals only ever assigned primitives are declared as primitives: DatabaseInfoResourceProvider, ConnectorUtil, GenericTableHandler, TableQueries, CustomCommandScope (Integer.compare), JsonUtil (Double.compare).

Test plan

  • Suites of the touched modules: core 56, maintenance 115, messaging 1, quartz-fragment 8, repo-jdbc 1, router 2, script 8, util 55, provisioner-openicf 136, shell 8 — 0 failures; infoservice compiles (no tests)
  • CodeQL on this PR closes #452–#468, #646–#650, #653

Side note for maintainers (not addressed here): BundleHandlerTest in openidm-maintenance is not idempotent — it leaves target/test-classes/bundleHandler/felix-cache behind and fails on the next run without mvn clean (Bundle symbolic name and version are not unique).

- Match SLF4J placeholders to their arguments in ManagedObjectSet,
  ReverseRelationshipValidator, UpdateManagerImpl, MessagingService,
  RepoJobStore, Activator, RouterConfig and ScriptedRequestHandler
- FieldStorageSchemeImpl: stop passing the stored password hash to the
  logger at all instead of adding a placeholder for it
- Use primitives for locals that are never null in
  DatabaseInfoResourceProvider, ConnectorUtil, GenericTableHandler,
  TableQueries, CustomCommandScope and JsonUtil

Resolves CodeQL alerts #452-#468, #646-#650, #653.
@vharseko vharseko added java Pull requests that update Java code refactor Code refactoring without behavior change security Security fix / CVE remediation labels Sep 18, 2026
if (PREFIX_INT.equals(tokenParts[0])) {
// handle single integer value
Integer int_value = Integer.parseInt(objValue.toString());
int int_value = Integer.parseInt(objValue.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code refactor Code refactoring without behavior change security Security fix / CVE remediation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants