static public void closeSession ( LoginInput loginInput ) throws SFException , SnowflakeSQLException { logger . debug ( " public void close() throws SFException" ) ; // assert the following inputs are valid AssertUtil . assertTrue ( loginInput . getServerUrl ( ) != null , "missing server URL for closing session" ) ; AssertUtil . assertTrue ( loginInput . getSessionToken ( ) != null , "missing session token for closing session" ) ; AssertUtil . assertTrue ( loginInput . getLoginTimeout ( ) >= 0 , "missing login timeout for closing session" ) ; HttpPost postRequest = null ; try { URIBuilder uriBuilder ; uriBuilder = new URIBuilder ( loginInput . getServerUrl ( ) ) ; uriBuilder . addParameter ( SF_QUERY_SESSION_DELETE , "true" ) ; uriBuilder . addParameter ( SFSession . SF_QUERY_REQUEST_ID , UUID . randomUUID ( ) . toString ( ) ) ; uriBuilder . setPath ( SF_PATH_SESSION ) ; postRequest = new HttpPost ( uriBuilder . build ( ) ) ; postRequest . setHeader ( SF_HEADER_AUTHORIZATION , SF_HEADER_SNOWFLAKE_AUTHTYPE + " " + SF_HEADER_TOKEN_TAG + "=\"" + loginInput . getSessionToken ( ) + "\"" ) ; setServiceNameHeader ( loginInput , postRequest ) ; String theString = HttpUtil . executeRequest ( postRequest , loginInput . getLoginTimeout ( ) , 0 , null ) ; JsonNode rootNode ; logger . debug ( "connection close response: {}" , theString ) ; rootNode = mapper . readTree ( theString ) ; SnowflakeUtil . checkErrorAndThrowException ( rootNode ) ; } catch ( URISyntaxException ex ) { throw new RuntimeException ( "unexpected URI syntax exception" , ex ) ; } catch ( IOException ex ) { logger . error ( "unexpected IO exception for: " + postRequest , ex ) ; } catch ( SnowflakeSQLException ex ) { // ignore session expiration exception if ( ex . getErrorCode ( ) != Constants . SESSION_EXPIRED_GS_CODE ) { throw ex ; } } }
Close a session