Skip to content

Modernization integration: Java 21 / Spring Boot 3.5.16 / DGS 10 / Next 15 + regression suite (do not merge yet) - #232

Open
devin-ai-integration[bot] wants to merge 37 commits into
mainfrom
devin/1791491209-modernization-integration
Open

devin-ai-integration[bot] wants to merge 37 commits into
mainfrom
devin/1791491209-modernization-integration

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Integration branch for the full modernization of the RealWorld app from Java 11 / Spring Boot 2.6.3 / Gradle 7.4 / Next 9 to Java 21 / Spring Boot 3.5.16 / Gradle 8.14.6 / Next 15, plus a cross-cutting regression suite. Opened for review only — do not merge to main yet. Six child PRs were merged into this branch in order (#226 platform/build → #227 REST/security → #228 persistence/JWT/time → #229 GraphQL/DGS → #230 frontend → #231 regression suite), with the full gate run after each merge (docs/modernization/integration/MERGE-LOG.md). The complete before/after report is docs/modernization/REPORT.md.

Final verification on this branch (head of PR)

JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64 ./gradlew clean test spotlessCheck jacocoTestReport jacocoTestCoverageVerification
  → BUILD SUCCESSFUL — 384 tests / 0 failures, JaCoCo 94.2% instruction / 84.7% branch (threshold 0.80 unchanged)
cd frontend && npm ci && npm run lint && npm run typecheck && npm test && npm run build   (Node 22)
  → all green — 151 Vitest tests / 0 failures, 97.4% stmts / 92.2% branches
./gradlew seleniumTest (JDK 21 backend + Next 15) → 5/5 (run by the regression session)

Baseline main: 68 tests, 33.2% coverage (CI skipped the JaCoCo gate), frontend untested, npm audit 109 vulns (10 critical). Now: 384 + 151 tests, gate enforced in CI, npm audit 7 dev-only findings (0 critical; see frontend/AUDIT.md).

Key migration points (details in docs/modernization/REPORT.md §6)

  • Build: Java 21 toolchain, Gradle 8.14.6, Boot 3.5.16 / dependency-management 1.1.7, Spotless 7.0.4 (target 'src/**/*.java' — Gradle 8 rejects the old root fileTree), JaCoCo 0.8.13 with exclusions for DGS codegen output only (io/spring/graphql/{types,client}/**, DgsConstants*). CI runs the full gate on JDK 21 plus a Node 22 frontend job.
  • REST/security: javax.* → jakarta.*; WebSecurityConfigurerAdapter → @Bean SecurityFilterChain (lambda DSL, requestMatchers). Authorization: Token <jwt> preserved. Added dispatcherTypeMatchers(DispatcherType.ERROR).permitAll() — Spring Security 6 otherwise filters the servlet ERROR dispatch and turned @ResponseStatus 403/404 into 401 at runtime.
  • Persistence/time: Joda removed → java.time.Instant (UTC, millis) across domain, DTOs, cursor pagination (wire format unchanged) and Jackson (InstantSerializer, same …SSSZ output as before). DateTimeHandler → InstantHandler writing canonical UTC text so app rows and seed rows sort/compare consistently. JJWT 0.12.6 (Keys.hmacShaKeyFor, verifyWith/parseSignedClaims); invalid/expired/tampered tokens → Optional.empty(). MyBatis starter 3.0.4, sqlite-jdbc 3.50.3.0, Flyway 11 (Boot-managed). ArticleMapper.update now persists updated_at (pre-existing defect).
  • GraphQL: DGS 10.6.0 on graphql-dgs-spring-graphql-starter, codegen 8.7.0 (generated types.PageInfo), async DataFetcherExceptionHandler.handleException, GraphiQL at /graphiql?path=/graphql.
  • Frontend: Next 15.5 / React 19 / TS 5.9 / SWR 2 / axios 1 / marked 18 + DOMPurify sanitization before dangerouslySetInnerHTML; ESLint 9 flat config, Vitest 5 + Testing Library with coverage thresholds; Node >=22.
  • Repo tooling: .devin/blueprint.yaml and .agents/skills/* updated for Java 21 / Node 22.

Known pre-existing behaviours left unchanged (documented, tests pin current contract)

POST /users/login bad credentials → 422 {"message"} (not {"errors"}); POST /users returns 201 while RegisterForm checks for 200; GraphQL updateUser unauthenticated error envelope; getPageInfo shows no pages when total < limit.

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/b94b7b39f5564da89955af6f9aaa39bb
Open in Devin Desktop: https://partner-workshops.devinenterprise.com/desktop/session/b94b7b39f5564da89955af6f9aaa39bb?variant=devin
Requested by: @mbatchelor81

… CI gate, dependency diff and compile report
…, graphql, JacksonCustomizations, api tests

- api/**: javax.* -> jakarta.* (servlet, validation); WebSecurityConfig rewritten as a
  SecurityFilterChain bean (WebSecurityConfigurerAdapter removed in Spring Security 6);
  CustomizeExceptionHandler.handleMethodArgumentNotValid takes HttpStatusCode.
- graphql/**: Joda DateTime -> Instant getters + Util.formatTimestamp;
  GraphQLCustomizeExceptionHandler implements handleException(..) -> CompletableFuture
  (DataFetcherExceptionHandler.onException removed in graphql-java 2x).
- JacksonCustomizations: Instant serializer emitting yyyy-MM-dd'T'HH:mm:ss.SSSZ (UTC)
  in place of the Joda DateTime serializer.
- api tests: Joda -> Instant fixtures; selenium BasePage uses Duration for WebDriverWait.
The REST / GraphQL sessions own these files; drop this commit if theirs supersede it.
…a.validation, MyBatis InstantHandler, regression tests

- Article/Comment/ArticleData/CommentData timestamps are java.time.Instant (UTC);
  Util.now() truncates to millis; DateTimeCursor keeps the epoch-millis wire format.
- InstantHandler (@MappedTypes(Instant.class)) replaces DateTimeHandler, writing/reading
  TIMESTAMP columns with a UTC Calendar exactly as before so existing SQLite rows and the
  textual V2 seed data read back unchanged.
- DefaultJwtService on the JJWT 0.12 builder/parser API (subject/expiration/signWith,
  parser().verifyWith(key).build().parseSignedClaims); key = hmacShaKeyFor(secret UTF-8).
- application/** validation on jakarta.validation.
- New tests: transaction commit/rollback, unique constraints, read-service round trips,
  JWT expiry/tamper/wrong-key/none-alg, InstantHandler unit + DB round trip, timestamp
  JSON format, cursor parsing + pagination boundaries.
…urity 6

- api/**: javax.servlet/javax.validation -> jakarta.*
- WebSecurityConfig: WebSecurityConfigurerAdapter -> SecurityFilterChain bean
  (lambda DSL, csrf disabled, cors with existing CorsConfigurationSource,
  stateless sessions, HttpStatusEntryPoint(401), identical authorizeHttpRequests
  rules, JwtTokenFilter before UsernamePasswordAuthenticationFilter)
- CustomizeExceptionHandler: HttpStatusCode signature for Spring 6
- JacksonCustomizations: add java.time.Instant serializer producing ISO-8601 UTC
  millis with Z (same as Joda ISODateTimeFormat.dateTime().withZoneUTC());
  Joda serializer kept until the time session removes Joda
- API tests: @MockBean -> @MockitoBean
- New regression tests: SecurityRegressionTest, ValidationRegressionTest,
  CorsAndHeadersRegressionTest, TimestampSerializationRegressionTest
…hql/infrastructure/selenium

Needed only so the api test suite compiles and runs on Boot 3.5; the owning
sessions' PRs supersede these:
- application/**: javax.validation -> jakarta.validation
- graphql/UserMutation: jakarta.validation
- graphql/exception/GraphQLCustomizeExceptionHandler: DGS 10 handleException API
- infrastructure/service/DefaultJwtService: JJWT 0.12 parser/builder API
- selenium/pages/BasePage: Selenium 4 WebDriverWait(Duration)
…ping PageInfo, Spotless target)

- generateJava.typeMapping PageInfo -> graphql.relay.PageInfo: the datafetchers build
  graphql.relay.PageInfo; DGS codegen 8 otherwise generates io.spring.graphql.types.PageInfo
  and compileJava fails with incompatible types.
- spotless.java.target = 'src/**/*.java': with Gradle 8 the rootDir fileTree makes
  ':spotlessJava' read build/ outputs of compileJava/test/jacocoTestReport, so
  './gradlew clean test spotlessCheck' fails validation (implicit_dependency).
For the orchestrator to reconcile centrally.
…ta namespace, SecurityFilterChain, JJWT 0.12 parser/key API, Spring 6 HttpStatusCode, Selenium Duration wait)
… regression suite

- GraphQLCustomizeExceptionHandler: async handleException, jakarta.validation, TypedGraphQLError builders
- Generated io.spring.graphql.types.PageInfo replaces graphql.relay.PageInfo in connections
- GraphQLTimeFormat: ISO-8601 UTC millis formatter accepting Instant/Date/legacy getMillis types
- Dedicated Jackson converter for /graphql (REST ObjectMapper has UNWRAP_ROOT_VALUE)
- SecurityUtil/me/updateUser tolerate null Authentication; feed/updateUser -> UNAUTHENTICATED
- Comment.article resolves CommentData from map local context
- 59 GraphQL tests: schema contract, queries, mutations, auth, validation, error mapping, pagination, HTTP /graphql + /graphiql
…tion manifest

- DGS codegen typeMapping PageInfo -> graphql.relay.PageInfo (datafetchers
  return graphql.relay.DefaultPageInfo; DGS 10 codegen otherwise emits its
  own io.spring.graphql.types.PageInfo and compileJava fails)
- Spotless target 'src/**/*.java' instead of a root fileTree: Gradle 8 fails
  'clean test spotlessCheck' with an implicit-dependency validation error
  (spotlessJava vs compileJava/generateJava/test outputs)
- TEMPORARY: re-add joda-time (2.14.0) because core/application/infrastructure
  on the integration branch still import org.joda.time until the
  persistence/time session's PR lands; drop this line at that merge
… GraphQL branch compiles until the java.time migration merges
…the same invocation as generateJava/test (Gradle 8 implicit-dependency validation)
Spring Security 6 applies the filter chain to ERROR dispatches by default.
@ResponseStatus exceptions (NoAuthorizationException 403,
ResourceNotFoundException 404) are rendered via response.sendError ->
ERROR dispatch to /error, which anyRequest().authenticated() turned into a
401 at runtime (MockMvc does not perform the error dispatch, so the
existing tests could not see it). dispatcherTypeMatchers(ERROR).permitAll()
restores the 403/404 responses; API rules are otherwise unchanged.
…C text

- ArticleMapper.update now writes updated_at (was changed in memory only)
- InstantHandler writes 'yyyy-MM-dd HH:mm:ss.SSS' UTC text so app rows sort and
  cursor-compare consistently with the textual seed rows from datetime('now');
  reads stay backward compatible (text with/without fraction, ISO offset text,
  legacy epoch-millis integers, java.sql types)
- Tests: handler unit + DB round-trip (storage type, ordering, cursor compare,
  updatedAt persistence); make JWT tampered-signature test deterministic
Central reconciliation: dropped temporary joda-time dependency and Joda
DateTimeSerializer (owner: persistence); WebSecurityConfig, JacksonCustomizations,
BasePage taken from REST branch; DefaultJwtService from persistence branch;
TimestampSerializationRegressionTest legacy-format check now uses the recorded Joda output.
Central reconciliation: graphql/** taken from GraphQL branch (generated types.PageInfo,
so the DGS codegen PageInfo typeMapping was removed); WebSecurityConfig, DefaultJwtService,
BasePage and build.gradle (Spotless target, no Joda) kept from the integration branch.
…itize markdown, add ESLint 9 + Vitest tooling
…validate article caches after create/update/delete
…ialization/unit), Selenium critical path, regression.yml
… fixtures, DGS 10 introspection split, MOCK web env for rollback test)
@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Author

Completed browser E2E testing of this branch locally with the Java 21 backend (./gradlew bootRun) and Node 22 / Next 15 frontend (npm run dev).

Runtime results and visual evidence

Passed: five seeded articles with valid dates; registration → prefilled Settings → logout/login; wrong-password error (no crash); article creation and immediate edit refresh (updated_at advanced, created_at unchanged); <script>/onerror sanitization; comment persistence; favorite/unfavorite; follow/unfollow and personalized feed; tag filtering; 20+1 pagination; logged-out feed protection; GraphiQL { tags } query.
REST: GET /articles/nonexistent → 404 (not 401), GET /user with Authorization: Token bad → 401.

Edited article / Unicode limitation GraphiQL query
Edited sanitized article GraphiQL tags response
Caveats and cleanup
  • Unicode comment text persisted exactly (DOM + SQLite), but CJK/emoji glyphs rendered as boxes: the test desktop has no matching fonts, so visual Unicode verification is incomplete.
  • Dates render as calendar dates (as before), not relative timestamps.
  • Logged-out direct feed access shows a generic "Cannot load recent articles" message rather than a login prompt (pre-existing behaviour).
  • Temporary pagination fixtures were removed; no production source changes were made.

Devin testing session

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