java - Throws exception and return from finally - Tomcat hangs -



looking @ frequent hangs of tomcat server , came across exceptions thrown in part of code.

when examined code, looked

public static string dosomething() {     string returnvakue = "default value";      try {         resultset rs = getmyresultset();           rs.first();          returnvalue = rs.getstring("my_field"); // note exception happens @ times when resultset empty      } catch (exception e) {         throw new exception(e);     } {         return returnvalue;     }  } 

while aware ok have both throws exception , return, wondering if can cause kind of leaks in tomcat. , there potential risk performance. ? hoowever caller function stops execution @ point. views on this? affect gc?

edit : note : i know how correct code. please share views whether can potentially cause tomcat hanging.

first check if returned resultset empty.

while( rs.next() ) {     // resultset processing here     // result set not empty } 

in opinion throwing exception decision, in should doing clean e.g. closing connections.

open connections if not closed cause tomcat hang because new requests coming server waiting connections become available.

any object in java referenced not garabage collected, in case if connections not closing these objects not garbage collected.

cheers !!


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -