The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Blank line exception handling

Last post 05-15-2008 9:55 PM by derula. 15 replies.
Page 1 of 1 (16 items)
Sort Posts: Previous Next
  • 05-15-2008 4:30 AM

    Blank line exception handling

    Now I know that even blank lines can throw an exception... I found this pearl in a ServletContextListener class.

    	public void contextDestroyed(ServletContextEvent sce)
    	{
    		try 
    		{
    			
    		} 
    		catch (Exception e) 
    		{
    			e.printStackTrace();
    		}
    	}
    
    Filed under:
  • 05-15-2008 5:34 AM In reply to

    • ammoQ
    • Top 10 Contributor
    • Joined on 04-13-2005
    • Vienna.Austria.Europe.Earth
    • Posts 3,305

    Re: Blank line exception handling

    That's because the same class has a method without a name, as in

    // called whenever a blank line is encountered
    protected void /*nameless*/ () throws Exception {
        ...
    }

     

    beanbag girl 4ever
  • 05-15-2008 7:35 AM In reply to

    • IMil
    • Not Ranked
    • Joined on 05-26-2006
    • Posts 29

    Re: Blank line exception handling

    Probably the application is expected to work in a multithreaded environment.

    Thus, an exception may occur in some other part of the program while the blank line is being executed.

    And who knows, maybe this exception is so huge as to occupy several threads at once? In fact, it would be safer to write

    catch (Exception[ ] theWholeBunch)

    or

    while( catch( Exception) ) { /*don't panic*/ }  

    to rescue other threads as well. 

  • 05-15-2008 7:41 AM In reply to

    Re: Blank line exception handling

    IMil:

    Probably the application is expected to work in a multithreaded environment.

    Thus, an exception may occur in some other part of the program while the blank line is being executed.

    Why would the exception subsequently be thrown here, as opposed to, oh I dunno, the part of the program that generated it?
    This user has retired from TDWTF Forums, citing complete incompetence on the part of the moderators. Please continue to spam the addresses below.

    PLEASE SPAM:
    jtobin@ohioinstituteofhealthcareers.edu
    jtobin@ohiobusinesscollege.edu
  • 05-15-2008 8:09 AM In reply to

    Re: Blank line exception handling

    IMil:

    Probably the application is expected to work in a multithreaded environment.

    Thus, an exception may occur in some other part of the program while the blank line is being executed.

     

    Either you fail at humour or you fail at Java. 

    Filed under:
  • 05-15-2008 8:12 AM In reply to

    Re: Blank line exception handling

    Physics Phil:
    Either you fail at humour or you fail at Java. 
     

    I think both you and Belgarion fail at humor.

    There is no way he is serious. It is obviously a joke to follow AmmoQ's.

    Yes, I have been banned. Thanks to all for a good time.

    Tired of incompetent moderation?
    Wondering where all the clever discussion went?
    Try irc.slashnet.org #TDWTFMafia.
    We don't ban or kick and everyone is welcome.*

    *Stupid people will be mocked mercilessly and encouraged to commit suicide, however.
  • 05-15-2008 8:16 AM In reply to

    Re: Blank line exception handling

    apetrelli:

    Now I know that even blank lines can throw an exception... I found this pearl in a ServletContextListener class.

     

     That's not perl, it's Java!

     

    *crickets* 

  • 05-15-2008 9:10 AM In reply to

    Re: Blank line exception handling

    IMil:

    while( catch( Exception) ) { /*don't panic*/ } 

    to rescue other threads as well.

     

    I know this was a joke, and I don't have a Java compiler handy to check, but I'm pretty sure that this is illegal syntax.  It's funnier when it compiles.
  • 05-15-2008 9:45 AM In reply to

    • IMil
    • Not Ranked
    • Joined on 05-26-2006
    • Posts 29

    Re: Blank line exception handling

     100.times { puts "I'll never skip <irony> tags again" }

  • 05-15-2008 10:00 AM In reply to

    • dlikhten
    • Top 25 Contributor
    • Joined on 09-27-2007
    • New York Citeyah
    • Posts 669

    Re: Blank line exception handling

    IMil:

     100.times { puts "I'll never skip <irony> tags again" }

     

    Damn you with your ruby-goodness! Don't infringe on our java cult!

    Code is like a box of chocolates. You never know who stuck a turd in there and why.
    The Stupidest Man On Earth
    SSDS Bug: Program should not start up
  • 05-15-2008 1:12 PM In reply to

    Re: Blank line exception handling

    Duplication Prevention Bot is back in action!

    http://forums.thedailywtf.com/forums/t/7269.aspx

    Enjoy your consequences.

    ╩юфют√ь ёЄЁрэшЎрь яюЁр эр яхэёш■.

    Visit #TDWTF @ SlashNET - the semi-official WTF IRC channel.
  • 05-15-2008 3:42 PM In reply to

    Re: Blank line exception handling

    Spectre:
    Enjoy your consequences.
     

    OP SUCKS YAK NUTS!!!1!!!!

    Yes, I have been banned. Thanks to all for a good time.

    Tired of incompetent moderation?
    Wondering where all the clever discussion went?
    Try irc.slashnet.org #TDWTFMafia.
    We don't ban or kick and everyone is welcome.*

    *Stupid people will be mocked mercilessly and encouraged to commit suicide, however.
    Filed under:
  • 05-15-2008 4:35 PM In reply to

    Re: Blank line exception handling

    TRWTF is using Java to catch Whitespace's exceptions.

  • 05-15-2008 4:38 PM In reply to

    • IMil
    • Not Ranked
    • Joined on 05-26-2006
    • Posts 29

    Re: Blank line exception handling

    dlikhten:

    IMil:

     100.times { puts "I'll never skip <irony> tags again" }

     

    Damn you with your ruby-goodness! Don't infringe on our java cult!

     

    Oh, shut up. The real WTF is that Java was used in the original sample.

    In Ruby, the same could have been achieved with metaprogramming in one line or even less!

  • 05-15-2008 8:51 PM In reply to

    Re: Blank line exception handling

    ammoQ:
    That's because the same class has a method without a name
    Too bad VB5 doesn't support invisible methods.  It would be like noodles made of optical fibres.  Anyhow, I appreciate the 'ridiculous programming constructs' humour in this thread.

    Legendary Thread
    Yes my avatar is a fictional character, get over it. (Before she chokes you with her mind.)
  • 05-15-2008 9:55 PM In reply to

    Re: Blank line exception handling

    IMil:
    In Ruby, the same could have been achieved with metaprogramming in one line or even less!
    Oh, come on! You can't just leave it at that. Code samples plz!
    class Paula_Bean
    PAULA = "Brillant"

    def get_paula
    return PAULA
    end
    end
Page 1 of 1 (16 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems