Scrivio Interview library

Spring utilities and extension points

19 questions in 6 subtopics.

ResourceLoader and Resource

ConceptFoundations5 min read
What is the difference between classpath: and classpath*: in Spring resource locations, and when do you need the second one?
DebuggingFoundations5 min read
Code that calls new ClassPathResource("templates/report.txt").getFile() works in the IDE but throws FileNotFoundException when the app runs from the Boot jar. Why, and how do you fix it?
ScenarioAdvanced5 min read
Templates, reports and reference files are loaded from the classpath, the file system and HTTP URLs in different services, and a missing file once broke production. How would you standardise resource loading?

Type conversion and formatters

CodingFoundations6 min read
A request parameter like ?range=2024-01-01..2024-02-01 should bind to a DateRange object in a controller. Show how you would register this conversion.
InternalsIntermediate6 min read
Explain how ConversionService, Converter, GenericConverter, Formatter and PropertyEditor relate, and which one Spring uses for @Value, MVC binding and configuration properties.
LeadershipPrincipal6 min read
Type conversion and formatting rules for money, dates and identifiers differ across your services and cause data errors between systems. How would you set long-term standards for value types?

MessageSource and i18n

CodingFoundations7 min read
Configure a Spring Boot application to return validation messages in English and German, with files messages.properties and messages_de.properties, based on the Accept-Language header. What do you need?
DesignAdvanced8 min read
A product is going to 12 locales across 20 services. How would you organise message bundles, error messages and translation workflow so that services stay consistent?
LeadershipPrincipal6 min read
Your product will expand to many countries over the next years. What would you decide now about internationalisation in Spring services to avoid expensive changes later?

@Async and task execution

DebuggingFoundations6 min read
A method annotated with @Async runs on the caller thread instead of a pool thread. List the common causes.
CodingIntermediate5 min read
An @Async method needs the caller's MDC trace id and security context. Show how you would carry them across the thread hop.
ScenarioIntermediate6 min read
An @Async method that sends notifications causes memory to grow during traffic spikes until the service runs out of heap. Boot's default task executor is in use. What is happening and how do you fix it?
DesignAdvanced6 min read
Each service defines its own thread pools for @Async, scheduling and HTTP clients, with very different sizes. What would a platform standard for task execution look like?

Spring Retry

CodingFoundations6 min read
Write a method that retries a call to a payment gateway up to 3 times with exponential backoff using Spring Retry, and returns a fallback when all attempts fail.
ScenarioIntermediate6 min read
A service retries failed downstream calls 5 times on every layer: the HTTP client, a @Retryable service method and the caller's own loop. During a downstream outage traffic to it grows sharply. What is going on and what policy would you set?
LeadershipPrincipal6 min read
Utilities such as Spring Retry, @Async executors and resource loading are often copied between services with small differences. How do you decide what the platform should own and what teams should own?

Sending email with JavaMailSender

CodingFoundations6 min read
Configure Spring Boot to send an HTML email with an attachment using JavaMailSender and MimeMessageHelper. Which properties do you set, and how do you test it without a real SMTP server?
DesignIntermediate6 min read
Order confirmation emails are sent with JavaMailSender inside a @Transactional method that saves the order. Customers sometimes get emails for orders that were rolled back, and SMTP slowness makes checkout slow. Redesign it.
LeadershipAdvanced6 min read
Many Spring Boot services each send email with their own JavaMailSender configuration, templates and SMTP credentials. A credential leak led to spam sent from your domain. What do you change?