You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "valerybokov (via GitHub)" <gi...@apache.org> on 2025/10/11 08:44:15 UTC

[PR] cancel heavy close operations if the stream is already closed [pdfbox]

valerybokov opened a new pull request, #287:
URL: https://github.com/apache/pdfbox/pull/287

   (no comment)


-- 
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: dev-unsubscribe@pdfbox.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org


Re: [PR] cancel heavy close operations if the stream is already closed [pdfbox]

Posted by "asf-gitbox-commits (via GitHub)" <gi...@apache.org>.
asf-gitbox-commits closed pull request #287: cancel heavy close operations if the stream is already closed
URL: https://github.com/apache/pdfbox/pull/287


-- 
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: dev-unsubscribe@pdfbox.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org


Re: [PR] cancel heavy close operations if the stream is already closed [pdfbox]

Posted by "lehmi (via GitHub)" <gi...@apache.org>.
lehmi commented on code in PR #287:
URL: https://github.com/apache/pdfbox/pull/287#discussion_r2423782244


##########
io/src/main/java/org/apache/pdfbox/io/RandomAccessReadMemoryMappedFile.java:
##########
@@ -110,6 +110,7 @@ public void close() throws IOException
         if (fileChannel != null)
         {
             fileChannel.close();
+            fileChannel = null;

Review Comment:
   OK, that is a reasonable point. IMHO the close operation should be moved to the if clause of the mappedByteBuffer



-- 
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: dev-unsubscribe@pdfbox.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org


Re: [PR] cancel heavy close operations if the stream is already closed [pdfbox]

Posted by "valerybokov (via GitHub)" <gi...@apache.org>.
valerybokov commented on code in PR #287:
URL: https://github.com/apache/pdfbox/pull/287#discussion_r2423114132


##########
io/src/main/java/org/apache/pdfbox/io/RandomAccessReadMemoryMappedFile.java:
##########
@@ -110,6 +110,7 @@ public void close() throws IOException
         if (fileChannel != null)
         {
             fileChannel.close();
+            fileChannel = null;

Review Comment:
   The idea isn't to nullify references, but to avoid calling the close method multiple times, since it's often synchronized. I mean, it's often.



-- 
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: dev-unsubscribe@pdfbox.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org


Re: [PR] cancel heavy close operations if the stream is already closed [pdfbox]

Posted by "valerybokov (via GitHub)" <gi...@apache.org>.
valerybokov commented on code in PR #287:
URL: https://github.com/apache/pdfbox/pull/287#discussion_r2423114132


##########
io/src/main/java/org/apache/pdfbox/io/RandomAccessReadMemoryMappedFile.java:
##########
@@ -110,6 +110,7 @@ public void close() throws IOException
         if (fileChannel != null)
         {
             fileChannel.close();
+            fileChannel = null;

Review Comment:
   The idea isn't to nullify references, but to avoid calling the close method multiple times, since it's often synchronized. 



-- 
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: dev-unsubscribe@pdfbox.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org


Re: [PR] cancel heavy close operations if the stream is already closed [pdfbox]

Posted by "lehmi (via GitHub)" <gi...@apache.org>.
lehmi commented on code in PR #287:
URL: https://github.com/apache/pdfbox/pull/287#discussion_r2423043753


##########
io/src/main/java/org/apache/pdfbox/io/RandomAccessReadMemoryMappedFile.java:
##########
@@ -110,6 +110,7 @@ public void close() throws IOException
         if (fileChannel != null)
         {
             fileChannel.close();
+            fileChannel = null;

Review Comment:
   This isn't needed. The garbage collector takes care of final members once the class itself is no longer referenced



-- 
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: dev-unsubscribe@pdfbox.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org


Re: [PR] cancel heavy close operations if the stream is already closed [pdfbox]

Posted by "valerybokov (via GitHub)" <gi...@apache.org>.
valerybokov commented on code in PR #287:
URL: https://github.com/apache/pdfbox/pull/287#discussion_r2423114132


##########
io/src/main/java/org/apache/pdfbox/io/RandomAccessReadMemoryMappedFile.java:
##########
@@ -110,6 +110,7 @@ public void close() throws IOException
         if (fileChannel != null)
         {
             fileChannel.close();
+            fileChannel = null;

Review Comment:
   The idea isn't to nullify references, but to avoid calling the close and other methods multiple times, since they are often synchronized. 



-- 
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: dev-unsubscribe@pdfbox.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org