Skip to content

Fix MySQL initialization failures and constructor lifecycle safety - #361

Merged
BenCodez merged 4 commits into
masterfrom
fix/mysql-constructor-lifecycle
Oct 11, 2026
Merged

BenCodez merged 4 commits into
masterfrom
fix/mysql-constructor-lifecycle

Conversation

@BenCodez

@BenCodez BenCodez commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

MySQL authentication rejection now aborts user/global SQL initialization without invoking subclass logging before its plugin reference is assigned. Successful construction still initializes the table, caches and UUID schema; a later setup failure closes owned pools/workers and preserves the primary exception. No SQLite fallback, schema/config migration or reward behavior change is introduced.

The accompanying SQL abstraction fix is merged in SimpleAPI #111. The POM now pins the published immutable artifact 1.0.2-20261011.161601-40. CI and normal clean Maven builds resolve the same dependency; no manual SimpleAPI source install is needed. This addresses Codex's clean-build dependency finding. Global database selection also preserves unchecked exception/error identity after cleanup, wrapping only checked SQL exceptions. Three regression tests exercise connection acquisition, statement preparation and execution with runtime, linkage and SQL failures and suppressed cleanup errors. The downloaded MySQL, AbstractSqlTable and ConnectionManager classes were verified byte-for-byte against the merged source candidate. The shaded JAR requires no separate runtime library installation.

Validation for d09f0d891:

  • Focused MySQLInitializationTest: 8 passed, zero failures/errors.
  • Full mvn -B -o -ntp -f AdvancedCore/pom.xml clean package: 1,032 passed, zero failures/errors/skips. Dependency resolution was first exercised online through Maven using the published coordinate.
  • Fresh independent focused source review: No findings. git diff --check passed.
  • Fresh JAR ZIP/Java 21/no test libraries and embedded published SQL classes audited; SHA-256 f8269cf51cbe205f7bee0cb7d169159c7aa0663f3e2dfc3476a870477c9fb6e1 (6,847,410 bytes). A subsequent local install for downstream testing succeeded without rerunning tests.
  • VotingPlugin #1701 downstream clean package against this exact revision passed: 1,985 tests passed, one optional skip, zero failures/errors. Hosted build and both CodeQL analyses pass on d09f0d891; CodeRabbit is rate limited and is not claimed as a fresh clean review.

Tests simulate authentication failure and setup cleanup with mocked JDBC/platform services; no live external MySQL or native Paper/Folia startup verification is claimed. Original authentication denial remains a server credential/permission problem. Merge this before VotingPlugin #1701; do not deploy an old dependency accidentally.

Summary by CodeRabbit

  • Bug Fixes

    • MySQL connection and database-selection failures now stop initialization instead of allowing startup to continue in an incomplete state.
    • Startup failures trigger connection cleanup, while preserving the original error details.
    • Existing data remains unchanged when MySQL startup fails; no SQLite fallback occurs.
  • Documentation

    • Added guidance on MySQL startup failures and building the project.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 276cef38-a8c3-4cc2-a01e-ddef00267f1c









📥 Commits

Reviewing files that changed from the base of the PR and between 6390c1c and a68cc2d.










📒 Files selected for processing (5)
  • .github/workflows/maven.yml
  • AdvancedCore/src/main/java/com/bencodez/advancedcore/api/user/userstorage/mysql/MySQL.java
  • AdvancedCore/src/main/java/com/bencodez/advancedcore/bungeeapi/globaldata/GlobalMySQL.java
  • AdvancedCore/src/test/java/com/bencodez/advancedcore/api/user/userstorage/mysql/MySQLInitializationTest.java
  • docs/mysql-startup-failure.md









Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.










📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: build
  • GitHub Check: Analyze (java-kotlin)
  • GitHub Check: Analyze (actions)
  • GitHub Check: build









🔇 Additional comments (5)
AdvancedCore/src/main/java/com/bencodez/advancedcore/api/user/userstorage/mysql/MySQL.java (1)

52-64: LGTM!


AdvancedCore/src/test/java/com/bencodez/advancedcore/api/user/userstorage/mysql/MySQLInitializationTest.java (1)

1-132: LGTM!


docs/mysql-startup-failure.md (1)

1-43: LGTM!


AdvancedCore/src/main/java/com/bencodez/advancedcore/bungeeapi/globaldata/GlobalMySQL.java (1)

109-126: LGTM!


.github/workflows/maven.yml (1)

25-35: LGTM!

Also applies to: 37-37












📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

MySQL initialization now stops when connection or setup fails and closes opened connections. Tests cover failure and successful closure paths. CI installs a pinned SimpleAPI revision before packaging AdvancedCore, and the documentation describes startup behavior and build steps.

Changes

MySQL startup failure handling

Layer / File(s) Summary
MySQL initialization and cleanup
AdvancedCore/src/main/java/com/bencodez/advancedcore/api/user/userstorage/mysql/MySQL.java, AdvancedCore/src/test/java/com/bencodez/advancedcore/api/user/userstorage/mysql/MySQLInitializationTest.java, docs/mysql-startup-failure.md
The MySQL constructor closes the connection when guarded setup fails and rethrows the failure. Tests cover rejected authentication, setup failure, and successful closure. The documentation describes startup behavior and cleanup.
Global MySQL constructor failure handling
AdvancedCore/src/main/java/com/bencodez/advancedcore/bungeeapi/globaldata/GlobalMySQL.java, AdvancedCore/src/test/java/com/bencodez/advancedcore/api/user/userstorage/mysql/MySQLInitializationTest.java, docs/mysql-startup-failure.md
The global constructor now stops on connection or database-selection failure, disconnects, and reports the failure. A test covers rejected authentication.
Pinned SimpleAPI build integration
.github/workflows/maven.yml, docs/mysql-startup-failure.md
CI checks out and installs the pinned SimpleAPI revision before packaging AdvancedCore. The package command disables snapshot updates. The documentation includes local build steps.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix






































Merge Risk: ⚪ Minimal · up to a68cc

No identified issue prevents merging after normal checks. Confirm the hosted CI build completes.

Security Architecture Review

Security architecture risk: 🔵 Low · up to a68cc

The inspected changes strengthen database startup failure handling without showing a new access path or increased database authority. Remaining uncertainty concerns the SQL library’s cleanup guarantees and dependency selection outside the pinned CI build.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The relevant runtime exposure follows the configured user-storage and shared global-data databases and the existing SQL credentials. The inspected constructor changes add no credential source or network entrypoint. Database-account privilege breadth and external consumer deployment scope were not supplied.

Trust Boundaries and Controls

  • observed — The added dependency source build executes in the build job with contents-read permissions. Both source checkouts disable credential persistence, and the dependency revision is immutable. The separate contents-write dependency-submission job remains push-only and unchanged.

Resilience and Maintainability Implications

  • observed — The constructor guards attempt cleanup before propagating failure. Added mocked lifecycle cases assert authentication-rejection cleanup, absence of premature diagnostic/query callbacks, preservation of a setup failure, successful cache initialization, and normal close. They do not exercise constructor cleanup throwing or establish complete real-pool cleanup.















Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 3 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: handling MySQL initialization failures and improving constructor lifecycle safety.

Full details: Docstring Coverage

Explanation

Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 3 files. (2 skipped: 2 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR










🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

















  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@BenCodez BenCodez reopened this Oct 11, 2026
@BenCodez
BenCodez marked this pull request as ready for review October 11, 2026 16:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T17:04:23.704293Z d09f0d8 New commits
🔒 Security Review ✅ Completed 2026-10-11T16:33:36.717373Z a68cc2d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a68cc2dfe6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/maven.yml Outdated
Comment on lines +34 to +35
- name: Build and install SimpleAPI dependency
run: mvn -B -f .ci/simpleapi/SimpleAPI/pom.xml clean install

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Publish the required SimpleAPI API in the POM

Installing the pinned SimpleAPI source only inside this CI job leaves the normal Maven build dependent on the unchanged public 1.0.2-SNAPSHOT, which the added comment and documentation acknowledge may lack the APIs now used by MySQL and GlobalMySQL. Consequently, a clean downstream checkout running mvn -f AdvancedCore/pom.xml package can fail compilation unless the developer first performs the undocumented-at-the-POM manual dependency install; reference a published dependency containing this API (or avoid requiring it) so source consumers continue to build normally.

AGENTS.md reference: AGENTS.md:L37-L42

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ca3d3530e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

} catch (SQLException | RuntimeException | Error failure) {
try { mysql.disconnect(); }
catch (RuntimeException | Error cleanupFailure) { failure.addSuppressed(cleanupFailure); }
throw new IllegalStateException("Failed to initialize global SQL database selection", failure);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve unchecked database-selection failures

When a JDBC driver or pool throws a RuntimeException or Error from connection acquisition, statement preparation, or execution, this catch converts it into an IllegalStateException. Before this change those unchecked failures propagated unchanged, and the pinned SimpleAPI implementation's equivalent path explicitly rethrows RuntimeException and Error after cleanup, including coverage for IllegalArgumentException and LinkageError; this public constructor therefore now has incompatible exception semantics and can disguise fatal linkage failures. After disconnecting, rethrow unchecked exceptions and errors unchanged and wrap only SQLException.

AGENTS.md reference: AGENTS.md:L37-L38

Useful? React with 👍 / 👎.

@BenCodez
BenCodez merged commit c7ff668 into master Oct 11, 2026
6 checks passed
@BenCodez
BenCodez deleted the fix/mysql-constructor-lifecycle branch October 11, 2026 21:06
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