The fail-fast approach to InterruptedException

2012-01-19  Source: Original Site  Category:Java  Views:3 

Advertisement

(In response to the column "Dealing with IntertuptedException")

The article advocates, as a minimal treatment of InterruptedException, to reinterrupt the current thread. I wholeheartedly support the condemnation of the catch-and-do-nothing approach, but I advocate more radical handling. More often than not, a component is designed with blocking calls, but with no option of premature cancellation, and this is legitimate. It is possible that the designers either don't want cancellation, or postpone the design of cancellation feature to the future.

So at a given time of development, no part of the code ever calls Thread.interrupt(). Knowing or assuming this, the programmer should, in my opinion, write code
catch (InterruptedException e) {
assert(false);
}
[/code]
Deciding exactly what to do in case of cancellation, and where in the code, is something that should be done with attention. The idea in the assert is simply to [b]fail-fast[/b] if the no-interrupt assumption is broken, currently or in some future change to the code - forcing a careful thinking. If interruption [i]is[/i] expected, it of course makes a lot of sense to reinterrupt the thread - but this is then done as a concious decision.

Yarden Nir-Buchbinder
Software Verification and Testing
IBM Haifa Research Lab

Related articles
  • The fail-fast approach to InterruptedException 2012-01-19

    (In response to the column "Dealing with IntertuptedException") The article advocates, as a minimal treatment of InterruptedException, to reinterrupt the current thread. I wholeheartedly support the condemnation of the catch-and-do-nothing approach,

  • PHP and the anti-fail-fast brigade 2013-06-08

    Why is it, that a lot of PHP developers, seem to detest the idea of fail-fast? (http://failfast.com/) Fail-fast has a great deal going for it. Yet PHP continues to fly in the face of overwhelming evidence, and suggest that it's a bad idea! Even the m

  • Oracle How to identify the failed instance ? 2012-03-09

    I have been asked this question in an interview. In a unix box there're around 10+ DB instances are running and in very rare case some of the instances would fail ie all the BG process would terminated but still there are some sga memory occupied by

  • what is the best & fast way to display a imge in memory 2012-08-03

    I need display a image in memory (surposed the image has been store in a block of memory). What is the best & fast way to display it? 'Cause CDC::setpixelv is not fast enough

  • Oracle It needs to recover by hand when the fail-over occured. 2012-09-07

    I have the database using Oracle10g(10.1.0.5)SE on Windows Server 2003 with HA Cluster using Oracle Fail Safe(3.3.4). It had smoothly run with fail-over before. But now,It needs to recover by hand when the fail-over occured. Even no connection with i

  • Ubuntu Laptop + two monitors (all aboard the fail boat) 2013-03-10

    I just bought a Zepto 3214W laptop and immediately installed ubuntu on it. I've been using linux for a while now (primarily gentoo on my stationary) and decided to go with ubuntu on the laptop. Mainly because I wanted something that I knew would work

  • Ubuntu Does compiling your own kernel actually make the OS faster? 2013-06-09

    Does compiling my own kernel actually make the OS faster? i just did that (using linux-source) and everything instantly became snappy.

  • Oracle I need find out the most intelligent approach..... 2014-04-15

    I'm working an environment where Servel Production databases are running at ORacle 8i DB Server. I'm also managing their backup at Oracle Standby Server. I need to find out the most intelligent approach to add disk space to a PRIMARY-STANDBY Producti

  • Oracle Run the Query Fast 2014-05-17

    Hi can any one explain what kind of changes i should do or create a database so that i can access the data fast , it should not take a long time to fetch the data. sanjay

  • Ubuntu Kazehakase The super fast Web Browser from Japan!(Think Firefox/Epiphany on steroids) 2014-06-12

    Kazehakase The super fast Web Browser from Japan!(Think Firefox/Epiphany on steroids) Kazehakase is simply awesome! sudo apt-get install KazehakaseThanks to Polygon (http://ubuntuforums.org/member.php?u=61586) for reminding me about this in this post

  • Java SocketException Thrown when Creating a Connection Using com.mysql.jdbc.ReplicationDriver during the Fail-Over 2014-12-07

    I try to test Mysql fail-over and fail-back function using com.mysql.jdbc.ReplicationDriver. When the fail-over happens (master server is shutdown), the following exception is thrown while trying to create a new connection. The same stand-alone test

  • Oracle How to find out the failed sql command and its data from DEFERROR 2015-03-04

    has anybody a procedure or some other possibilities to read the content of column USER_DATA of the advanced replication view DEFERROR in order to find out the failed sql command and its column values?

  • Oracle How to identify fields which are fast approaching the size limits 2014-03-04

    Is there an easy (or any) way of identifying Database fields whose field sizes are close to the limits. Example: I have field called SEQ_NUM, size of the field is 3 and currently latest value in the filed is 995, soon it will be a 1000.

  • Events vs. direct function calls -- why is the latter faster? 2013-07-06

    Greetings, I have an application that receives data from a data feed (a lot of data). Each time a piece of data comes in from the feed, I want to notify any "listeners" of the data. I have tested two models, and cannot figure out why one is faster. F

  • How to change DEVMODE data to make the printing faster in VC++? 2014-07-07

    Let me explain my question in more detailed: Environment: VC++ 6.0, Document/View architecture, SDI, print the document through CView::OnFilePrint() ( I call it MFC printing ). The OnFilePrint() is modified a little bit. Goal: I want to use the faste

  • Oracle how sql query do the performence fast 2012-02-25

    i have one report it's have 200 column .and have lack vise record also .in this report have one query button.if click query button report should disply.but have the some column filter also.what i am facing problem 1)if i am tring to click the button

  • How to handle the failed script command in an err handle procedure? 2012-04-26

    The following is an example used in Robot help doc: On Error Goto Errhdlr1 userdir=InputBox("Enter directory path:") ChDir ... MsgBox "New default directory is: " & userdrive & userdir Exit Sub Errhdlr1: ... It can work normally. But my quest

  • Ubuntu The Fix: for the "failed to parse xorg.conf" bug 2012-06-10

    Hello, i was searching the internet to try and find a solution to my nvidia-settings problems and i found a neat little guide on http://awesomelinux.blogspot.com/ This is just a post for the community and i take no credit in making this AT ALL!, i on

  • Oracle how can i get the failed row numbers in batch insertion? 2012-10-06

    Afeter execution of batch insert operation into a table, i use OCIAttrGet() to get the error number of insertion, as expected, it returns the correct number. however, when i use OCIParamGet() to get an error handle and then to get the exact failed ro

  • Finding the failed login app 2013-08-18

    DB2 8.2 AIX 5L I'm seeing a failed login every 1 minute in the dbdiag.log. I am trying to find out what script/app has the wrong password set which is causing this error. Looking for some tips to hunt this down. 2008-01-17-09.36.28.237620-300 I119118