Reamer commented on code in PR #5010: URL: https://github.com/apache/zeppelin/pull/5010#discussion_r2278371744
########## python/src/main/java/org/apache/zeppelin/python/PythonInterpreter.java: ########## @@ -196,15 +197,21 @@ protected boolean useIPython() { private void copyResourceToPythonWorkDir(String srcResourceName, String dstFileName) throws IOException { FileOutputStream out = null; + InputStream in = null; try { Review Comment: Please use try-with-resources, also here ########## python/src/main/java/org/apache/zeppelin/python/IPythonInterpreter.java: ########## @@ -134,6 +134,9 @@ private void setupJVMGateway(String gatewayHost, int gatewayPort) throws IOExcep private void initPythonInterpreter(String gatewayHost, int gatewayPort) throws IOException { InputStream input = Review Comment: Here, closing the input stream is missing; this can be done directly with try-with-resource. ########## rlang/src/main/java/org/apache/zeppelin/r/ZeppelinR.java: ########## @@ -97,6 +97,9 @@ public void open() throws IOException, InterpreterException { try { Review Comment: Same use try-with-resource for the input and FileOutputStream ########## python/src/main/java/org/apache/zeppelin/python/IPythonInterpreter.java: ########## @@ -161,6 +167,9 @@ private void initPythonInterpreter(String gatewayHost, int gatewayPort) throws I if (additionalPythonInitFile != null) { input = getClass().getClassLoader().getResourceAsStream(additionalPythonInitFile); Review Comment: Here, closing the input stream is missing; this can be done directly with try-with-resource. ########## alluxio/src/test/java/org/apache/zeppelin/alluxio/AlluxioInterpreterTest.java: ########## @@ -224,9 +224,12 @@ void mkdirTest() throws IOException, AlluxioException { private void fileReadTest(String fileName, int size) throws IOException { File testFile = new File(PathUtils.concatPath(mLocalAlluxioCluster.getAlluxioHome(), fileName)); FileInputStream fis = new FileInputStream(testFile); - byte[] read = new byte[size]; - fis.read(read); - fis.close(); - assertTrue(BufferUtils.equalIncreasingByteArray(size, read)); + try { Review Comment: Please use try-with-resources. This is more elegant. https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html ########## python/src/main/java/org/apache/zeppelin/python/IPythonInterpreter.java: ########## @@ -145,6 +148,9 @@ private void initPythonInterpreter(String gatewayHost, int gatewayPort) throws I input = Review Comment: Here, closing the input stream is missing; this can be done directly with try-with-resource. ########## rlang/src/main/java/org/apache/zeppelin/r/IRInterpreter.java: ########## @@ -129,6 +129,9 @@ protected void initIRKernel() throws IOException, InterpreterException { String timeout = getProperty("spark.r.backendConnectionTimeout", "6000"); InputStream input = Review Comment: Same please use try-with-resource do close the stream. -- 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...@zeppelin.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org