Skip to Content
Java Coding Problems
book

Java Coding Problems

by Anghel Leonard
September 2019
Intermediate to advanced
816 pages
18h 47m
English
Packt Publishing
Content preview from Java Coding Problems

179. Debugging lambdas

There are at least three solutions when it comes to debugging lambdas:

  • Inspect a stack trace
  • Logging
  • Rely on IDE support (for example, NetBeans, Eclipse, and IntelliJ IDEA support debugging lambdas out of the box or provide plugins for it)

Let's focus on the first two since relying on an IDE is a very large and specific topic that isn't in the scope of this book.

Inspecting the stack trace of a failure that happened inside a lambda or a stream pipeline can be pretty puzzling. Let's consider the following snippet of code:

List<String> names = Arrays.asList("anna", "bob", null, "mary");names.stream()  .map(s -> s.toUpperCase())  .collect(Collectors.toList());

Since the third element from this list is null, we will get ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Coding Problems - Second Edition

Java Coding Problems - Second Edition

Anghel Leonard
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan
The Well-Grounded Java Developer, Second Edition

The Well-Grounded Java Developer, Second Edition

Benjamin Evans, Martijn Verburg, Jason Clark

Publisher Resources

ISBN: 9781789801415Supplemental Content