Buggy code:
@ Path ( "//user" ) public class UserSvc extends Application { private static Logger log = Logger . getLogger ( UserSvc . class . getName ( ) ) ; public Set < Class < ? > > getClasses ( ) { } @ GET @ Produces ( "application//json" ) public Response getUserDetails ( @ Context HttpServletRequest request ) { Response response = null ; try { Class . forName ( "org.postgresql.Driver" ) ; } catch ( ClassNotFoundException e ) { UserSvc . log . log ( Level . SEVERE , "Can't<seq2seq4repair_space>find<seq2seq4repair_space>PostgreSQL<seq2seq4repair_space>JDBC<seq2seq4repair_space>Driver" , e ) ; response = Response . serverError ( ) . build ( ) ; return response ; } Connection connectionSD = SDDataSource . getConnection ( "surveyKPI-UserSvc" ) ; PreparedStatement pstmt = null ; User user = new User ( ) ; try { String sql = null ; ResultSet resultSet = null ; sql = "SELECT<seq2seq4repair_space>u.id<seq2seq4repair_space>as<seq2seq4repair_space>id,<seq2seq4repair_space>" + ( ( ( ( ( ( ( ( ( ( ( ( ( ( "u.name<seq2seq4repair_space>as<seq2seq4repair_space>name,<seq2seq4repair_space>" + "u.language<seq2seq4repair_space>as<seq2seq4repair_space>language,<seq2seq4repair_space>" ) + "u.email<seq2seq4repair_space>as<seq2seq4repair_space>email,<seq2seq4repair_space>" ) + "u.current_project_id<seq2seq4repair_space>as<seq2seq4repair_space>current_project_id,<seq2seq4repair_space>" ) + "u.current_survey_id<seq2seq4repair_space>as<seq2seq4repair_space>current_survey_id,<seq2seq4repair_space>" ) + "o.name<seq2seq4repair_space>as<seq2seq4repair_space>organisation_name,<seq2seq4repair_space>" ) + "o.allow_email,<seq2seq4repair_space>" ) + "o.allow_facebook,<seq2seq4repair_space>" ) + "o.allow_twitter,<seq2seq4repair_space>" ) + "o.can_edit,<seq2seq4repair_space>" ) + "o.ft_send_trail<seq2seq4repair_space>" ) + "<seq2seq4repair_space>from<seq2seq4repair_space>users<seq2seq4repair_space>u,<seq2seq4repair_space>organisation<seq2seq4repair_space>o<seq2seq4repair_space>" ) + "<seq2seq4repair_space>where<seq2seq4repair_space>u.ident<seq2seq4repair_space>=<seq2seq4repair_space>?<seq2seq4repair_space>" ) + "<seq2seq4repair_space>and<seq2seq4repair_space>u.o_id<seq2seq4repair_space>=<seq2seq4repair_space>o.id<seq2seq4repair_space>" ) + "<seq2seq4repair_space>order<seq2seq4repair_space>by<seq2seq4repair_space>u.ident;" ) ; pstmt = connectionSD . prepareStatement ( sql ) ; pstmt . setString ( 1 , request . getRemoteUser ( ) ) ; UserSvc . log . info ( ( ( ( "SQL:<seq2seq4repair_space>" + sql ) + ":" ) + ( request . getRemoteUser ( ) ) ) ) ; resultSet = pstmt . executeQuery ( ) ; while ( resultSet . next ( ) ) { user . id = resultSet . getInt ( "id" ) ; user . ident = request . getRemoteUser ( ) ; user . name = resultSet . getString ( "name" ) ; user . language = resultSet . getString ( "language" ) ; user . email = resultSet . getString ( "email" ) ; user . current_project_id = resultSet . getInt ( "current_project_id" ) ; user . current_survey_id = resultSet . getInt ( "current_survey_id" ) ; user . organisation_name = resultSet . getString ( "organisation_name" ) ; user . allow_email = resultSet . getBoolean ( "allow_email" ) ; user . allow_facebook = resultSet . getBoolean ( "allow_facebook" ) ; user . allow_twitter = resultSet . getBoolean ( "allow_twitter" ) ; user . can_edit = resultSet . getBoolean ( "can_edit" ) ; user . ft_send_trail = resultSet . getBoolean ( "ft_send_trail" ) ; } <START_BUG> user . sendEmail = ( UtilityMethods . getSmtpHost ( connectionSD , request . getRemoteUser ( ) ) ) != null ; <END_BUG> sql = "SELECT<seq2seq4repair_space>g.id<seq2seq4repair_space>as<seq2seq4repair_space>id,<seq2seq4repair_space>g.name<seq2seq4repair_space>as<seq2seq4repair_space>name<seq2seq4repair_space>" + ( ( ( "<seq2seq4repair_space>from<seq2seq4repair_space>groups<seq2seq4repair_space>g,<seq2seq4repair_space>user_group<seq2seq4repair_space>ug<seq2seq4repair_space>" + "<seq2seq4repair_space>where<seq2seq4repair_space>g.id<seq2seq4repair_space>=<seq2seq4repair_space>ug.g_id<seq2seq4repair_space>" ) + "<seq2seq4repair_space>and<seq2seq4repair_space>ug.u_id<seq2seq4repair_space>=<seq2seq4repair_space>?<seq2seq4repair_space>" ) + "<seq2seq4repair_space>order<seq2seq4repair_space>by<seq2seq4repair_space>g.name;" ) ; pstmt = connectionSD . prepareStatement ( sql ) ; pstmt . setInt ( 1 , user . id ) ; UserSvc . log . info ( ( ( ( "SQL:<seq2seq4repair_space>" + sql ) + ":" ) + ( user . id ) ) ) ; resultSet = pstmt . executeQuery ( ) ; while ( resultSet . next ( ) ) { if ( ( user . groups ) == null ) { user . groups = new ArrayList < Group > ( ) ; } Group group = new Group ( ) ; group . id = resultSet . getInt ( "id" ) ; group . name = resultSet . getString ( "name" ) ; user . groups . add ( group ) ; } sql = "SELECT<seq2seq4repair_space>p.id<seq2seq4repair_space>as<seq2seq4repair_space>id,<seq2seq4repair_space>p.name<seq2seq4repair_space>as<seq2seq4repair_space>name<seq2seq4repair_space>" + ( ( ( "<seq2seq4repair_space>from<seq2seq4repair_space>project<seq2seq4repair_space>p,<seq2seq4repair_space>user_project<seq2seq4repair_space>up<seq2seq4repair_space>" + "<seq2seq4repair_space>where<seq2seq4repair_space>p.id<seq2seq4repair_space>=<seq2seq4repair_space>up.p_id<seq2seq4repair_space>" ) + "<seq2seq4repair_space>and<seq2seq4repair_space>up.u_id<seq2seq4repair_space>=<seq2seq4repair_space>?<seq2seq4repair_space>" ) + "<seq2seq4repair_space>order<seq2seq4repair_space>by<seq2seq4repair_space>p.name;" ) ; pstmt = connectionSD . prepareStatement ( sql ) ; pstmt . setInt ( 1 , user . id ) ; UserSvc . log . info ( ( ( ( "SQL:<seq2seq4repair_space>" + sql ) + ":" ) + ( user . id ) ) ) ; resultSet = pstmt . executeQuery ( ) ; while ( resultSet . next ( ) ) { if ( ( user . projects ) == null ) { user . projects = new ArrayList < Project > ( ) ; } Project project = new Project ( ) ; project . id = resultSet . getInt ( "id" ) ; project . name = resultSet . getString ( "name" ) ; user . projects . add ( project ) ; } Gson gson = new GsonBuilder ( ) . disableHtmlEscaping ( ) . create ( ) ; String resp = gson . toJson ( user ) ; response = Response . ok ( resp ) . build ( ) ; } catch ( Exception e ) { UserSvc . log . log ( Level . SEVERE , "Error:<seq2seq4repair_space>" , e ) ; response = Response . serverError ( ) . build ( ) ; } finally { try { if ( pstmt != null ) { pstmt . close ( ) ; } } catch ( SQLException e ) { } try { if ( connectionSD != null ) { connectionSD . close ( ) ; connectionSD = null ; } } catch ( SQLException e ) { UserSvc . log . log ( Level . SEVERE , "Failed<seq2seq4repair_space>to<seq2seq4repair_space>close<seq2seq4repair_space>connection:<seq2seq4repair_space>" , e ) ; } } return response ; } @ POST @ Consumes ( "application//json" ) public Response updateUser ( @ Context HttpServletRequest request , @ FormParam ( "user" ) String user ) { } }

Fix:
user . sendEmail = ( UtilityMethods . getSmtpHost ( connectionSD , null , request . getRemoteUser ( ) ) ) != null ;