Java upgrade to 21 - #46
Conversation
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #46 +/- ##
======================================
Coverage 0.00% 0.00%
======================================
Files 10 10
Lines 537 532 -5
Branches 97 98 +1
======================================
+ Misses 537 532 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 26 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -24,7 +24,7 @@ jobs: | |||
| - name: Set up JDK 17 | |||
There was a problem hiding this comment.
The step name still says "Set up JDK 17" but the Java version has been updated to 21. Update the step name to "Set up JDK 21" to match the actual version being configured.
| @@ -84,7 +84,7 @@ jobs: | |||
| - name: Set up JDK 17 | |||
There was a problem hiding this comment.
The step name still says "Set up JDK 17" but the Java version has been updated to 21. Update the step name to "Set up JDK 21" to match the actual version being configured.
| @@ -21,7 +21,7 @@ jobs: | |||
| - name: Set up JDK 17 | |||
There was a problem hiding this comment.
The step name still says "Set up JDK 17" but the Java version has been updated to 21. Update the step name to "Set up JDK 21" to match the actual version being configured.
| public Document getQuery() { | ||
| return query; | ||
| return query != null ? new Document(query) : new Document(); | ||
| } | ||
|
|
||
| public Document getConstraints() { | ||
| return constraints; | ||
| return constraints != null ? new Document(constraints) : null; | ||
| } | ||
|
|
||
| public Document getOrderBy() { | ||
| return orderBy; | ||
| return orderBy != null ? new Document(orderBy) : null; |
There was a problem hiding this comment.
The getQuery(), getConstraints(), and getOrderBy() methods have inconsistent null-handling behavior. getQuery() returns an empty Document when query is null, but getConstraints() and getOrderBy() return null. This inconsistency can lead to confusion and potential NullPointerExceptions. Consider making all three methods consistent by either all returning empty Documents or all returning null when the field is null.
| properties.containsKey("mongocom.database") | ||
| ? properties.getProperty("mongocom.database") | ||
| : ""; | ||
| if (!user.equals("")) { |
There was a problem hiding this comment.
Inefficient comparison to empty string, check for zero length instead.
| if (!user.equals("")) { | ||
| builder.append(user).append(":").append(password).append("@"); | ||
| } | ||
| if (host.equals("")) { |
There was a problem hiding this comment.
Inefficient comparison to empty string, check for zero length instead.
| } else { | ||
| builder.append(host); | ||
| } | ||
| if (!port.equals("")) { |
There was a problem hiding this comment.
Inefficient comparison to empty string, check for zero length instead.
| builder.append(port); | ||
| } | ||
| builder.append("/"); | ||
| if (!dbName.equals("")) { |
There was a problem hiding this comment.
Inefficient comparison to empty string, check for zero length instead.
|
/review |
🤖 ThrillhouseBot PR SummaryWhat this PR doesUpgrade the project from Java 17 to 21, update CI workflows to use JDK 21, apply defensive coding (null checks, defensive copies), adopt Java 16+ pattern matching for instanceof, and reformat Javadoc comments.
|
| File | Change | Summary |
|---|---|---|
.github/workflows/ci.yml |
Modified | Switch to JDK 21, change build command to skip verify, and remove pull_request trigger. |
.github/workflows/pr-validation.yml |
Modified | Update to JDK 21, combine test and coverage steps, remove continue-on-error from static analysis. |
BUILD_ISSUES_ANALYSIS.md |
Added | - |
IMPLEMENTATION_PLAN.md |
Added | - |
TEST_COVERAGE_REPORT.md |
Added | - |
check-quality.sh |
Modified | Make static analysis checks exit with error instead of continuing on failure. |
src/main/java/com/arquivolivre/mongocom/annotations/Document.java |
Modified | - |
src/main/java/com/arquivolivre/mongocom/annotations/GeneratedValue.java |
Modified | - |
src/main/java/com/arquivolivre/mongocom/annotations/Id.java |
Modified | - |
src/main/java/com/arquivolivre/mongocom/annotations/Index.java |
Modified | - |
src/main/java/com/arquivolivre/mongocom/annotations/Internal.java |
Modified | - |
src/main/java/com/arquivolivre/mongocom/annotations/ObjectId.java |
Modified | - |
src/main/java/com/arquivolivre/mongocom/annotations/Reference.java |
Modified | - |
src/main/java/com/arquivolivre/mongocom/annotations/Trigger.java |
Modified | - |
src/main/java/com/arquivolivre/mongocom/exceptions/NoSuchMongoCollectionException.java |
Modified | - |
src/main/java/com/arquivolivre/mongocom/management/CollectionManager.java |
Modified | Add null check for InsertOneResult, use pattern matching for List, iterate over Map.Entry, and adjust formatting. |
src/main/java/com/arquivolivre/mongocom/management/CollectionManagerFactory.java |
Modified | Use try-with-resources for file input, add null check for listFiles, and reorder imports. |
src/main/java/com/arquivolivre/mongocom/management/MongoQuery.java |
Modified | Add defensive copies for query/constraints/orderBy, use pattern matching for instanceof, and remove unused imports. |
src/main/java/com/arquivolivre/mongocom/types/Action.java |
Modified | - |
src/main/java/com/arquivolivre/mongocom/types/IndexType.java |
Modified | - |
…and 6 more file(s).
Risk Assessment
| Risk | Count |
|---|---|
| 🔴 Critical | 0 |
| 🟠 High | 1 |
| 🟡 Medium | 0 |
| 🔵 Low | 1 |
Key Findings
- HIGH: CI no longer runs on pull requests (
.github/workflows/ci.yml:4) - LOW: Defensive copies of Document may break callers relying on mutation (
src/main/java/com/arquivolivre/mongocom/management/MongoQuery.java:116)
⚠️ Required CI Checks Status
Some required checks are still pending or have failed:
| Check | Type | Status | Detail |
|---|---|---|---|
| validate | check-run | ❌ Failed | failure |
Automated review by ThrillhouseBot. Reply with /review to re-run.
| on: | ||
| push: | ||
| branches: [ master, main ] |
There was a problem hiding this comment.
🟠 HIGH — CI no longer runs on pull requests
The pull_request trigger was removed from ci.yml, so the CI pipeline (including tests, coverage, and SonarCloud analysis) will not execute on pull requests. This allows merging code that hasn't passed these quality gates.
| on: | |
| push: | |
| branches: [ master, main ] | |
| on: | |
| push: | |
| branches: [ master, main ] | |
| pull_request: | |
| branches: [ master, main ] |
| public Document getQuery() { | ||
| return query; | ||
| return query != null ? new Document(query) : new Document(); | ||
| } |
There was a problem hiding this comment.
🔵 LOW — Defensive copies of Document may break callers relying on mutation (low confidence — verify before acting)
Methods getQuery(), getConstraints(), and getOrderBy() now return defensive copies of internal Document objects instead of the direct references. External code that intended to modify the query by mutating the returned Document will no longer affect the MongoQuery instance, possibly breaking existing integrations. No regression tests cover this change.
| public Document getQuery() { | |
| return query; | |
| return query != null ? new Document(query) : new Document(); | |
| } | |
| public Document getQuery() { | |
| return query; | |
| } |
|
/describe |
🤖 ThrillhouseBot — suggested title & descriptionSuggested title
Suggested descriptionSummaryBump the project’s Java version from 17 to 21 across CI/CD, source code, and documentation. Key ChangesCI / Workflows
Java source code
New documentation
TestingAll 161 unit tests continue to pass after the Java 21 change; no functional regressions. Suggestion only — your PR was not modified. Copy whatever is useful into the title and description. Re-run with |
|
/changelog |
🤖 ThrillhouseBot — suggested CHANGELOG entryChanged
Fixed
Removed
Suggestion only — nothing was committed. Copy whatever fits into |
|
/help |
🤖 ThrillhouseBot commands
You can also use the mention form, e.g. |
|
/add-docs |
| @@ -150,27 +147,27 @@ public <A extends Object> List<A> find(Class<A> collectionClass, MongoQuery quer | |||
| A obj = collectionClass.newInstance(); | |||
There was a problem hiding this comment.
📝 Documentation for CollectionManager.find(Class<A>, MongoQuery)
| A obj = collectionClass.newInstance(); | |
| /** | |
| * Finds all documents of the given collection class that match the specified query. | |
| * Applies projection, ordering, skip, and limit from the query object. | |
| * | |
| * @param <A> the type of the collection element | |
| * @param collectionClass the class of the collection to query | |
| * @param query the query containing filters and modifiers | |
| * @return a list of objects of type A matching the query | |
| */ | |
| public <A extends Object> List<A> find(Class<A> collectionClass, MongoQuery query) { |
| @@ -230,12 +227,12 @@ public <A extends Object> A findOne(Class<A> collectionClass, MongoQuery query) | |||
| result = collectionClass.newInstance(); | |||
There was a problem hiding this comment.
📝 Documentation for CollectionManager.findOne(Class<A>, MongoQuery)
| result = collectionClass.newInstance(); | |
| /** | |
| * Returns the first document of the given collection class that matches the query, | |
| * or {@code null} if none found. | |
| * | |
| * @param <A> the type of the collection element | |
| * @param collectionClass the class of the collection to query | |
| * @param query the query containing filters and modifiers | |
| * @return an object of type A or {@code null} | |
| */ | |
| public <A extends Object> A findOne(Class<A> collectionClass, MongoQuery query) { |
| @@ -301,13 +298,15 @@ public String insert(Object document) { | |||
| String collectionName = reflectCollectionName(document); | |||
There was a problem hiding this comment.
📝 Documentation for CollectionManager.insert(Object)
| String collectionName = reflectCollectionName(document); | |
| /** | |
| * Inserts the given document into the MongoDB collection derived from its annotations. | |
| * The generated {@code _id} is set back into the document if it carries an {@code @ObjectId} field. | |
| * | |
| * @param document the object to insert | |
| * @return the inserted ID as a string | |
| */ | |
| public String insert(Object document) { |
| @@ -341,8 +340,9 @@ public void update( | |||
| try { | |||
There was a problem hiding this comment.
📝 Documentation for CollectionManager.update(Object, MongoQuery, WriteConcern, boolean)
This symbol is missing documentation. Suggested:
/**
* Updates one or multiple documents matching the given query with the values
* extracted from the provided document object.
*
* @param document the object whose fields will be used for the update ({@code $set})
* @param query the query identifying documents to update
* @param concern the write concern to use for the operation
* @param multi if {@code true}, updates all matching documents; otherwise only the first
*/
public void update(
Object document, MongoQuery query, WriteConcern concern, boolean multi) {
| @@ -375,19 +375,19 @@ public String save(Object document) { | |||
| Document doc = loadDocument(document); | |||
There was a problem hiding this comment.
📝 Documentation for CollectionManager.save(Object)
| Document doc = loadDocument(document); | |
| /** | |
| * Saves a document using upsert behavior: inserts if no {@code _id} is present, | |
| * otherwise replaces the existing document with the same {@code _id}. | |
| * | |
| * @param document the object to save | |
| * @return the document's ID as a string | |
| */ | |
| public String save(Object document) { |
| @@ -666,7 +683,10 @@ public String getStatus() { | |||
| for (String name : client.listDatabaseNames()) { | |||
There was a problem hiding this comment.
📝 Documentation for CollectionManager.getStatus()
| for (String name : client.listDatabaseNames()) { | |
| /** | |
| * Returns a human-readable status string containing the MongoDB client connection state, | |
| * a ping result, and the list of available database names. | |
| * | |
| * @return a status string | |
| */ | |
| public String getStatus() { |
| @@ -76,18 +77,14 @@ public static CollectionManager createCollectionManager( | |||
| public static CollectionManager createCollectionManagerFromURI(String uri) { | |||
There was a problem hiding this comment.
📝 Documentation for CollectionManagerFactory.createCollectionManager(String, int, String, String, String)
This symbol is missing documentation. Suggested:
/**
* Creates a {@link CollectionManager} connected to MongoDB using the given connection
* parameters. Defaults to localhost if host is empty, and default port if zero.
*
* @param host the MongoDB host
* @param port the MongoDB port (0 to use default)
* @param dbName the database name
* @param user the authentication username (may be empty)
* @param password the authentication password (may be empty)
* @return a new CollectionManager instance, or {@code null} on connection failure
*/
public static CollectionManager createCollectionManager(
String host, int port, String dbName, String user, String password) {
| .applyConnectionString(connectionString) | ||
| .build(); | ||
| MongoClientSettings settings = | ||
| MongoClientSettings.builder().applyConnectionString(connectionString).build(); |
There was a problem hiding this comment.
📝 Documentation for CollectionManagerFactory.createCollectionManagerFromURI(String)
| MongoClientSettings.builder().applyConnectionString(connectionString).build(); | |
| /** | |
| * Creates a {@link CollectionManager} from a MongoDB connection URI. The database name | |
| * is extracted from the URI. | |
| * | |
| * @param uri the MongoDB connection URI | |
| * @return a new CollectionManager instance, or {@code null} on failure | |
| */ | |
| public static CollectionManager createCollectionManagerFromURI(String uri) { |
| @@ -164,61 +160,66 @@ public static CollectionManager setup(ServletContext context) { | |||
| if (props == null) { | |||
There was a problem hiding this comment.
📝 Documentation for CollectionManagerFactory.setup(ServletContext)
| if (props == null) { | |
| /** | |
| * Initializes a {@link CollectionManager} from configuration files found in the web | |
| * application's {@code /WEB-INF/conf} directory. Supports both a full URI property | |
| * ({@code mongocom.uri}) and individual properties ({@code mongocom.host}, etc.). | |
| * | |
| * @param context the servlet context from which to locate configuration files | |
| * @return a new CollectionManager instance, or {@code null} if configuration is missing | |
| */ | |
| public static CollectionManager setup(ServletContext context) { |
|
|
||
| public Document getQuery() { | ||
| return query; | ||
| return query != null ? new Document(query) : new Document(); |
There was a problem hiding this comment.
📝 Documentation for MongoQuery.getQuery()
| return query != null ? new Document(query) : new Document(); | |
| /** | |
| * Returns the query filter document. The returned document is a defensive copy of the | |
| * internal query, or an empty document if no query was set. | |
| * | |
| * @return the query filter document | |
| */ | |
| public Document getQuery() { |
| return query; | ||
| return query != null ? new Document(query) : new Document(); | ||
| } | ||
|
|
There was a problem hiding this comment.
📝 Documentation for MongoQuery.getConstraints()
| /** | |
| * Returns the projection / constraints document, or {@code null} if none is set. | |
| * The returned document is a defensive copy. | |
| * | |
| * @return the constraints document, or {@code null} | |
| */ | |
| public Document getConstraints() { |
|
|
||
| public Document getConstraints() { | ||
| return constraints; | ||
| return constraints != null ? new Document(constraints) : null; |
There was a problem hiding this comment.
📝 Documentation for MongoQuery.getOrderBy()
| return constraints != null ? new Document(constraints) : null; | |
| /** | |
| * Returns the sort order document, or {@code null} if no ordering is specified. | |
| * The returned document is a defensive copy. | |
| * | |
| * @return the sort order document, or {@code null} | |
| */ | |
| public Document getOrderBy() { |
| /** | ||
| * @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br> | ||
| */ | ||
| public interface Generator { |
There was a problem hiding this comment.
📝 Documentation for Generator.generateValue(Class, MongoDatabase)
| public interface Generator { | |
| /** | |
| * Generates a value for a field of the given parent class, optionally using the | |
| * provided database context for sequence-like generation. | |
| * | |
| * @param <A> the type of the generated value | |
| * @param parent the class that owns the field to be filled | |
| * @param db the MongoDB database, may be used for ID generation | |
| * @return the generated value | |
| */ | |
| <A extends Object> A generateValue(Class parent, MongoDatabase db); |
|
|
||
| /** @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br> */ | ||
| /** | ||
| * @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br> |
There was a problem hiding this comment.
📝 Documentation for DateGenerator.generateValue(Class, MongoDatabase)
| * @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br> | |
| /** | |
| * Returns the current date and time. The {@code parent} and {@code db} parameters are | |
| * ignored by this generator. | |
| * | |
| * @param parent ignored | |
| * @param db ignored | |
| * @return the current {@link Date} | |
| */ | |
| public Date generateValue(Class parent, MongoDatabase db) { |
|
|
||
| /** @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br> */ | ||
| /** | ||
| * @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br> |
There was a problem hiding this comment.
📝 Documentation for IntegerGenerator.generateValue(Class, MongoDatabase)
| * @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br> | |
| /** | |
| * Generates the next integer value from the {@code _sequences} collection for the | |
| * given parent class. Uses the simple name of {@code parent} as the sequence key. | |
| * | |
| * @param <A> the type of the generated value (expected to be {@link Integer}) | |
| * @param parent the class that owns the field | |
| * @param db the MongoDB database to access the {@code _sequences} collection | |
| * @return the next sequence value | |
| */ | |
| public <A extends Object> A generateValue(Class parent, MongoDatabase db) { |
| /** @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br> */ | ||
| /** | ||
| * @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br> | ||
| */ |
There was a problem hiding this comment.
📝 Documentation for QueryPrototype.select(String...)
| */ | |
| /** | |
| * Prototype method that defines the fields to select in a query. This implementation | |
| * does nothing; the actual selection is handled by the {@code MongoQuery} builder. | |
| * | |
| * @param fields the field names to select | |
| */ | |
| public static void select(String... fields) {} |
|
|
||
| /** @author thiago */ | ||
| /** | ||
| * @author thiago |
There was a problem hiding this comment.
📝 Documentation for NoSuchMongoCollectionException(String)
| * @author thiago | |
| /** | |
| * Constructs a new exception with the given detail message. | |
| * | |
| * @param message the detail message | |
| */ | |
| public NoSuchMongoCollectionException(String message) { |
|
📝 ThrillhouseBot added 16 committable documentation suggestion(s) and drafted 2 more it couldn't post as committable suggestions (declarations that don't map cleanly onto the diff — each note has the docs to add manually). Review each one and commit the suggestions you want to keep. |
## What type of PR is this? - [x] 📝 Documentation - [x] 📦 Dependency update ## Description Release prep for **v0.3.0**, in three parts: - **Docs — stale command lists fixed.** The v0.3.0 commands `/describe`, `/changelog`, and `/add-docs` were missing from the `webhook/` package row in `docs/ARCHITECTURE.md` and from the `CommentCommandService` class javadoc (both still listed only the five older commands). Both now match the `CommentCommand` enum and the live `/help` output. The `README.md` summary bullet now mentions the changed-files walkthrough added in v0.3.0 (#179). - **Changelog — dated and synced.** The `[0.3.0]` heading moves from `unreleased` to `2026-06-30`, and a new `### Dependencies` section records the bumps landed during the cycle. - **Version bump for tagging.** The Maven project version goes `0.3.0-SNAPSHOT` → `0.3.0` so the release can be tagged. (The frontend `package.json` keeps its own independent `1.0.0`.) No runtime behavior changes — docs, changelog, and version metadata only. ## Related Issues N/A (no code fix). This documents already-merged v0.3.0 features (`/describe` #35, `/changelog` #62, `/add-docs` #56, changed-files walkthrough #179) and records the dependency bumps #262, #263, #265, #266, #267 in the changelog. ## How Has This Been Tested? - [x] Manual testing The documented v0.3.0 command surface was dogfooded on `#256` and `devops-thiago/MongOCOM#46`; the corrected command list matches both the `CommentCommand` enum and the bot's own `/help` output. Changes are documentation/metadata only, so no automated tests apply. ## Checklist - [x] My code follows the project's coding standards - [x] I have performed a self-review of my own code - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] I have updated the documentation accordingly - [x] My changes generate no new warnings or errors ## Additional Notes - A copy-editing pass over the v0.3.0 changelog prose (against the Wikipedia "Signs of AI writing" checklist) found **no changes needed** — the entries match the established terse-technical voice, so there is no follow-up commit. - Three tracking issues surfaced during v0.3.0 dogfooding were filed **separately** (not part of this PR): #296 (`/describe` `/changelog` `/add-docs` truncation disclosure), #297 (`/summary` "already exists" wording), #298 (summary "Changes Overview" count accuracy).


No description provided.