Skip to content

fix: honour ojp.connection.pool.* properties passed via DriverManager.getConnection() info argument#500

Merged
rrobetti merged 1 commit intomainfrom
copilot/review-ojp-connection-configuration
May 9, 2026
Merged

fix: honour ojp.connection.pool.* properties passed via DriverManager.getConnection() info argument#500
rrobetti merged 1 commit intomainfrom
copilot/review-ojp-connection-configuration

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 9, 2026

Pool configuration keys set in the Properties argument to DriverManager.getConnection(url, info) were silently dropped — the driver read pool settings exclusively from ojp.properties / system properties / env vars, making programmatic overrides (e.g. dynamically computed maximumPoolSize) impossible.

Changes

  • DatasourcePropertiesLoader — new applyInfoProperties(base, info, datasourceName) method that filters ojp.connection.pool.* and ojp.xa.* keys from info and merges them on top of the already-resolved base with the highest precedence. Non-OJP keys (user, password, database-specific params) are deliberately ignored.

  • Driver.connect() — calls applyInfoProperties immediately after loading from file/system/env.

  • DatasourcePropertiesLoaderInfoPropertiesTest — 13 new unit tests covering: null/empty guards, info-only (no file present), info overrides base, XA properties, credential key filtering, and mixed scenarios.

  • Docsojp-jdbc-configuration.md and part2-chapter5-jdbc-configuration.md: added programmatic configuration section with the four-level priority table; corrected the ebook property reference table (wrong bare names and stale defaults).

Priority order after fix

Priority Source
1 (highest) Properties passed to getConnection()
2 Environment variables
3 System properties (-D)
4 ojp.properties file

Usage

Properties info = new Properties();
info.setProperty("user", "alice");
info.setProperty("password", "secret");
// Overrides any value in ojp.properties / env / system props
info.setProperty("ojp.connection.pool.maximumPoolSize", String.valueOf(allocatedMaxConnections));
info.setProperty("ojp.connection.pool.minimumIdle", "3");

Connection conn = DriverManager.getConnection(
    "jdbc:ojp[ojp-server:1059]_postgresql://db:5432/mydb", info);

….getConnection() info arg

- Add DatasourcePropertiesLoader.applyInfoProperties() to merge any
  ojp.connection.pool.* / ojp.xa.* keys from the JDBC info Properties with
  the highest precedence (above env vars, system props, and the file)
- Call applyInfoProperties in Driver.connect() immediately after the
  file/system/env properties are loaded
- Add DatasourcePropertiesLoaderInfoPropertiesTest (13 tests) covering
  null/empty guards, info-only, override, XA, key filtering, and mixed cases
- Update documents/configuration/ojp-jdbc-configuration.md with a new
  "Programmatic Configuration via DriverManager" subsection and priority table
- Update documents/ebook/part2-chapter5-jdbc-configuration.md: fix the
  property reference table (wrong names and defaults), expand the Programmatic
  Configuration section with the priority table and filtering note

Agent-Logs-Url: https://github.com/Open-J-Proxy/ojp/sessions/c5d92d35-acf2-4be2-ad8d-e57ae26b77cb

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 9, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@rrobetti rrobetti marked this pull request as ready for review May 9, 2026 21:44
@rrobetti rrobetti merged commit 9c5912e into main May 9, 2026
52 of 53 checks passed
@rrobetti rrobetti deleted the copilot/review-ojp-connection-configuration branch May 9, 2026 21:45
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.

2 participants