anantbhandarkar/make-it-right/mir-backend-jvm-spring

Claude Code and agent skill by anantbhandarkar/make-it-right

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Make It Right (Spring Boot module). Spring Boot 4.x / Framework 7 + Spring Data JPA/Hibernate + Spring Security 7 + MVC/WebFlux footguns. Covers: @Transactional self-invocation (a same-bean call bypasses the proxy, so no transaction), checked exceptions not rolling back by default, JPA/Hibernate N+1 and LazyInitializationException plus the open-in-view default, @Async on Boot's auto-configured applicationTaskExecutor (unbounded queue, swallowed exceptions, spring.threads.virtual.enabled), the Jackson 3 and Boot 3.x-to-4 migration cliff, @Valid + DTOs against overposting, and Spring Security object-level authorization plus the current authorization-bypass advisories (NimbusJwtDecoder issuer validation, method security on parameterized types, Actuator health-group paths, versioned static-resource path traversal). Chains: mir-backend (gates) -> mir-backend-jvm (JVM runtime) -> this, which adds only Spring library mechanics. TRIGGER only when the JVM backend stack is Spring Boot — building, reviewing, or debugging a controller, service, @Transactional method, JPA entity, Spring Security config, Actuator exposure, or @Async task. SKIP for Quarkus (mir-backend-jvm-quarkus), Micronaut (mir-backend-jvm-micronaut), Vert.x, Helidon, Ktor, every other non-Spring JVM framework, and every non-JVM runtime.

Install

npx vskill@latest install anantbhandarkar/make-it-right/mir-backend-jvm-spring

SKILL.md

The same SKILL.md was published earlier as anantbhandarkar/make-it-right/mir-backend-jvm-spring.

/mir-backend-jvm-spring · Make It Right (Spring Boot)

Bottom tier of the chain: mir-backend (generic gates) → mir-backend-jvm (JVM runtime model) → this (Spring Boot / Spring Data library mechanics). Run the gates first; load the JVM runtime tier for threading, GC, and container-heap concerns; reach for this at Gate 5 (design mechanics), Gate 6 (implementation), and Gate 7 review. Runtime-level concerns (virtual-thread pinning, pool sizing, GC tuning, `-XX:MaxRAMPercentage`, ThreadLocal hygiene) live in `mir-backend-jvm` — not here.

Stack assumed: Spring Boot 4.x · Spring Framework 7 · Spring Security 7 · Spring Data JPA (Hibernate 7.x, the version Boot 4 manages) · Spring MVC or WebFlux · PostgreSQL / MySQL. Notes call out WebFlux divergences explicitly.

Version and support status, verified 13 Aug 2026:

LineStatusConsequence
Spring Boot 4.1Current. Released 30 Jun 2026; OSS support to 31 Jul 2027Target for new work
Spring Boot 4.0Released 30 Nov 2025; OSS support ends 31 Dec 2026Plan the 4.1 bump now
Spring Boot 3.5OSS support ended 30 Jun 2026 (last OSS release 3.5.16). Commercial support to Jun 2032No free patches — new Spring CVEs are fixed in 4.x and, for paying customers, in 3.5.x. An unpatched 3.5 app is an unpatched app
Spring Boot 3.4 and olderOut of OSS supportUpgrade path is 3.5 → clear every deprecation → 4.x. Do not jump from 3.2/3.3 straight to 4

What Boot 4 / Framework 7 changed that breaks code AI writes from memory:

  • Java baseline stays 17; Java 25 is the tested first-class target (AOT and native-image builds are validated on 25).
  • Jakarta EE 11 — Servlet 6.1, JPA 3.2, Bean Validation 3.1. Needs Tomcat 11+ or Jetty 12.1+. `spring-boot-starter-undertow` was removed.
  • Jackson 3 is the default. Group id moves from com.fasterxml.jackson to tools.jackson; Jackson2ObjectMapperBuilderCustomizer becomes JsonMapperBuilderCustomizer; Jackson 2 properties move under spring.jackson2. Any answer that reaches for com.fasterxml.jackson.databind.ObjectMapper config on Boot 4 is targeting the wrong library.
  • Kotlin 2.2 baseline; the codebase is split into 70+ focused jars. Starters still pull the right set, but a hand-written dependency list from a Boot 3 project will miss modules.

The Spring Boot footguns AI walks into most

1. @Transactional self-invocation: the proxy bypass

Spring's @Transactional is implemented via a proxy (AOP). When a bean method calls another method on the same bean instance (this.someMethod()), the call goes directly to the target object, not through the proxy — the transaction advice is never applied.

java
@Service
public class OrderService {
// WRONG — calling settle() from within the same class bypasses the proxy;
// settle() does NOT run in a transaction even though it is annotated.
public void process(Order order) {
settle(order); // direct call on 'this' — proxy not involved
}
@Transactional
public void settle(Order order) { ... }
}
// FIX — extract settle() to a separate @Service bean and inject that
@Autowired private SettlementService settlementService;
public void process(Order order) { settlementService.settle(order); }
// NOT A FIX — self-injection. Spring Boot sets spring.main.allow-circular-references=false
// by default (since 2.6), so this fails the context at startup rather than working.
// @Autowired private OrderService self;
2. Checked exceptions do NOT roll back @Transactional by default

Spring rolls back only on unchecked exceptions (RuntimeException and its subclasses) by default. A checked exception thrown inside a @Transactional method commits the transaction unless you say otherwise.

java
// WRONG — IOException is checked; Spring commits even on failure
@Transactional
public void importFile(MultipartFile f) throws IOException {
parse(f); // may throw IOException
repo.saveAll(rows); // saved to DB, then IOException rolls back nothing
}
// RIGHT — declare rollbackFor
@Transactional(rollbackFor = Exception.class)
public void importFile(MultipartFile f) throws IOException { ... }
// OR convert to unchecked in the domain layer
throw new FileProcessingException("...", cause); // extends RuntimeException
3. Propagation and isolation: pick deliberately, not by default

@Transactional defaults are PROPAGATION_REQUIRED (join existing tx or create one) and ISOLATION_DEFAULT (whatever the DB default is, usually READ COMMITTED). AI accepts both defaults everywhere — that is wrong for several common patterns:

ScenarioCorrect settingWhy the default is wrong
Audit log that must persist even if the outer tx rolls backPROPAGATION_REQUIRES_NEWREQUIRED rolls the audit row back with the outer tx
Read-only report query@Transactional(readOnly = true)Hibernate reduces flush and dirty-check work. It is a hint — it does not route to a read replica; that needs an explicit routing DataSource or a proxy
Preventing lost-update on concurrent state machineISOLATION_REPEATABLE_READ or row-lockREAD COMMITTED allows a concurrent read of the row before the update commits
Independent retry unit inside a larger operationPROPAGATION_REQUIRES_NEWREQUIRED merges into the outer tx; a rollback undoes everything
4. JPA/Hibernate N+1: lazy associations in a loop

Hibernate defaults to lazy loading for @OneToMany and @ManyToMany. A loop that accesses a lazy collection issues one SELECT per entity — N+1 selects.

java
// WRONG — triggers N+1: one query for orders, then one per order.items
List<Order> orders = orderRepo.findAll();
for (Order o : orders) {
o.getItems().size(); // LazyInitializationException if session is closed here
}
// RIGHT — fetch join / @EntityGraph
@EntityGraph(attributePaths = {"items"})
List<Order> findAll(); // single query with LEFT JOIN FETCH
// OR in JPQL
@Query("SELECT o FROM Order o LEFT JOIN FETCH o.items")
List<Order> findAllWithItems();

`LazyInitializationException` occurs when a lazy field is accessed after the Hibernate session has closed (outside the @Transactional boundary). If you serialize an entity in a Spring MVC controller that sits outside the service's transaction, Hibernate can't issue the lazy SELECT. Fix: load everything you need inside the service/transaction, or use a DTO projection.

5. open-in-view: still enabled by default in Boot 4

spring.jpa.open-in-view still defaults to `true` in Spring Boot 4 — the proposal to flip it (spring-boot issue #47547) is open, not merged. Boot logs a startup warning telling you to configure it explicitly; that warning is the only signal you get. The setting keeps the Hibernate session and a pooled DB connection open for the entire HTTP request including view rendering. Lazy loads then work in the controller layer — which masks N+1 instead of fixing it and holds connections far longer than needed.

This gets worse with virtual threads: spring.threads.virtual.enabled=true removes the thread-count ceiling that used to limit how many requests could hold a connection at once, so open-in-view turns straight into connection-pool exhaustion under load.

yaml
# Add to application.yml explicitly and fix lazy loads at the service layer
spring:
jpa:
open-in-view: false

After disabling, LazyInitializationException surfaces in controllers that relied on it — good. Fix each case with eager fetch or DTO.

6. Singleton bean scope: never store per-request state

All Spring beans are @Scope("singleton") by default — one instance shared across all threads. Storing mutable state in a singleton service field is a data race with request bleed.

java
// WRONG — currentUser is a shared mutable field; all threads stomp on it
@Service
public class InvoiceService {
private User currentUser; // NOT thread-safe
public void generate(User u) {
this.currentUser = u; // set by thread A, read by thread B
}
}
// RIGHT — pass state as method arguments; use SecurityContextHolder for auth context
public void generate(User u) {
// use u directly; never store in a field
}

Use @RequestScope beans sparingly (they require a proxy wrapper to inject into singletons) and only when you have a genuine per-request lifecycle need.

7. @Async: which executor you actually get, and its unbounded queue

The common claim that "@Async with no configuration uses SimpleAsyncTaskExecutor and spawns an unbounded number of threads" is true for plain Spring Framework and wrong for Spring Boot. Boot auto-configures an applicationTaskExecutor bean (a ThreadPoolTaskExecutor, 8 core threads by default) and @EnableAsync picks it up. The real Boot failure modes are different:

  1. The queue absorbs everything, so `max-size` is never reached. A ThreadPoolTaskExecutor only creates threads beyond core size once the queue is full. Boot's defaults are core-size=8, max-size=Integer.MAX_VALUE, queue-capacity=Integer.MAX_VALUE — an unbounded queue in front of 8 threads. The pool never grows, work piles up in heap, latency climbs, nothing scales out, and a restart drops every queued task.
  2. One shared executor for everything. applicationTaskExecutor also backs Spring MVC async request handling, WebSocket, and other framework work. A slow @Async email job starves unrelated framework tasks.
  3. Virtual threads silently change the semantics. With spring.threads.virtual.enabled=true, the auto-configured executor becomes a SimpleAsyncTaskExecutor on virtual threads and the scheduler becomes SimpleAsyncTaskScheduler — all pooling properties are ignored. Every spring.task.execution.pool.* value you set is silently dropped, and there is no backpressure at all.
yaml
# Bound the shared executor explicitly — never rely on the defaults
spring:
task:
execution:
pool:
core-size: 8
max-size: 16
queue-capacity: 100 # bounded: forces threads to spawn, then rejects
java
// RIGHT — a dedicated, named, bounded executor for each workload
@Bean(name = "emailPool")
public Executor emailPool() {
ThreadPoolTaskExecutor ex = new ThreadPoolTaskExecutor();
ex.setCorePoolSize(4);
ex.setMaxPoolSize(10);
ex.setQueueCapacity(500); // bounded
ex.setThreadNamePrefix("email-");
ex.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy()); // fail loudly
ex.initialize();
return ex;
}
@Async("emailPool")
public void sendEmail(String to) { ... }

@Async is still not a queue. Anything that must survive a pod restart belongs in a real broker or an outbox table, not in an in-memory executor queue.

Exception swallowing: exceptions thrown inside @Async methods are not propagated to the caller. They are silently swallowed unless you implement AsyncUncaughtExceptionHandler or return a Future / CompletableFuture and handle it.

java
@Configuration
public class AsyncConfig implements AsyncConfigurer {
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return (ex, method, params) ->
log.error("Async exception in {}: {}", method.getName(), ex.getMessage(), ex);
}
}
8. Input validation and overposting: @Valid + narrow DTOs

Never bind the request body directly to a JPA entity — the client can supply id, role, isAdmin, tenantId, or any other field Hibernate will happily write.

java
// WRONG — client sends {"id":1,"role":"ADMIN","name":"Alice"} and overwrites role
@PostMapping("/users")
public User create(@RequestBody User user) { return repo.save(user); }

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
15
7-day trend score
14

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/anantbhandarkar/make-it-right/mir-backend-jvm-spring/badge)](https://verified-skill.com/skills/anantbhandarkar/make-it-right/mir-backend-jvm-spring)

Something wrong with this skill or its page? Tell us.