Why does the inner exception reach the ThreadException handler and not the actual thrown exception?

The RunWorkerCompleted event is marshaled from the BGW thread to the UI thread by the WF plumbing that makes Control.Invoke() work. Essentially, there’s a queue with delegates that is emptied by the message loop. The code that does this, Control.InvokeMarshaledCallbacks(), you’ll see it on the call stack, has a catch (Exception) clause to catch unhandled … Read more

How do I not log a particular type of Exception in Logback?

You can do it with a simple EvaluatorFilter: <filter class=”ch.qos.logback.core.filter.EvaluatorFilter”> <evaluator> <expression>java.lang.RuntimeException.class.isInstance(throwable)</expression> </evaluator> <onMatch>DENY</onMatch> </filter> Please note that you need the following dependency in your pom.xml as well: <dependency> <groupId>org.codehaus.janino</groupId> <artifactId>janino</artifactId> <version>3.1.9</version> </dependency> Another possible solution is a custom Filter implementation: import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.IThrowableProxy; import ch.qos.logback.classic.spi.ThrowableProxy; import ch.qos.logback.core.filter.Filter; import ch.qos.logback.core.spi.FilterReply; public class SampleFilter extends … Read more

CopyOnWriteArrayList throwing CurrentModificationException

CopyOnWriteArrayList.subLists throw ConcurrentModificationExceptions if the containing list changes out from underneath it: public class ListTest { private static List<int[]> intList; public static void main (String[] args) { CopyOnWriteArrayList<Integer> cowal = new CopyOnWriteArrayList<Integer>(); cowal.add(1); cowal.add(2); cowal.add(3); List<Integer> sub = cowal.subList(1, 2); cowal.add(4); sub.get(0); //throws ConcurrentModificationException } }

plpgsql error “RETURN NEXT cannot have a parameter in function with OUT parameters” in table-returning function

RETURN NEXT just returns what output parameters currently hold. The manual: If you declared the function with output parameters, write just RETURN NEXT with no expression. You object: There are no OUT parameters. Output parameters are declared among function parameters with the keyword OUT or INOUT, or implicitly in your RETURNS clause: RETURNS TABLE(column1 integer, … Read more

How expensive are Exceptions [duplicate]

Exceptions are not free… so they are expensive 🙂 The book Effective Java covers this in good detail. Item 39 Use exceptions only for exceptional conditions. Item 40 Use exceptions for recoverable conditions The author found that exceptions resulted in the code tunning 70 times slower for his test case on his machine with his … Read more