DEV Community

Discussion on: How to Make Your Reviewer Cry Using Java Optional

Collapse
 
denday04 profile image
Andreas Stensig

Good article. Though I will add a legitimate use for orElse(null) that I encounter a lot: when transitioning from code that operates on Optional types to code that does not (and which accepts null refences). Sadly this is something that happens a lot when you try and use Optional, because a lot of frameworks cannot handle that gracefully - sad and infuriating as it is.

Collapse
 
dante0747 profile image
Majid Abarghooei

Yes, Andreas, you're right. Unfortunately, accepting null references is a bad practice that I usually face. In that case, especially when you're dealing with a framework, I think it's inevitable.