← J.P. Morgan Interview Insights

J.P. Morgan·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jul 2026

Summary

J.P. Morgan software engineer interview focused heavily on Spring Boot exception handling and API design. The question was deep enough that I kept second-guessing whether they wanted a design walkthrough or actual code, and I never fully figured that out.

Questions Asked (5)

Q1

Walk through how you'd implement centralized exception handling in a Spring Boot REST API so that every controller returns a consistent error response instead of leaking stack traces or random messages.

System DesignAPI & IntegrationsTechnical Trade-offs
Author's notes

This one took me a minute to scope properly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the goal: consistent, safe error responses across all controllers. Then describe using @ControllerAdvice with @ExceptionHandler to centralize handling, and show how to map exceptions to appropriate HTTP statuses and a standard error DTO. Finally, discuss validation errors, logging, and avoiding leakage of sensitive information.

Pro tip: Emphasize that you never expose stack traces or internal details in production, and that you log the full exception server-side with a correlation ID for traceability. Mention that you extend ResponseEntityExceptionHandler to handle Spring's built-in exceptions consistently.

1. Define a standard error response structure

Create a consistent JSON schema for errors, including fields like timestamp, status, error code, message, and path. This ensures clients can reliably parse errors.

2. Implement a global exception handler

Use @ControllerAdvice and @ExceptionHandler to catch exceptions across all controllers. Extend ResponseEntityExceptionHandler to handle Spring MVC exceptions uniformly.

3. Map exceptions to HTTP statuses and messages

For each custom exception (e.g., ResourceNotFoundException, ValidationException), define the appropriate HTTP status and a safe, user-friendly message.

4. Handle validation and binding errors

Override handleMethodArgumentNotValid to extract field errors and return a structured response with details for each invalid field.

5. Log exceptions and avoid information leakage

Log the full exception with a correlation ID at the server side, but return only a generic message and the correlation ID to the client to prevent exposing internals.

Key Points to Mention

  • @ControllerAdvice and @ExceptionHandler for centralized handling
  • Extending ResponseEntityExceptionHandler for Spring's built-in exceptions
  • Custom exception hierarchy (e.g., BusinessException, ResourceNotFoundException)
  • Standard error DTO with fields like timestamp, status, errorCode, message, path
  • Validation error handling with MethodArgumentNotValidException
  • Logging with correlation ID and not leaking stack traces in responses

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How do you surface per-field validation errors when a request body fails bean validation, and what does the response look like to the client?

API & IntegrationsTechnical Trade-offs
Author's notes

Knew this one.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Explain that you use a global exception handler to catch MethodArgumentNotValidException, extract field errors from BindingResult, and map them to a structured error response. Emphasize that the response should include field name, rejected value, and message, and that you ensure consistency across all validation errors.

Pro tip: Mention that you avoid exposing internal exception details and instead use a stable error code and user-friendly message, which is crucial in regulated environments like J.P. Morgan.

1. Catch validation exceptions globally

Use @ControllerAdvice with @ExceptionHandler(MethodArgumentNotValidException.class) to intercept validation failures across all controllers.

2. Extract field errors

From the exception's BindingResult, retrieve all FieldError objects, each containing the field name, rejected value, and default message.

3. Build a structured error response

Create a response object with a top-level error code, message, and a list of field errors, each with field, message, and optionally rejected value.

4. Return appropriate HTTP status

Respond with 400 Bad Request and include the error details in the response body, typically as JSON.

5. Ensure consistency and security

Use a standard error format across the API, avoid leaking sensitive data, and consider internationalization for messages.

Key Points to Mention

  • MethodArgumentNotValidException and BindingResult
  • @ControllerAdvice and @ExceptionHandler for global handling
  • FieldError properties: field, rejectedValue, defaultMessage
  • Structured JSON response with error code and list of field errors
  • HTTP 400 Bad Request status
  • Avoiding exposure of internal stack traces or sensitive data

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

What's the difference between @ControllerAdvice and @RestControllerAdvice, and when would you restrict an advice class to only certain controllers or packages?

Technical Trade-offsAPI & Integrations
Author's notes

Straightforward.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly defining @ControllerAdvice and @RestControllerAdvice, highlighting that @RestControllerAdvice combines @ControllerAdvice and @ResponseBody. Then explain scenarios where restricting advice to specific controllers or packages is beneficial, such as applying different exception handling or data binding rules to different API groups.

Pro tip: Mention that in large applications, global advice can lead to unintended behavior; using selectors like basePackages or annotations ensures that advice only applies where intended, improving maintainability and reducing side effects.

1. Define @ControllerAdvice

Explain that @ControllerAdvice is a specialization of @Component that allows global handling of exceptions, data binding, and model attributes across all controllers by default.

2. Define @RestControllerAdvice

Explain that @RestControllerAdvice is a convenience annotation that combines @ControllerAdvice and @ResponseBody, meaning methods return values are serialized directly to the response body, ideal for REST APIs.

3. Compare default behavior

Highlight that both apply globally, but @RestControllerAdvice automatically adds @ResponseBody to methods, so you don't need to annotate each method with @ResponseBody.

4. Explain restriction scenarios

Describe when to restrict advice: e.g., when you have multiple API versions with different error formats, when certain controllers need special exception handling, or when you want to avoid applying global advice to non-REST controllers.

5. Discuss implementation

Mention that you can restrict using attributes like basePackages, basePackageClasses, assignableTypes, or annotations in the @ControllerAdvice annotation.

Key Points to Mention

  • @RestControllerAdvice = @ControllerAdvice + @ResponseBody
  • Default behavior applies globally to all controllers
  • Restriction via basePackages, assignableTypes, annotations
  • Use cases: multiple API versions, different error handling per module
  • Avoiding unintended side effects in large applications
  • Impact on exception handling and data binding

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

How would you handle authentication and authorization failures without accidentally leaking whether a resource or an account actually exists?

System DesignTechnical Trade-offs
Author's notes

This caught me a little off guard because I'd been thinking purely about domain errors.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by acknowledging the security principle of not leaking resource existence, then describe a consistent response strategy for both authentication and authorization failures. Emphasize uniform error messages, status codes, and timing to prevent enumeration attacks, and mention logging and monitoring for security without exposing details to clients.

Pro tip: In regulated environments like J.P. Morgan, align your answer with standards like OWASP and mention compliance requirements (e.g., PCI DSS, GDPR) to show you understand the broader context. Also, highlight the importance of consistent timing to prevent side-channel attacks.

1. Clarify the threat model

Explain that the goal is to prevent attackers from enumerating valid accounts or resources by observing differences in responses. Mention common attack vectors like brute force, credential stuffing, and resource enumeration.

2. Design uniform responses

Describe how to return identical error messages, HTTP status codes (e.g., 401 for both authentication and authorization failures), and response bodies regardless of whether the account or resource exists. Avoid detailed error messages that distinguish between 'invalid credentials' and 'account not found'.

3. Normalize timing and side channels

Discuss the need to equalize response times to prevent timing attacks. For example, always perform a dummy password hash check even if the user doesn't exist, or introduce random delays to mask differences.

4. Implement secure logging and monitoring

Explain that while client responses are uniform, server-side logs should capture detailed reasons for failures to aid debugging and security monitoring. Ensure logs are protected and not exposed to clients.

5. Consider rate limiting and account lockout

Mention that rate limiting and account lockout policies can mitigate enumeration attacks, but must be applied carefully to avoid denial-of-service or leaking information through lockout messages.

Key Points to Mention

  • Use generic error messages like 'Invalid credentials' for both authentication and authorization failures.
  • Return the same HTTP status code (e.g., 401 Unauthorized) for all authentication and authorization failures.
  • Ensure consistent response times by performing dummy operations or adding random delays.
  • Log detailed failure reasons server-side for auditing and debugging, but never expose them to clients.
  • Implement rate limiting and account lockout with caution to avoid information leakage.
  • Follow OWASP guidelines and comply with financial industry regulations (e.g., PCI DSS, GDPR).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q5

What is RFC 7807 and why might you adopt that format for error responses instead of a custom schema?

API & IntegrationsTechnical Trade-offs
Author's notes

Knew the name, blanked on some specifics.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining RFC 7807 as the IETF standard for Problem Details for HTTP APIs, then explain its benefits over custom schemas: interoperability, reduced documentation, and built-in extensibility. Finally, connect it to J.P. Morgan's context by highlighting how standardization improves client integration and reduces support overhead.

Pro tip: Mention that RFC 7807 is natively supported by many frameworks (e.g., Spring, ASP.NET Core) and that adopting it can future-proof your API as tooling and client libraries increasingly expect it.

1. Define RFC 7807

State that RFC 7807 specifies a standard JSON (or XML) format for HTTP error responses, with fields like type, title, status, detail, and instance.

2. Explain the problem with custom schemas

Discuss how custom error schemas lead to inconsistent client handling, increased documentation, and higher integration costs for API consumers.

3. Highlight benefits of RFC 7807

Emphasize interoperability, reduced boilerplate, extensibility via custom members, and better developer experience.

4. Connect to business impact

Explain how standardization reduces support tickets, speeds up partner onboarding, and aligns with industry best practices—critical in financial services.

5. Acknowledge trade-offs

Mention potential downsides like limited adoption in some legacy systems or the need to map existing errors, showing balanced judgment.

Key Points to Mention

  • RFC 7807 defines a standard set of fields: type, title, status, detail, and instance.
  • Custom schemas often require clients to write bespoke parsing logic, increasing integration effort.
  • RFC 7807 is extensible: you can add custom members for domain-specific details.
  • Many popular frameworks and libraries support RFC 7807 out of the box.
  • Standardization improves API consistency and reduces documentation and support burden.
  • Adoption demonstrates adherence to industry standards, which is valued in regulated industries like finance.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.