Skip to content
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

JarViewer: Fix orphaned temp files (remove background jobs) #6342

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;

import aQute.bnd.exceptions.Exceptions;
import aQute.bnd.osgi.Jar;
import aQute.bnd.print.JarPrinter;

Expand Down Expand Up @@ -393,10 +394,13 @@ private void update() {
return;
}
loading = true;
JAREditor.background("Printing ZIP file", monitor -> print(uri), text -> {
try {
String text = print(uri);
styledText.setText(text);
styledText.setFocus();
});
} catch (Exception e) {
throw Exceptions.duck(e);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

import aQute.bnd.exceptions.Exceptions;
import aQute.lib.hex.Hex;
import aQute.lib.io.ByteBufferOutputStream;
import aQute.lib.io.IO;
Expand Down Expand Up @@ -201,13 +202,13 @@ private void update() {
lastModified.setText("");
if (resource instanceof IFile) {
IFile node = (IFile) resource;
JAREditor.background("Loading " + resource.getName(), mon -> {
try (InputStream in = limitRead ? new LimitedInputStream(node.getContents(), READ_LIMIT)
: node.getContents()) {
return IO.copy(in, new ByteBufferOutputStream())
.toByteBuffer();
}
}, this::setContent);
try (InputStream in = limitRead ? new LimitedInputStream(node.getContents(), READ_LIMIT)
: node.getContents()) {
setContent(IO.copy(in, new ByteBufferOutputStream())
.toByteBuffer());
} catch (Exception e) {
throw Exceptions.duck(e);
}
} else {
setContent("");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.graphics.Image;
Expand All @@ -20,6 +21,8 @@
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.plugin.AbstractUIPlugin;

import aQute.bnd.exceptions.Exceptions;

public class JARTreePage extends FormPage {

private Image titleImg;
Expand Down Expand Up @@ -101,19 +104,21 @@ private void update() {
if (loading.getAndIncrement() > 1)
return;

JAREditor.background("Reading zip file", monitor -> {
try {
IFolder folder;
do {
folder = getFolder(uri, monitor);
folder = getFolder(uri, new NullProgressMonitor());
loading.getAndDecrement();
} while (loading.getAndSet(0) > 0);
return folder;
}, folder -> {

if (closed)
return;
setFolder(folder);
tree.setFormInput(folder);
});
} catch (CoreException e) {
throw Exceptions.duck(e);
}

}

private void setFolder(IFolder folder) {
Expand Down