You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by GitBox <gi...@apache.org> on 2020/11/12 00:51:01 UTC

[GitHub] [tika] lcc opened a new pull request #379: Fix unecessary close

lcc opened a new pull request #379:
URL: https://github.com/apache/tika/pull/379


   Meaningless Close: In several classes, close(), specified in Closeable interface, has no effect and other methods in those classes can be called after close() without IOException.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tika] lcc commented on a change in pull request #379: Fix unecessary close

Posted by GitBox <gi...@apache.org>.
lcc commented on a change in pull request #379:
URL: https://github.com/apache/tika/pull/379#discussion_r522970661



##########
File path: tika-core/src/test/java/org/apache/tika/config/ParamTest.java
##########
@@ -61,8 +61,6 @@ public void testSaveAndLoad() throws Exception {
             ByteArrayOutputStream stream = new ByteArrayOutputStream();
             param.save(stream);
             ByteArrayInputStream inStream = new ByteArrayInputStream(stream.toByteArray());
-            stream.close();
-            inStream.close();

Review comment:
       Sorry for the late response, can you tell me which tools send a false positive warning? Also, would you like me to put these two calls at the end of the loop?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tika] kkrugler commented on a change in pull request #379: Fix unecessary close

Posted by GitBox <gi...@apache.org>.
kkrugler commented on a change in pull request #379:
URL: https://github.com/apache/tika/pull/379#discussion_r521758824



##########
File path: tika-core/src/test/java/org/apache/tika/config/ParamTest.java
##########
@@ -61,8 +61,6 @@ public void testSaveAndLoad() throws Exception {
             ByteArrayOutputStream stream = new ByteArrayOutputStream();
             param.save(stream);
             ByteArrayInputStream inStream = new ByteArrayInputStream(stream.toByteArray());
-            stream.close();
-            inStream.close();

Review comment:
       The call to `inStream.close()` is confusing here, as it's used in the next line. You're right that a `close()` for either stream does nothing, but to avoid false positive warnings from tools that aren't so smart, I would just move these two calls to the end of the loop. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tika] kkrugler commented on a change in pull request #379: Fix unecessary close

Posted by GitBox <gi...@apache.org>.
kkrugler commented on a change in pull request #379:
URL: https://github.com/apache/tika/pull/379#discussion_r525579096



##########
File path: tika-core/src/test/java/org/apache/tika/config/ParamTest.java
##########
@@ -61,8 +61,6 @@ public void testSaveAndLoad() throws Exception {
             ByteArrayOutputStream stream = new ByteArrayOutputStream();
             param.save(stream);
             ByteArrayInputStream inStream = new ByteArrayInputStream(stream.toByteArray());
-            stream.close();
-            inStream.close();

Review comment:
       Findbugs would (or at least used to) always report a missing close on any kind of InputStream (anything that was closable). And yes, I was suggesting putting those two calls at the end of the loop.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org