Category: Spring Boot

  • Fixing slow Bcrypt and BasicAuthenticationFilter.doFilter

    I recently investigated and fixed a performance issue with user authentication in our Spring Boot based API service. Our users started complaining about random 504s from our service. Looking at our thread pool config, worker threads, database connection pool size etc., everything looked normal. Looking at NewRelic for slow transactions, it gave a clue: It […]

  • How to mock Clock in DTO classes?

    If you need to freeze time for a Spring Boot integration test, the easiest option is to define a custom bean for Clock object for test profile. Eg This only works if the Clock object is injected by Spring into a component (Controller/Service/Repository etc.,) What if you have a Clock object in your DTO class […]

  • Hide Links object with SpringDoc & Swagger 3

    We started generating Swagger 3 documentation (OpenAPI 3.0) for our API service using SpringDoc. We are also using Spring Hateoas to include links within the response for easy navigation. The generated schema includes the 3 examples of “_links” object for each model classes that extends RepresentationModel in your response. Here is a shortened example of […]