Buggy code:
@ Path ( "//onetimelogon" ) public class PasswordReset extends Application { Authorise a = new Authorise ( null , Authorise . ADMIN ) ; private static Logger log = Logger . getLogger ( PasswordReset . class . getName ( ) ) ; public Set < Class < ? > > getClasses ( ) { } @ GET @ Path ( "//{email}" ) public Response oneTimeLogon ( @ Context HttpServletRequest request , @ PathParam ( "email" ) String email ) { Response response = null ; try { Class . forName ( "org.postgresql.Driver" ) ; } catch ( ClassNotFoundException e ) { String msg = "Error:<seq2seq4repair_space>Can't<seq2seq4repair_space>find<seq2seq4repair_space>PostgreSQL<seq2seq4repair_space>JDBC<seq2seq4repair_space>Driver" ; PasswordReset . log . log ( Level . SEVERE , msg , e ) ; response = Response . status ( INTERNAL_SERVER_ERROR ) . entity ( msg ) . build ( ) ; return response ; } Connection connectionSD = SDDataSource . getConnection ( "surveyKPI-onetimelogon" ) ; PreparedStatement pstmt = null ; if ( ( email != null ) && ( ( email . trim ( ) . length ( ) ) > 0 ) ) { try { String interval = "1<seq2seq4repair_space>hour" ; String uuid = UtilityMethods . setOnetimePassword ( connectionSD , pstmt , email , interval ) ; if ( uuid != null ) { System . out . println ( "Sending<seq2seq4repair_space>email" ) ; String smtp_host = null ; <START_BUG> if ( ( smtp_host = UtilityMethods . getSmtpHost ( connectionSD , request . getRemoteUser ( ) ) ) != null ) { <END_BUG> String adminEmail = UtilityMethods . getAdminEmail ( connectionSD , request . getRemoteUser ( ) ) ; ArrayList < String > idents = UtilityMethods . getIdentsFromEmail ( connectionSD , pstmt , email ) ; UtilityMethods . sendEmail ( email , uuid , "reset" , "Password<seq2seq4repair_space>Reset" , null , interval , idents , null , adminEmail , smtp_host , request . getServerName ( ) ) ; response = Response . ok ( ) . build ( ) ; } else { String msg = "Error<seq2seq4repair_space>password<seq2seq4repair_space>reset.<seq2seq4repair_space>Email<seq2seq4repair_space>not<seq2seq4repair_space>enabled<seq2seq4repair_space>on<seq2seq4repair_space>this<seq2seq4repair_space>server." ; System . out . println ( msg ) ; response = Response . status ( NOT_FOUND ) . entity ( msg ) . build ( ) ; } } else { String msg = "Error<seq2seq4repair_space>password<seq2seq4repair_space>reset.<seq2seq4repair_space>Email<seq2seq4repair_space>address<seq2seq4repair_space>not<seq2seq4repair_space>found:" + email ; System . out . println ( msg ) ; response = Response . status ( NOT_FOUND ) . entity ( msg ) . build ( ) ; } } catch ( SQLException e ) { String msg = e . getMessage ( ) ; if ( msg . contains ( "does<seq2seq4repair_space>not<seq2seq4repair_space>exist" ) ) { PasswordReset . log . info ( ( "No<seq2seq4repair_space>data:<seq2seq4repair_space>" + msg ) ) ; } else { PasswordReset . log . log ( Level . SEVERE , "Exception" , e ) ; } response = Response . status ( NOT_FOUND ) . entity ( msg ) . build ( ) ; } catch ( Exception e ) { PasswordReset . log . log ( Level . SEVERE , "Exception" , e ) ; response = Response . status ( INTERNAL_SERVER_ERROR ) . entity ( e . getMessage ( ) ) . build ( ) ; } finally { try { if ( pstmt != null ) { pstmt . close ( ) ; } } catch ( SQLException e ) { } try { if ( connectionSD != null ) { connectionSD . close ( ) ; connectionSD = null ; } } catch ( SQLException e ) { PasswordReset . log . log ( Level . SEVERE , "Failed<seq2seq4repair_space>to<seq2seq4repair_space>close<seq2seq4repair_space>connection" , e ) ; } } } else { response = Response . status ( NOT_FOUND ) . entity ( "Email<seq2seq4repair_space>not<seq2seq4repair_space>specified" ) . build ( ) ; } return response ; } class PasswordDetails { String onetime ; String password ; } @ POST public Response setPassword ( @ Context HttpServletRequest request , @ FormParam ( "passwordDetails" ) String passwordDetails ) { } }

Fix:
if ( ( smtp_host = UtilityMethods . getSmtpHost ( connectionSD , email , request . getRemoteUser ( ) ) ) != null ) {