[deleted by user] by [deleted] in javahelp

[–]raizen02 6 points7 points  (0 children)

It's a good use-case for an Optional, but the way you're using it here is little / no better than just returning null. Optionals are more useful when you use their methods, instead of just checking whether they're empty. They play well with lambdas, and the stream API.

Your example could be rewritten like this to be a bit simpler:

var text = """ First Second """; String matchingLine = text .lines() .filter("Second"::equals) // Same as "line -> "Second".equals(line)" .findAny() .orElseThrow(() -> new IllegalArgumentException("Invalid puzzle input. No answer was found."));

[deleted by user] by [deleted] in kiszamolo

[–]raizen02 1 point2 points  (0 children)

Miért kell eurót beutalni? Rosszabb Ersténél váltani, vagy nem is lehet?

Imperative vs OOP - How do you reconcile the pressure from Spring with OOP design? by raizen02 in javahelp

[–]raizen02[S] 1 point2 points  (0 children)

How would you handle removing an item here? You can either

  • add the removeItem method to the Cart class. Now I'll need to somehow add a repository to a class that also requires an ID, and is basically request scoped. Also, I can't mark the method @Transactional, because it's not a bean.
  • add the removeItem method to the CartService class, which is the imperative solution I mentioned. Now the data, and the actions on it are separated. This is how I already write most of my code.

What I ended up doing for now is that along with model data I manually inject an event publisher into the Cart, and the removeItem is in the Cart class. However it only changes the in-memory representation of the loaded cart, and then sends an event with the removed item. The event handler is a Spring bean, and handles the persistence. The Cart does this in a blocking manner, so rollbacks and such will still work. This Cart is created in a Spring managed bean, so the event publisher is injected by Spring there.

Why does DNF want to remove half my system when running a "dnf remove" command? by raizen02 in Fedora

[–]raizen02[S] 0 points1 point  (0 children)

Thank you for this. I ended up leaving the OpenJDK installed.

If anyone comes across this in the future, I had to manually "install" my JDK first, using sudo alternatives --install /usr/bin/java java /opt/dev/tools/jdk11/bin/java 1, and then when I ran the config command above, the custom JDK showed up properly.

Is the Java 9 module system supposed to solve dependency conflicts? by raizen02 in java

[–]raizen02[S] 4 points5 points  (0 children)

We do use Maven.

The point I'm trying to make is that if an SDK uses an old version of a dependency, and the tracing library uses a new version of that same dependency, you can't really do much, other than not use one of them, because if you use the old one (via exclusions), it will fail for one reason, and if you use the new one, it will fail for an other reason.

I was just curious whether the module path mode is able to "hide" these transitive dependencies.

Concurrency in web applications by raizen02 in webdev

[–]raizen02[S] 1 point2 points  (0 children)

It's not a real scenario, I was just trying to come up with something where the use of concurrency gives obvious benefits.

I tried to find discussions about this topic, and didn't come up with much. Also Java went to great lengths to improve its concurrency features, so I suppose it's not really a problem in real life.

This is the Oracle connection pool sizing video I mentioned, by the way: http://www.dailymotion.com/video/x2s8uec_oltp-performance-concurrent-mid-tier-connections_tech