feature: migrate javax to jakarta and Spring Security 6 (Java 21 upgrade, Stage 3 of 4) - #1051
Open
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: andrew.zhao <andrew.zhao@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 3 of 4 of the Java 11 -> 21 upgrade: make the source compile and the tests pass on Spring Boot 3.5.3 / Spring Security 6. Base is Stage 2's
devin/1787850098-spring-boot-3-upgrade, where./gradlew clean builddied at:compileJavawith ~84 errors.After this PR:
./gradlew clean buildand./gradlew testare green (68 tests, 0 failures, 0 errors, 0 skipped), and the app boots and serves authenticated REST + GraphQL traffic.Per Stage 2's decisions,
sourceCompatibility/targetCompatibilitystay'11', theTargetJvmVersion = 17resolution attribute stays (Stage 4 removes both), and jjwt stays on 0.11.5.1. javax -> jakarta (20 source files, 38 imports)
javax.validation.*->jakarta.validation.*,javax.validation.constraints.*->jakarta.validation.constraints.*,javax.servlet[.http].*->jakarta.servlet[.http].*. Imports were migrated file by file, not by a tree-wide sed.Deliberately left as
javax— JDK packages, not Jakarta EE, ininfrastructure/service/DefaultJwtService.java:These are
java.base/JCE types and have nojakartaequivalent. A blind rename here would not compile. No otherjavax.*import survives insrc/;src/testhad none to begin with.2. Spring Security 6 configuration
WebSecurityConfigurerAdapteris gone in Spring Security 6, soWebSecurityConfigis now a plain@Configurationexposing aSecurityFilterChainbean built with the lambda DSL. ThejwtTokenFilter(),passwordEncoder()andcorsConfigurationSource()beans are unchanged, and the endpoint matrix is a 1:1 translation — same order, same matchers, same outcomes.Before:
After:
Notes:
requestMatchers(HttpMethod.OPTIONS)is the method-only overload, matching the oldantMatchers(HttpMethod.OPTIONS)(any path, OPTIONS verb).JwtTokenFilterreadingAuthorization: Token <jwt>; noAuthenticationManager,UserDetailsServiceor form/basic login was introduced, and nothing was loosened. UnauthenticatedGET /userstill returns 401 viaHttpStatusEntryPoint.UserDetailsServiceis defined. It is inert here — nothing authenticates against it — so no workaround was added.3. Other Spring Boot 3 / DGS 9 breakages
DGS exception handler:
DataFetcherExceptionHandler.onException(...)was replaced byCompletableFuture<DataFetcherExceptionHandlerResult> handleException(...).GraphQLCustomizeExceptionHandlernow returnsCompletableFuture.completedFuture(...)and delegates todefaultHandler.handleException(...).Relay
PageInfo: DGS codegen 8 generatesio.spring.graphql.types.PageInfofrom the schema, andArticlesConnection/CommentsConnectionbuilders now require it, sographql.relay.DefaultPageInfo/DefaultConnectionCursorwere dropped in favor of the generated builder:Spring 6
HttpStatusCode:CustomizeExceptionHandler's overridden handler signatures now takeHttpStatusCodeinstead ofHttpStatus.Two
build.gradlechanges were unavoidable to get the suite green (everything Stage 2 fenced off is untouched):codegen { clientCoreConventionsEnabled = false }. The DGS codegen plugin 8.1.0 client-core convention putsgraphql-dgs-codegen-shared-core:8.1.0onimplementation, which drags ingraphql-dgs-platform-dependencies:10.0.4and wins conflict resolution against the app'sgraphql-dgs-spring-boot-starter:9.2.2— a mixed DGS graph (autoconfig 9.2.2, core 10.0.4). That failed 2 tests at context startup:Disabling the convention keeps codegen generating sources while leaving the runtime graph aligned on DGS 9.2.2. The app uses only DGS runtime annotations (
@DgsComponent,@DgsData,@DgsQuery,@DgsMutation) and generatedio.spring.graphql.types, no codegen client-core API, andgraphql-dgs-codegen-shared-coreis now absent fromruntimeClasspath.Spotless target narrowed from a
fileTree(rootDir)withbuild/generated*excludes to'src/**/*.java'— the old form tripped Gradle 8 task-input validation on generated build output. Same set of hand-written sources, no formatting policy change.spotlessJavaApplyalso absorbed the one pre-existing google-java-format drift inDefaultJwtServiceTestthat Stage 2 flagged.Verification
Gradle 8.5, JVM 21.0.11.
./gradlew compileJava compileTestJava— zero errors../gradlew spotlessJavaApplyrun before committing;./gradlew clean build(which includesspotlessJavaCheck) — BUILD SUCCESSFUL../gradlew test— 68 tests, 0 failures, 0 errors, 0 skipped. No test was deleted, disabled,@Disabled-ed, weakened, or had its assertions changed.Runtime smoke test (
./gradlew bootRun, SQLite/Flyway migrateddev.db)Register:
Login:
Authenticated current user, and the unauthenticated control:
GraphQL, including the Relay connections that exercise the new generated
PageInfo(a second run registeredrelay1787852226and created an article, since no test covers the datafetchers):Remaining failures / handoff notes for Stage 4
No remaining test failures. The suite is fully green, so Stage 4 starts from a green build.
Stage 4 must:
sourceCompatibility/targetCompatibility(or ajava.toolchain) to 21 and delete theTargetJvmVersion = 17bridge block inbuild.gradle— the two go together; leaving the attribute behind once the toolchain is 21 is stale config.codegen { clientCoreConventionsEnabled = false }if it touches DGS versions. It is a version-alignment fix, not a Java-version one, so it should stay unless DGS is upgraded to the 10.x line — in which case aligninggraphql-dgs-spring-boot-starterto 10.x is the better resolution and the flag can go.PageInfochange above was verified only by the manual GraphQL queries in this PR; a toolchain bump won't re-verify it. Worth adding a datafetcher test at some point (out of scope here).Jwts.parserBuilder(),signWith,setX->x) remains a separate follow-up, deliberately not bundled into the version upgrade.Devin-Org: engineering
Link to Devin session: https://app.devin.ai/sessions/76fd1d83a7f7423599ed4dede411dc22
Open in Devin Desktop: https://app.devin.ai/desktop/session/76fd1d83a7f7423599ed4dede411dc22?variant=devin
Requested by: @Azhao15
Note
Devin errored when opening this Pull Request as Azhao15.
As a fallback, Devin opened this PR as itself.
Devin Review