Tag Archives: Java

Spring Security 5 to 6 to 7 Migration: SecurityFilterChain, Lambda DSL, and the Silent Authorization Changes

Of every breaking change in the Spring Boot 2 β†’ 3 era, the removal of WebSecurityConfigurerAdapter generated the most confused stack traces I’ve debugged β€” because security configuration is the one place where “it compiles and runs” tells you almost nothing about whether it still protects anything. This guide migrates Spring Security 5 configurations to the 6.x component model (Spring Boot 3.x), covers what tightens further in Spring Security 7 (Spring Boot 4), and flags the places where a mechanical conversion quietly changes your authorization behaviour.

Continue reading Spring Security 5 to 6 to 7 Migration: SecurityFilterChain, Lambda DSL, and the Silent Authorization Changes

RestTemplate to RestClient Migration Guide: Method Mapping, Error Handling, and the exchange() Trap

Spring Boot 4 finally forced the issue: RestTemplate, in maintenance mode since Spring 5, is out of the recommended path, and codebases full of getForObject() and exchange() calls need a plan. The good news is that RestClient (introduced in Spring 6.1 / Boot 3.2) was designed as the synchronous successor, so this migration is mostly mechanical β€” if you know the method-by-method mapping and the three places where behaviour quietly differs. This guide gives you both.

Continue reading RestTemplate to RestClient Migration Guide: Method Mapping, Error Handling, and the exchange() Trap

Hibernate 5 to 6 to 7 Migration Guide: The Breaking Changes and the Silent Ones

I have now taken three codebases through the Hibernate 5 β†’ 6 β†’ 7 path, and the same pattern repeated each time: the compile errors are the easy part, and the silent behaviour changes β€” query result types, ID generation, fetch semantics β€” are what reach production. This guide walks the migration in two deliberate hops (5β†’6, then 6β†’7), with the exact errors you will see at each stage and how to fix them. Do not attempt 5β†’7 in one jump; the diagnostics assume you pass through 6.

Continue reading Hibernate 5 to 6 to 7 Migration Guide: The Breaking Changes and the Silent Ones

Zuul to Spring Cloud Gateway Migration: Routes, Filters, and the Blocking-Call Traps

The first time I ported a Zuul gateway to Spring Cloud Gateway, the routes took an afternoon β€” and the filters took two weeks. That ratio surprises every team that attempts this migration, because the route configuration looks superficially similar while the filter model is a different universe: Zuul 1 is a blocking servlet filter chain, Spring Cloud Gateway runs on Netty with Project Reactor, and a single hidden blocking call in a ported filter can stall your entire gateway. This guide covers the route conversion, the filter-by-filter port, and the blocking-call traps, in that order.

Continue reading Zuul to Spring Cloud Gateway Migration: Routes, Filters, and the Blocking-Call Traps

Spring Cloud Netflix to Modern Alternatives: The Complete Migration Guide (2026)

In 2020 I published a dozen tutorials on this site covering Eureka, Hystrix, Zuul, Ribbon, and Feign β€” the Spring Cloud Netflix stack. They were accurate then. Today, most of that stack is dead: Netflix put Hystrix into maintenance mode back in 2018, Zuul 1 and Ribbon followed, and the Spring team removed them from the Spring Cloud release train entirely. If you are still running any of these libraries on Spring Boot 2.x, this guide maps every Netflix component to its modern replacement and shows you the actual migration steps β€” including the parts that break.

Continue reading Spring Cloud Netflix to Modern Alternatives: The Complete Migration Guide (2026)

java.util.Date and Calendar to java.time: The Complete Migration Guide (Java 8–21)

Every experienced Java developer has a date-related war story. Mine came from a batch financial-reconciliation job that silently skipped three months of records because Calendar.MONTH uses zero-based indexing β€” January is 0, not 1 β€” and the off-by-one was invisible in unit tests that only ran against the current month. The bug surfaced in a quarterly audit, not in CI. That afternoon I started migrating our entire codebase to java.time, and I have not looked back since.

The java.time package (JSR-310, shipped in Java 8) is not merely a cleaner calendar API β€” it is a complete redesign of how Java represents time. Every type is immutable and thread-safe, month numbers start at 1, year offsets are gone, and the API forces you to be explicit about whether a value carries a timezone. This guide covers every migration scenario you will encounter when moving a real codebase from java.util.Date, java.util.Calendar, java.sql.Date, and SimpleDateFormat to their modern equivalents. All code has been tested on Java 21.0.3 (Eclipse Temurin) and is fully backward-compatible to Java 8.

The guide is structured so you can jump to any section independently. If you only need to migrate SQL types for a Hibernate project, jump to Section 6. If you are fixing Jackson serialisation in a REST API, jump to Section 10. The pitfalls section at the end contains the five mistakes I see most often in code reviews β€” read it before you consider the migration done.

Continue reading java.util.Date and Calendar to java.time: The Complete Migration Guide (Java 8–21)

JUnit 6

JUnit 6 represents the next evolution in Java testing, building on the solid foundation of JUnit 5 while introducing modern features, improved API design, and enhanced developer experience. Whether you’re upgrading from JUnit 5 or starting fresh, this comprehensive guide covers everything you need to know about JUnit 6β€”from core concepts to advanced patterns.

Why JUnit 6?

JUnit 6 continues the modular architecture introduced in JUnit 5, with refinements focused on reducing cognitive load, improving discoverability, and providing better integration with modern Java features like records, sealed classes, and virtual threads. The framework emphasizes backward compatibility while offering clear upgrade paths for existing projects.

Getting Started with JUnit 6

Before diving into advanced topics, get acquainted with the fundamentals of JUnit 6.

Core Testing Patterns

Master the essential patterns that form the foundation of professional test suites.

Mocking and Test Doubles

Integrate popular mocking frameworks with JUnit 6 for effective unit testing in isolation.

Extensions and Customization

Extend JUnit 6 with custom extensions for specialized testing needs.

Integration Testing

Combine JUnit 6 with Spring and other frameworks for comprehensive integration tests.

Performance and Best Practices

Optimize your tests for speed and maintainability.

Troubleshooting and Quality

Learn what to watch out for and how to solve common problems.

Advanced Topics

Deep dives into specialized scenarios and cutting-edge patterns.

AI Prompts for JUnit 6

Use AI tools to accelerate your JUnit 6 testing workflow.

Quick Reference

Key Annotations: @Test, @DisplayName, @BeforeEach, @AfterEach, @BeforeAll, @AfterAll, @ParameterizedTest, @RepeatedTest, @Nested, @Disabled, @EnabledOnJava, @EnabledOnOs

Common Assertions: assertEquals, assertNotEquals, assertTrue, assertFalse, assertNull, assertNotNull, assertSame, assertArrayEquals, assertIterableEquals, assertThrows, assertDoesNotThrow, assertAll

Extension Points: BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback, TestInstancePostProcessor, ParameterResolver, TestTemplateInvocationContextProvider

Next Steps

JUnit 6 provides a comprehensive, modular foundation for testing Java applications of any size. Whether you’re writing unit tests for a small utility, integration tests for a microservice, or full test suites for enterprise systems, JUnit 6’s flexible extension model and rich feature set help you write clear, maintainable tests that improve code quality and accelerate development.

Start with the fundamentals, master the core patterns, and progressively adopt advanced techniques as your testing needs grow. The investment in learning JUnit 6 thoroughly pays dividends in every project you build.