-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExecutorService causes application to hang on termination #94
Comments
Thanks for submitting this, and your interest in the bagit-java library! It looks like you are recreating the However, the |
Hi! Don't be misguided by the While debugging I also created the instance at the start of this method, outside the for-comprehension, but that didn't matter. Besides that, the enclosing method is only called once in the whole application run. |
You are still creating multiple instances of You can also try using a different |
Ah, I see what you mean! Here is a change to fix that in my code: I removed both instances of the |
There is nothing to stop you from calling Something like However, I would find it highly inconsistent that Scala would forget to call the |
You're right, when calling both For example: in @Override
public void close() throws Exception {
executor.shutdown();
} and for @Override
public void close() throws Exception {
executor.shutdown();
manifestVerifier.close();
} In defense of Scala, this language translate to Java Bytecode and is ran by the same JVM as Java code would be. So it can't be that. I still think it is the use of I got a temporary solution for now (DANS-KNAW/easy-bag-store@402108f), but I hope there will be a cleaner solution in a future version of this library. |
…because it integrates with other JVM languages better
Good point, in the next release it will use the |
Hey, this looks great. Tested it with the provided jar and it works perfectly. The application terminates properly without hanging! Thanks for the quick responses again. Always a pleasure to work with you! |
great to hear. I will make a new release for this then (5.0.3) |
In one of our (commandline) applications that is using BagIt as a dependency, we noticed the application hanging on termination. After hanging for exactly 60 seconds the process is killed automatically by the JVM. This behavior occurred after upgrading to BagIt 5.x.
BagVerifier.isValid
.ExecutorService
with a that is used twice inisValid
, namely in the two subcalls tocheckHashes
. I mention this especially because theExecutorService
is closed by callingshutdown
insidefinalize
, which is one of those 'forbidden' methods to override in Java...isValid
:isComplete
.MandatoryVerifier
(which do not cause the described behavior), this method callsPayloadVerifier.verifyPayload
. Just asBagVerifier
, this class has anExecutorService
that is closed by callingshutdown
insidefinalize
!PayloadVerifier.verifyPayload
first callsgetAllFilesListedInManifests
which works correctly (it does not cause the described behavior). After that, it takes the result from this call and uses it incheckAllFilesListedInManifestExist
, where theExecutorService
of this class is used. This call causes the described behavior!ExecutorService
is not used (a.k.a. all tasks are executed using the underlyingRunnable.run()
method), the described behavior does not occur...I have a suspicion that the
finalize
method inPayloadVerifier
(andBagVerifier
) are causing the hanging behavior. When running the application with a debugger attached, thefinalize
methods of either class are never called... Could it be the case that thisExecutorService
therefore leaves a number of threads open, which block the termination process?Full disclosure: the project I'm talking about is demonstrating this behavior since DANS-KNAW/easy-bag-store#29 (or this commit), which upgrades the code to BagIt 5.x. The specific call that causes this behavior can be found here.
If you need more information or you want me to test something, please let me know! I'll be happy to help out.
The text was updated successfully, but these errors were encountered: