susan.harkins-LOCKED (26) [Avatar] Offline
Please share post-publication errors in this folder. We'll compile and publish a comprehensive list for everyone's convenience. Thank you!

Susan Harkins
Errata Editor
undjask (13) [Avatar] Offline
10.3.3 Optional<People> typo
The example in 10.3.3 is as follows

Optional<Person> optPerson = Optional.of(person);
Optional<String> name =

But the text refers to Optional<People>

"[...]Why? The variable optPeople is of type Optional<People>, so itÂ’s perfectly fine to call the map method.[...]"
405563 (1) [Avatar] Offline
I'm wondering about chapter 10, on Optionals. You say that if an insurance company doesn't have a name, that indicates a bug or a problem in your data. But when I look at, if Insurance::getName returns null, the getCarInsuranceName() method will return "Unknown". Shouldn't it throw an exception (probably a NPE) instead?
353164 (3) [Avatar] Offline
I believe the intent of Optional is to allow us to move away from having to catch the JVM driven NPE as a result of accessing null references. Ultimately, what you are referring to here is something that is driven by a bug in your data. In keeping with a domain driven design - we would want to catch the NPE and then throw our own exception back to the caller, letting them know that something went wrong. However, there can be several reasons for an NPE - especially if it occurs deep within an algorithm. Using an Optional would allow us to not only make the reference null safe, but would allow us greater flexibility in checking for domain specific errors, and thus allowing us to respond appropriately to those errors by throwing our own domain driven exception.
mhalver (29) [Avatar] Offline
On page 316, the wrong arrow type ("->") is used for the Scala example (it should use "=>").

The example should read

def numbers(n: Int): Stream[Int] = n #:: numbers(n+1)

def primes(numbers: Stream[Int]): Stream[Int] = {
    numbers.head #:: primes(numbers.tail filter (n => n % numbers.head != 0))

I am not finding it as I write this, but I believe that I have seen the Java 8 style arrow used in a few of the other Scala code examples as well.