BUAAserein commented on code in PR #8846: URL: https://github.com/apache/iotdb/pull/8846#discussion_r1070222002
########## example/session/src/main/java/org/apache/iotdb/SessionExample.java: ########## @@ -828,18 +828,19 @@ private static void nonQuery() throws IoTDBConnectionException, StatementExecuti session.executeNonQueryStatement("insert into root.sg1.d1(timestamp,s1) values(200, 1)"); } - private static void setTimeout() throws StatementExecutionException { - Session tempSession = new Session(LOCAL_HOST, 6667, "root", "root", 10000, 20000); - tempSession.setQueryTimeout(60000); + private static void setTimeout() throws StatementExecutionException, IoTDBConnectionException { + try (Session tempSession = new Session(LOCAL_HOST, 6667, "root", "root", 10000, 20000)) { + tempSession.setQueryTimeout(60000); + } } private static void createClusterSession() throws IoTDBConnectionException { Review Comment: ok ########## tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileRestorableReader.java: ########## @@ -61,11 +61,12 @@ private void checkAndRepair() throws IOException { if (!isComplete()) { // Try to close it logger.info("File {} has no correct tail magic, try to repair...", file); - RestorableTsFileIOWriter rWriter = - new RestorableTsFileIOWriter(FSFactoryProducer.getFSFactory().getFile(file)); - TsFileWriter writer = new TsFileWriter(rWriter); - // This writes the right magic string - writer.close(); + try (RestorableTsFileIOWriter rWriter = + new RestorableTsFileIOWriter(FSFactoryProducer.getFSFactory().getFile(file))) { + TsFileWriter writer = new TsFileWriter(rWriter); + // This writes the right magic string + writer.close(); Review Comment: ok -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@iotdb.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org