-
Notifications
You must be signed in to change notification settings - Fork 14
feat: upgrade to a more recent JDK (21 or higher) #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
WalkthroughThe PR upgrades the Java toolchain from 1.7/1.8 to Java 21, updates Gradle from 8.2 to 9.2.1, migrates test framework from JUnit 4 to JUnit 5, and updates dependencies (commons-codec and commons-io). The CI workflow is simplified to run with Java 21 only. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
build.gradle.kts (1)
105-110:⚠️ Potential issue | 🟡 MinorPOM properties still reference Java 1.7 - inconsistent with Java 21 toolchain.
The
maven.compiler.targetandmaven.compiler.sourceare set to1.7, but the project now uses Java 21 toolchain. This inconsistency may confuse downstream consumers of the published artifact.🔧 Proposed fix
properties = mapOf( "project.build.sourceEncoding" to "UTF-8", "project.reporting.outputEncoding" to "UTF-8", - "maven.compiler.target" to "1.7", - "maven.compiler.source" to "1.7" + "maven.compiler.target" to "21", + "maven.compiler.source" to "21" )src/test/java/com/uploadcare/upload/FileUploaderTest.java (1)
21-22:⚠️ Potential issue | 🟠 Major
org.mockito.Matchersis deprecated - useArgumentMatchers.
org.mockito.Matchershas been deprecated since Mockito 2.x and removed in later versions. When upgrading Mockito (as recommended inbuild.gradle.kts), this will cause compilation failures.🔧 Proposed fix
-import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq;.github/workflows/build.yml (1)
26-35:⚠️ Potential issue | 🟡 MinorUpdate GitHub Actions to current versions.
The actions used are on older major versions:
actions/checkout@v3→ v6 is the current latest (v4 is still supported)actions/setup-java@v3→ v5 is the current latest (v4 is still supported)gradle/gradle-build-action@v2is deprecated in favor ofgradle/actions/setup-gradle@v5🔄 Proposed updates
steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} distribution: 'temurin' - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v5 # Removing unused files from Gradle User Home before saving to cache (i.e. older versions of gradle) gradle-home-cache-cleanup: true # Cache downloaded JDKs in addition to the default directories. gradle-home-cache-includes: | caches notifications jdks
🤖 Fix all issues with AI agents
In `@build.gradle.kts`:
- Around line 28-29: The build declares a non-existent Commons IO version
("commons-io:commons-io:2.21.0") which will break the Gradle build; update the
dependency declaration in build.gradle.kts to a valid Maven Central version (for
example change the version from 2.21.0 to 2.16.1 or 2.15.1) so the
implementation("commons-io:commons-io:<version>") entry resolves; leave the
JUnit BOM/testImplementation lines as-is since JUnit 6.0.1 is valid.
- Line 36: Replace the deprecated dependency declaration
testImplementation("org.mockito:mockito-all:1.10.19") with the modern Mockito
artifacts for JUnit 5: add
testImplementation("org.mockito:mockito-core:<latest-version>") and
testImplementation("org.mockito:mockito-junit-jupiter:<latest-version>") in
build.gradle.kts, then update tests using Mockito to use the JUnit 5 extension
by annotating test classes with `@ExtendWith`(MockitoExtension.class) (or migrate
to `@Mock/`@InjectMocks with MockitoExtension) to ensure compatibility.
In `@src/test/java/com/uploadcare/api/RequestHelperTest.java`:
- Around line 28-36: The test in RequestHelperTest calls RequestHelper.rfc2822
and then asserts the result against itself (assertEquals(formattedDate,
formattedDate)), which always passes; change the assertion to compare the
produced formattedDate to the expected constant FORMATTED_DATE (e.g.,
assertEquals(FORMATTED_DATE, formattedDate)) so the test actually verifies
RequestHelper.rfc2822 output; locate the assertion in method testRfc2822 and
update it accordingly.
| testImplementation(platform("org.junit:junit-bom:6.0.1")) | ||
| testImplementation("org.junit.jupiter:junit-jupiter") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check JUnit BOM 6.0.1 existence
echo "=== Checking JUnit BOM 6.0.1 ==="
http_code=$(curl -s -o /dev/null -w "%{http_code}" "https://repo1.maven.org/maven2/org/junit/junit-bom/6.0.1/junit-bom-6.0.1.pom")
echo "HTTP Status for JUnit BOM 6.0.1: $http_code"
# Check available JUnit BOM versions
echo ""
echo "=== Available JUnit BOM versions (latest 15) ==="
curl -s "https://repo1.maven.org/maven2/org/junit/junit-bom/maven-metadata.xml" 2>/dev/null | grep -o '<version>[^<]*</version>' | sed 's/<version>//g' | sed 's/<\/version>//g' | tail -15
# Check commons-io version
echo ""
echo "=== Checking commons-io 2.21.0 ==="
http_code=$(curl -s -o /dev/null -w "%{http_code}" "https://repo1.maven.org/maven2/org/apache/commons/commons-io/2.21.0/commons-io-2.21.0.pom")
echo "HTTP Status for commons-io 2.21.0: $http_code"
# Check available commons-io versions
echo ""
echo "=== Available commons-io versions (latest 10) ==="
curl -s "https://repo1.maven.org/maven2/org/apache/commons/commons-io/maven-metadata.xml" 2>/dev/null | grep -o '<version>[^<]*</version>' | sed 's/<version>//g' | sed 's/<\/version>//g' | tail -10
# Check mockito-all availability
echo ""
echo "=== Checking mockito-all 1.10.19 ==="
http_code=$(curl -s -o /dev/null -w "%{http_code}" "https://repo1.maven.org/maven2/org/mockito/mockito-all/1.10.19/mockito-all-1.10.19.jar")
echo "HTTP Status for mockito-all 1.10.19: $http_code"
# Check available mockito versions
echo ""
echo "=== Available mockito-core versions (latest 10) ==="
curl -s "https://repo1.maven.org/maven2/org/mockito/mockito-core/maven-metadata.xml" 2>/dev/null | grep -o '<version>[^<]*</version>' | sed 's/<version>//g' | sed 's/<\/version>//g' | tail -10Repository: uploadcare/uploadcare-java
Length of output: 650
JUnit BOM 6.0.1 is a valid release — JUnit 6 is a legitimate production version line with official releases including 6.0.0, 6.0.1, and 6.0.2 on Maven Central. No issue here.
However, commons-io 2.21.0 (line 25) does not exist on Maven Central (HTTP 404). This will cause the gradle build to fail. Update to a valid version such as 2.15.1 or 2.16.1.
🤖 Prompt for AI Agents
In `@build.gradle.kts` around lines 28 - 29, The build declares a non-existent
Commons IO version ("commons-io:commons-io:2.21.0") which will break the Gradle
build; update the dependency declaration in build.gradle.kts to a valid Maven
Central version (for example change the version from 2.21.0 to 2.16.1 or 2.15.1)
so the implementation("commons-io:commons-io:<version>") entry resolves; leave
the JUnit BOM/testImplementation lines as-is since JUnit 6.0.1 is valid.
| testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") | ||
|
|
||
| testImplementation("org.hamcrest:hamcrest:2.2") | ||
| testImplementation("org.mockito:mockito-all:1.10.19") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
mockito-core Java 21 compatibility latest version 2024 2025
💡 Result:
- Mockito + Java 21: Mockito 5.x is the line that works with Java 21; Mockito 4.11.0 was reported broken on Java 21 due to needing a newer Byte Buddy, while “the latest version of Mockito 5 works fine with Java 21.” [2]
- Latest
mockito-core(as of Jan 30, 2026):org.mockito:mockito-core:5.21.0(published 2025-12-09). [1] - Relevant 2024–2025 releases (from Maven Central timestamps): 5.10.0 (2024-01-24), 5.11.0 (2024-03-01), 5.12.0 (2024-05-11), 5.13.0 (2024-08-27), 5.14.x (2024-09/10), 5.15.2 (2025-01-02), 5.16.x (2025-03), 5.17.0 (2025-04-04), 5.18.0 (2025-05-20), 5.19.0 (2025-08-15), 5.20.0 (2025-09-20), 5.21.0 (2025-12-09). [1]
- Note if you used
mockito-inline: Mockito maintainers state inline mocking is the default since Mockito 5 and you should usemockito-corelatest instead of relying on a separatemockito-inlineartifact. [3]
Recommendation for Java 21: use org.mockito:mockito-core:5.21.0. [1]
Sources: [1] https://repo1.maven.org/maven2/org/mockito/mockito-core/ , [2] mockito/mockito#3143 , [3] https://groups.google.com/g/mockito/c/psRyztIa5mY
🌐 Web query:
mockito-all incompatible JUnit 5 mockito-core replacement
💡 Result:
mockito-all is the old “fat jar” distribution (mainly for manual/legacy builds) and was discontinued starting with Mockito 2.x—so it’s a bad fit for modern JUnit 5 projects. Replace it with mockito-core + mockito-junit-jupiter. [1], [2]
Maven (JUnit 5 / Jupiter)
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>mockito-junit-jupiter provides the JUnit 5 extension:
`@ExtendWith`(MockitoExtension.class)
class MyTest { ... }[2], [3]
Gradle
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion"[1], [2]
If you relied on mockito-all bundling extra deps
Because mockito-all used to bundle some transitive dependencies, you may need to add what your project actually uses explicitly (commonly Hamcrest, depending on your assertions/matchers). [4]
Sources: Mockito site (recommends mockito-core, notes mockito-all discontinued) [1]; JUnit 5 usage via mockito-junit-jupiter / MockitoExtension [2]; artifact exists on Maven Central [3]; mockito-all vs mockito-core differences/discontinuation note [4].
[1] (site.mockito.org)
[2] (stackoverflow.com)
[3] (central.sonatype.com)
[4] (stackoverflow.com)
Citations:
- 1: https://site.mockito.org/?utm_source=openai
- 2: https://stackoverflow.com/questions/40961057/how-to-use-mockito-with-junit-5/40962941?utm_source=openai
- 3: https://central.sonatype.com/artifact/org.mockito/mockito-junit-jupiter/5.21.0?utm_source=openai
- 4: https://stackoverflow.com/questions/55076680/what-is-the-difference-between-mockito-core-and-mockito-all?utm_source=openai
🌐 Web query:
mockito-all 1.10.19 release date 2014
💡 Result:
org.mockito:mockito-all:1.10.19 was released to Maven Central on December 31, 2014 (artifacts timestamped 2014-12-31 16:43). [1], [2]
Replace mockito-all with mockito-core and mockito-junit-jupiter for JUnit 5 compatibility.
mockito-all:1.10.19 (released 2014-12-31) is discontinued since Mockito 2.x and incompatible with JUnit 5. Use the current versions:
🔧 Proposed fix
- testImplementation("org.mockito:mockito-all:1.10.19")
+ testImplementation("org.mockito:mockito-core:5.21.0")
+ testImplementation("org.mockito:mockito-junit-jupiter:5.21.0")For JUnit 5 tests, annotate with @ExtendWith(MockitoExtension.class).
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| testImplementation("org.mockito:mockito-all:1.10.19") | |
| testImplementation("org.mockito:mockito-core:5.21.0") | |
| testImplementation("org.mockito:mockito-junit-jupiter:5.21.0") |
🤖 Prompt for AI Agents
In `@build.gradle.kts` at line 36, Replace the deprecated dependency declaration
testImplementation("org.mockito:mockito-all:1.10.19") with the modern Mockito
artifacts for JUnit 5: add
testImplementation("org.mockito:mockito-core:<latest-version>") and
testImplementation("org.mockito:mockito-junit-jupiter:<latest-version>") in
build.gradle.kts, then update tests using Mockito to use the JUnit 5 extension
by annotating test classes with `@ExtendWith`(MockitoExtension.class) (or migrate
to `@Mock/`@InjectMocks with MockitoExtension) to ensure compatibility.
486b3f8 to
ee16ede
Compare
* Upgraded the GitHub actions. * Upgraded the JDK to 22 or higher. * Upgraded Gradle to newest possible 9.x. * Upgraded Mockito. * Upgraded JUnit.
ee16ede to
97ac86c
Compare
Fixes #71.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.