bndtools / bnd

Bnd/Bndtools. Tooling to build OSGi bundles including Eclipse, Maven, and Gradle plugins.
https://bndtools.org
Other
532 stars 305 forks source link

BndtoolsJAREditorTempFiles keeps growing: 1 jar file creates two folders, but only one is removed on closing #6340

Closed chrisrueger closed 2 weeks ago

chrisrueger commented 3 weeks ago

Problem

I noticed the following behavior recently in 7.1.0.SNAPSHOT where I am opening a lot of jar files to verify stuff.

  1. I open one .jar file image

This creates 2 temp folders

  1. now I close the Jar File Viewer window. This deletes only one of the two temp folders.
image

Expected result: Both temp folders from the 1st screenshot should have been removed. Also ending Eclipse does not remove anything.

I searched other related issues, but not sure if one of it is related. Here is the search result: https://github.com/bndtools/bnd/issues?q=is%3Aissue+bndtoolsjareditortempfiles+is%3Aclosed

chrisrueger commented 3 weeks ago

Reason seems to be that JARTreePage.update() is called two times in different threads.

And because stuff is happening in a backgroud Job

JAREditor.background("Reading zip file", monitor -> {

see https://github.com/bndtools/bnd/blob/master/bndtools.jareditor/src/bndtools/jareditor/internal/JARTreePage.java#L94

I was able to fix it by avoiding a background job when the jar is loaded: so basically removing the outer

JAREditor.background("Reading zip file", monitor -> {

and just do the stuff inside in the main / display thread. Now only one folder is created.

Performance wise I do not notice a difference. The jar opens instantly just as before. Maybe even faster, because only one temp folder is created , thus less work.

Not sure how this is "good" or "bad" in Eclipse. I personally don't know what would be bad to open the jar in the Display thread. I mean, it is like "I want to open that file, and of course I am willing to wait until it is opened".

I will do some more testing and maybe push the PR later.

@pkriens any opinion?

pkriens commented 3 weeks ago

The issue is that some jar files > 50Mb and that will be noticeable. (Or at least it used to be.)