public class MethodIsBlockingException
extends java.lang.RuntimeException
Method may wait for some callback to receive a result from some worker thread. If this method happened to be called from another callback being run by the same thread this will block the thread forever because method is never going to get result. Such situation may raise this exception.
Currently this exception is never actually thrown so it gets more of
symbolic sense. Nevertheless it's still important to keep its declaration
because it helps to track which ones are blocking and which are not.
To do this, one should temporarily modify this class and make exception checked
(make it extend java.lang.Exception
). This will enforce the proper
declaration of all blocking methods.
Here are the simple rules: you never normally catch this exception, but add throws declaration wherever needed; if your callback method needs to throw it you are doing something wrong (i.e. calling blocking method from a callback) and risk running into a deadlock; wherever you are sure you are on a safe ground (not called from callback) and there is no need in further tracking this exception, make a symbolic try/catch and explain why you think it's safe, in a catch block:
try { makeSureAllScriptsAreLoaded(); } catch (MethodIsBlockingException e) { // I'm being called from my own thread, so it's ok if method blocks, // I can wait throw new RuntimeException(e); // never executed }
By default, MethodIsBlockingException
is unchecked exception,
so you may completely ignore it.
Copyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.