
Fix Mockito UnnecessaryStubbingException in JUnit 5
Fix Mockito's UnnecessaryStubbingException by removing dead stubs, moving setup into the tests that use it and using lenient stubs only where they belong.
Tag
77 posts

Fix Mockito's UnnecessaryStubbingException by removing dead stubs, moving setup into the tests that use it and using lenient stubs only where they belong.

Fix the PostgreSQL JDBC connection refused error by checking that the server runs and listens, the host and port are right, and Docker networking is correct.

Fix Jackson's Cannot construct instance error by giving the class a creator Jackson can call, using a record, or choosing a concrete type for interfaces.

Stop the StackOverflowError that Jackson raises when entities reference each other, by returning DTOs, or by breaking the cycle with Jackson annotations.

Fix NoSuchBeanDefinitionException by telling apart a missing type, a missing name and a bean hidden by scanning, profiles or a child context.

Understand why the JVM throws GC overhead limit exceeded, capture a heap dump at the failure and decide between a bigger heap and fixing a memory leak.

Read the helpful NullPointerException message the JVM prints, find which expression was null and remove the cause instead of adding null checks everywhere.

Read the nested messages of UnsatisfiedDependencyException to find the real problem behind a failed constructor, setter or field injection.

Fix OutOfMemoryError Metaspace by finding out whether the limit is too low, classes are generated without bound or a class loader leaks across redeploys.

Fix NumberFormatException from parseInt and parseDouble by handling whitespace, empty input, overflow and locale-specific separators before you parse.

Fix TransactionRequiredException when saving or running an update query by placing a transaction around the call and checking that the proxy applies.

Work through why Maven cannot resolve a dependency: a wrong coordinate, a cached failure, a blocked mirror, missing credentials or a proxy.