How to cancel all remaining tasks in gather if one fails?

The problem with your implementation is that it calls sleepers.cancel() after sleepers has already raised. Technically the future returned by gather() is in a completed state, so its cancellation must be no-op. To correct the code, you just need to cancel the children yourself instead of trusting gather‘s future to do it. Of course, coroutines … Read more

Application of @Sneaky Throws in lombok

To add to the existing answers. I personally dislike checked exceptions. See for more info: https://phauer.com/2015/checked-exceptions-are-evil/ To add insult to injury, the code gets bloated when avoiding the checked exceptions. Consider the usage of @SneakyThrows: List<Instant> instantsSneaky = List.of(“2020-09-28T12:30:08.797481Z”) .stream() .map(Example::parseSneaky) .collect(Collectors.toList()); @SneakyThrows private static Instant parseSneaky(String queryValue) { return new SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss.SSS’Z'”).parse(queryValue).toInstant(); } versus non-@SneakyThrows … Read more

GDB complaining about missing raise.c

To do full source code debugging of the C library on Ubuntu, there are just a few steps to take: Install the debuginfo version of libc6. It’s probably already installed – the gdb package on Ubuntu has a dependency on it – but in case it isn’t, run sudo apt install libc6-dbg. Prepare the package … Read more

postgresql error: canceling statement due to user request

We have figured out the the cause of this issue. It’s explained by buggy implementation of setQueryTimeout() in latest JDBC drivers 9.2-100x. It might not happen if you open / close connection manually, but very often happens with connection pooling in place and autocommit set to false. In this case, setQueryTimeout() should be called with … Read more

How to catch multiple exceptions in one line? (in the “except” block)

From Python Documentation: An except clause may name multiple exceptions as a parenthesized tuple, for example except (IDontLikeYouException, YouAreBeingMeanException) as e: pass Or, for Python 2 only: except (IDontLikeYouException, YouAreBeingMeanException), e: pass Separating the exception from the variable with a comma will still work in Python 2.6 and 2.7, but is now deprecated and does … Read more

What to do of exceptions when implementing java.lang.Iterator

You should rethrow exception as custom runtime exception, not generic one, for instance SomethingBadRuntimeException. Also, you can try exception tunneling. And I’m assured that forcing client to deal with exceptions by making them checked is a bad practice. It just pollutes your code or forces to wrap exceptions with runtime ones or force to process … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)