Streams are not fault tolerant: the moment a mapping function throws, the exception propagates straight out of the terminal operation and any elements already processed are lost, with nothing collected.
List<String> inputs = List.of("1", "2", "oops", "4");
try {
List<Integer> parsed = inputs.stream().map(Integer::parseInt).toList();
System.out.println("Unreachable: " + parsed);
} catch (NumberFormatException e) {
System.out.println("Pipeline aborted: " + e.getClass().getSimpleName() + ": " + e.getMessage());
}
Pipeline aborted: NumberFormatException: For input string: "oops"
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-09-27