Fix the use of Java 8 optional