diff --git a/src/main/java/net/snowflake/client/jdbc/DefaultSFConnectionHandler.java b/src/main/java/net/snowflake/client/jdbc/DefaultSFConnectionHandler.java index 9e7e59038..6bb62c82f 100644 --- a/src/main/java/net/snowflake/client/jdbc/DefaultSFConnectionHandler.java +++ b/src/main/java/net/snowflake/client/jdbc/DefaultSFConnectionHandler.java @@ -286,7 +286,7 @@ private void checkLogFolderPermissions(Path path) throws SnowflakeSQLLoggedExcep || folderPermissions.contains(PosixFilePermission.OTHERS_WRITE) || folderPermissions.contains(PosixFilePermission.OTHERS_READ) || folderPermissions.contains(PosixFilePermission.OTHERS_EXECUTE)) { - logger.info( + logger.warn( "Access permission for the logs directory '{}' is currently {} and is potentially " + "accessible to users other than the owner of the logs directory.", path.toString(), @@ -297,7 +297,7 @@ private void checkLogFolderPermissions(Path path) throws SnowflakeSQLLoggedExcep sfSession, ErrorCode.INTERNAL_ERROR, String.format( - "Un-able to get permissions of log directory %s ,%s", + "Unable to get permissions of log directory %s ,%s", path.toString(), ex.getMessage(), ex.getCause())); } } diff --git a/src/test/java/net/snowflake/client/log/JDK14LoggerWithClientLatestIT.java b/src/test/java/net/snowflake/client/log/JDK14LoggerWithClientLatestIT.java index ef510a0ff..232da8451 100644 --- a/src/test/java/net/snowflake/client/log/JDK14LoggerWithClientLatestIT.java +++ b/src/test/java/net/snowflake/client/log/JDK14LoggerWithClientLatestIT.java @@ -99,29 +99,26 @@ public void testJDK14LoggerWithQuotesInMessage() { } @Test - public void testJDK14LoggingWithMissingLogPathClientConfig() throws IOException { + public void testJDK14LoggingWithMissingLogPathClientConfig() throws Exception { Path configFilePath = Paths.get("config.json"); String configJson = "{\"common\":{\"log_level\":\"debug\"}}"; Path homeLogPath = Paths.get(homePath, "jdbc"); - try { - Files.write(configFilePath, configJson.getBytes()); - Properties properties = new Properties(); - properties.put("client_config_file", configFilePath.toString()); - Connection connection = getConnection(properties); - connection.createStatement().executeQuery("select 1"); + Files.write(configFilePath, configJson.getBytes()); + Properties properties = new Properties(); + properties.put("client_config_file", configFilePath.toString()); + try (Connection connection = getConnection(properties); + Statement statement = connection.createStatement()) { + try { + statement.executeQuery("select 1"); - File file = new File(homeLogPath.toString()); - assertTrue(file.exists()); - } catch (IOException e) { - fail("testJDK14LoggingWithMissingLogPathClientConfig failed"); - } catch (SQLException e) { - fail("testJDK14LoggingWithMissingLogPathClientConfig failed"); - } catch (Exception e) { - fail("testJDK14LoggingWithMissingLogPathClientConfig failed"); - } finally { - Files.deleteIfExists(configFilePath); - FileUtils.deleteDirectory(new File(homeLogPath.toString())); + File file = new File(homeLogPath.toString()); + assertTrue(file.exists()); + + } finally { + Files.deleteIfExists(configFilePath); + FileUtils.deleteDirectory(new File(homeLogPath.toString())); + } } } @@ -131,11 +128,11 @@ public void testJDK14LoggingWithMissingLogPathNoHomeDirClientConfig() throws Exc Path configFilePath = Paths.get("config.json"); String configJson = "{\"common\":{\"log_level\":\"debug\"}}"; - try { - Files.write(configFilePath, configJson.getBytes()); - Properties properties = new Properties(); - properties.put("client_config_file", configFilePath.toString()); - Connection connection = getConnection(properties); + Files.write(configFilePath, configJson.getBytes()); + Properties properties = new Properties(); + properties.put("client_config_file", configFilePath.toString()); + try (Connection connection = getConnection(properties); + Statement statement = connection.createStatement()) { fail("testJDK14LoggingWithMissingLogPathNoHomeDirClientConfig failed"); } catch (SnowflakeSQLLoggedException e) {