News for hackers. Stuff that matters.
Re:Cloudflare outage on November 18, 2025 post mortem by vbezhenar on Wednesday November 19, 2025 @05:19AM (#45977864)
I've found both methods very useful. I'm using `get()` when I've checked that the value is present and I don't expect any exceptions. I'm using `orElseThrow()` when I actually expect that value can be absent and throwing is fine. Something like

    if (userOpt.isPresent()) {
      var user = userOpt.get();
      var accountOpt = accountRepository.selectAccountOpt(user.getId());
      var account = accountOpt.orElseThrow();
    }
Idea checks it by default and highlights if I've used `get()` without previous check. It's not forced at compiler level, but it's good enough for me.
Re:Cloudflare outage on November 18, 2025 post mortem by loglog on Wednesday November 19, 2025 @03:08PM (#45984448)
While the `Optional` API is generally pretty inconvenient (compared e.g. to Kotlin), it does offer the more precise `ifPresent`.
Re:Cloudflare outage on November 18, 2025 post mortem by vbezhenar on Wednesday November 19, 2025 @07:27PM (#45987222)
Java lambdas are terrible so I usually avoid them. There's no reason to invent new methods, when language already has corresponding statements.