CodeSOD: isAlive
by Remy Porter from The Daily WTF on (#19NEJ)
Why are we here? What is the purpose of life? What does it even mean to be alive?
No, I haven't been hanging out in coffee shops wearing a beret and discussing philosophy. I've instead been puzzling over this code, from Nikolai K.
public boolean isAlive() { try { return true; } catch (Exception var2) { return false; } } protected void finalize() throws Exception { try { if(this.isAlive()) { ; } } catch (Exception var2) { System.err.println("Error occurred in finalize. Exception: " + var2); throw new Exception(var2); } }
There are some deep philsophical questions here, but I don't think we can hope to extract any answers. This code begs for an explanation, but I can't give you one. I don't think the original author could either. The best Nikolai could give us was that this was in a CORBA wrapper object. Perhaps having to use CORBA drove the original developer mad? Or perhaps the original developer has a wisdom that only the mad can access?
When will isAlive return false?
[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today!