Can finalize be called before entry streams are done?
See original GitHub issueIdeally, I would think I could add as many entries with streams as I want, then call finalize
right afterward and everything would work (ie automatically wait for all the input streams to complete before actually creating the package). The documentation seems to imply that this isn’t the case tho. Can I or can’t i do that? If not, why not? Can we make it so finalize can be called without explicitly waiting for the streams?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:3
- Comments:11 (2 by maintainers)
Top Results From Across the Web
finalize() called on strongly reachable objects in Java 8
And finalize() doesn't call close() on the stream directly but via its own instance method close() which will then invoke close() on the...
Read more >A Guide to the finalize Method in Java - Baeldung
The finalize() method is called the finalizer. Finalizers get invoked when JVM figures out that this particular instance should be garbage ...
Read more >finalize called on strongly reachable object in Java 8 - Edureka
Logging shows that the finalizer thread is calling finalize() on the object that holds the stream (which in turn closes the stream).
Read more >10 points on finalize method in Java – Tutorial Example
4) finalize gets called only once by GC thread if the object revives itself from the finalize() method then finalize will not be...
Read more >MET12-J. Do not use finalizers
The Java programming language imposes no ordering on finalize() method calls. Finalizers [of different objects] may be called in any order, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey everyone !! Any news about this issue? Adding multiple files within a tar archive would be really useful…
@croqaz @mafintosh @fresheneesz
Hi, I was able to stream multiple entries using the following code and without any modifications to mafintosh’s original source code. This will create a .tar.gz file using only streams:
The key here is to call
pack.entry()
only after the previous entry has finished streaming and also to know when to explicitly callentry.end()
This is recursive but perhaps can be done differently. Maybe some tweaks are needed to get this to work properly for you (this was roughly copied and modified from my own code), but this solution works just fine for me.