Spring Framework Risk Assessment & Management 5 — Questions and Answers
Question 1: Which risk does @Transactional on a private method in a Spring-managed bean introduce?
- Spring's AOP proxy cannot intercept private methods, so the transaction annotation is silently ignored (Correct answer)
- Private transactional methods cause a BeanCreationException at application startup
- The transaction is applied but rolled back immediately after the method returns
- Spring applies the transaction but cannot enforce the propagation rules
Correct answer: Spring's AOP proxy cannot intercept private methods, so the transaction annotation is silently ignored
Spring's proxy-based AOP only intercepts public methods called through the proxy; private methods are called directly on the target, bypassing transaction advice.
Question 2: In a Spring microservices architecture, which risk is introduced by using synchronous REST calls between all services?
- Cascading failures: a slow or unavailable downstream service can block threads and bring down callers (Correct answer)
- Services cannot share authentication tokens across synchronous HTTP boundaries
- Spring's RestTemplate does not support TLS, exposing inter-service traffic
- Synchronous calls prevent Spring Cloud LoadBalancer from distributing traffic
Correct answer: Cascading failures: a slow or unavailable downstream service can block threads and bring down callers
Synchronous chaining means a single slow dependency can exhaust thread pools upstream, causing cascading failures across the entire call chain.
Question 3: Which Spring Cloud pattern directly mitigates the risk of cascading failures in a microservices system?
- Circuit Breaker (e.g., Resilience4j) that opens when failure thresholds are exceeded (Correct answer)
- API Gateway routing that retries failed requests up to 10 times
- Using Spring Feign clients instead of RestTemplate for type-safe calls
- Configuring Spring Cloud Config to cache property sources locally
Correct answer: Circuit Breaker (e.g., Resilience4j) that opens when failure thresholds are exceeded
A Circuit Breaker stops forwarding requests to a failing service and returns a fallback, preventing thread exhaustion and failure propagation.
Question 4: What risk is introduced by setting spring.jpa.hibernate.ddl-auto=create-drop in a production Spring Boot application?
- All database tables are dropped and recreated on every application restart, causing total data loss (Correct answer)
- Hibernate generates invalid DDL that is incompatible with PostgreSQL and MySQL
- The application fails to start if the schema already exists in the database
- Spring Data repositories cannot detect the generated schema and throw RepositoryNotFoundException
Correct answer: All database tables are dropped and recreated on every application restart, causing total data loss
create-drop instructs Hibernate to drop all tables when the SessionFactory closes, meaning a server restart will destroy all production data.
Question 5: Which risk does disabling Spring Security's default password encoding (using NoOpPasswordEncoder) introduce?
- Passwords are stored in plain text, making a database breach immediately expose all user credentials (Correct answer)
- Spring Security cannot compare passwords, causing all login attempts to fail
- The application throws a deprecation error and refuses to start in Spring Boot 3.x
- Session tokens are no longer linked to the authenticated user's password hash
Correct answer: Passwords are stored in plain text, making a database breach immediately expose all user credentials
NoOpPasswordEncoder stores passwords as plain text; any attacker who reads the database immediately has all user passwords without needing to crack anything.
Question 6: In Spring WebFlux, which risk arises from performing blocking I/O operations inside a reactive pipeline?
- Blocking calls on the event-loop thread stall all concurrent reactive streams, causing system-wide latency spikes (Correct answer)
- Reactive pipelines automatically move blocking calls to a separate thread pool without any risk
- Spring WebFlux throws a BlockingCallNotPermittedException and cancels the request
- Blocking I/O causes WebFlux to fall back to the Servlet stack for that request only
Correct answer: Blocking calls on the event-loop thread stall all concurrent reactive streams, causing system-wide latency spikes
WebFlux uses a small event-loop thread pool; blocking one of these threads prevents it from processing other requests, negating non-blocking scalability.
Question 7: Which configuration risk is associated with externalizing sensitive properties in Spring Boot without encryption?
- Plain-text secrets in environment variables or config files can be read by anyone with OS-level or file-system access (Correct answer)
- Spring Boot requires all externalized properties to be encrypted or the context fails to load
- Externalized properties override application.properties, causing configuration conflicts
- Spring Cloud Config refuses to serve plain-text properties to client applications
Correct answer: Plain-text secrets in environment variables or config files can be read by anyone with OS-level or file-system access
Environment variables and config files are readable by any process or user with OS access, so unencrypted secrets are exposed to anyone who can log into the host.
Which risk does @Transactional on a private method in a Spring-managed bean introduce?