Thursday 13 July 2023

Using FindFirst in an Odd Way?

So I have a list, and I'm pretty sure it's either empty or contains one element.

So I was thinking too hard, and fabricated something like this:

public Optional<Item> getItem() {
  return items.isEmpty() ? Optional.empty() : Optional.of(items.get(0)));
}

And then I thought: "What am I thinking!?" and used the stream API instead:

public Optional<Item> getItem() {
  return items.stream().findFirst();
}

There.

Seems easy enough.

Thursday 6 July 2023

Turning off Hazelcast in Payara Micro

Just wanted to turn off hazelcast in my Payara Micro instance.

I've tried putting the following in my postboot file, but that doesn't work:

set-hazelcast-configuration --enabled=false

A quick google search found reference [1].

Just adding --nocluster as a commandline parameter when running Payara Micro does the trick.

References

[1] Payara Forums - Can’t disable Hazelcast with payara-micro-maven-plugin prebootcommandfile
https://forum.payara.fish/t/cant-disable-hazelcast-with-payara-micro-maven-plugin-prebootcommandfile/321/2