Issue
Is it possible to force an exception to be thrown while debugging.
Let me give you an example: I am debugging some code where I download a page from the internet. When the Internet connection is lost, or network card is down, an IOException should be thrown, BUT instead the execution is blocking (on the second line)
URLConnection connection = requestURL.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
I need a way to force throwing an exception while debugging when the code is blocking so I can jump to the catch block.
I am using netbeans BTW.
While Debugging = added manually when the execution thread is paused.
EDIT: In other words, I need to inject - Invoke an exception while running, without affecting current code !
Thank you.
Solution
I would find the variable that is being waited on, and in the expression window in eclipse, call notify on that variable, then i would null
out that variable, so that the synchronized block would throw a NullPointerException
.
Answered By - MeBigFatGuy
Answer Checked By - Willingham (JavaFixing Volunteer)