From 2ab3f1b95c93b2f085dfec19e35996c82209ebc8 Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Tue, 18 Oct 2022 16:10:46 +0200 Subject: [PATCH 1/3] [#5395] -export failure deadlock] This patch will not block the saving of the files when the export fails. Then the next time it all falls in place again. Signed-off-by: Peter Kriens --- .../src/aQute/bnd/build/Project.java | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/biz.aQute.bndlib/src/aQute/bnd/build/Project.java b/biz.aQute.bndlib/src/aQute/bnd/build/Project.java index 33b1b1e3fc..32d21a8e72 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/build/Project.java +++ b/biz.aQute.bndlib/src/aQute/bnd/build/Project.java @@ -1966,30 +1966,34 @@ public File[] buildLocal(boolean underTest) throws Exception { return null; } - Map exports = builder.doExports(selectedRunFiles); - getInfo(builder); if (!isOk()) { return null; } - for (Map.Entry ee : exports.entrySet()) { - try (Resource resource = ee.getValue()) { - File outputFile = ee.getKey(); - File actual = write(resource::write, outputFile); + if (!selectedRunFiles.isEmpty()) { + Map exports = builder.doExports(selectedRunFiles); - if (actual != null) { - buildFilesSet.add(actual); - } else { - error("Could not save %s", outputFile); + getInfo(builder); + + if (isOk()) { + + for (Map.Entry ee : exports.entrySet()) { + try (Resource resource = ee.getValue()) { + File outputFile = ee.getKey(); + File actual = write(resource::write, outputFile); + + if (actual != null) { + buildFilesSet.add(actual); + } else { + error("Could not save %s", outputFile); + } + } } } } - if (!isOk()) { - return null; - } boolean bfsWrite = !bfs.exists() || (lastModified > bfs.lastModified()); if (buildfiles != null) { @@ -2622,7 +2626,8 @@ public Jar getValidJar(Jar jar, String id) throws Exception { return jar; } - public String _project(@SuppressWarnings("unused") String args[]) { + public String _project(@SuppressWarnings("unused") + String args[]) { return IO.absolutePath(getBase()); } @@ -2713,7 +2718,8 @@ public void action(String command, Object... args) throws Exception { /** * Run all before command plugins */ - void before(@SuppressWarnings("unused") Project p, String a) { + void before(@SuppressWarnings("unused") + Project p, String a) { List testPlugins = getPlugins(CommandPlugin.class); for (CommandPlugin testPlugin : testPlugins) { testPlugin.before(this, a); @@ -2723,7 +2729,8 @@ void before(@SuppressWarnings("unused") Project p, String a) { /** * Run all after command plugins */ - void after(@SuppressWarnings("unused") Project p, String a, Throwable t) { + void after(@SuppressWarnings("unused") + Project p, String a, Throwable t) { List testPlugins = getPlugins(CommandPlugin.class); for (int i = testPlugins.size() - 1; i >= 0; i--) { testPlugins.get(i) @@ -2737,7 +2744,8 @@ public void refreshAll() { } @SuppressWarnings("unchecked") - public void script(@SuppressWarnings("unused") String type, String script) throws Exception { + public void script(@SuppressWarnings("unused") + String type, String script) throws Exception { script(type, script, new Object[0]); } @@ -2760,7 +2768,8 @@ public void script(String type, String script, Object... args) throws Exception .eval((Map) p, new StringReader(script)); } - public String _repos(@SuppressWarnings("unused") String args[]) throws Exception { + public String _repos(@SuppressWarnings("unused") + String args[]) throws Exception { List repos = getPlugins(RepositoryPlugin.class); List names = new ArrayList<>(); for (RepositoryPlugin rp : repos) From 09794daba92ee19550bb4de72d078d7149f7e3f8 Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Thu, 3 Nov 2022 10:28:44 +0100 Subject: [PATCH 2/3] #5062 JVM Crash in bndtools explorer I was able to consistently crash the VM by selecting a binary class file in rt.jar from the VM project item and then closing the VM project item. After hundreds of trials I found that the bug was triggered when the getTreeViewer().refresh() was called during a model update. For the record, this happened on the main thread so I cannot see any issue with this. I then made the refresh conditional on a change in the filter text field. For this, an AtomicBoolean dirtyFilter was added. This seemed to work fine now. Of course this does not remove the bug. There is an SWT bug lurking but closing an tree item in the bnd explorer will no longer trigger it. Signed-off-by: Peter Kriens --- bndtools.core/src/bndtools/Plugin.java | 2 +- .../src/bndtools/explorer/BndtoolsExplorer.java | 4 +++- bndtools.core/src/bndtools/explorer/Model.java | 16 +++++----------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/bndtools.core/src/bndtools/Plugin.java b/bndtools.core/src/bndtools/Plugin.java index c2042a0bb9..d4fb57ab3b 100644 --- a/bndtools.core/src/bndtools/Plugin.java +++ b/bndtools.core/src/bndtools/Plugin.java @@ -70,7 +70,7 @@ public void start(BundleContext context) throws Exception { plugin = this; this.bundleContext = context; - scheduler = Executors.newScheduledThreadPool(1); + scheduler = Executors.newScheduledThreadPool(4); bndActivator = new Activator(); bndActivator.start(context); diff --git a/bndtools.core/src/bndtools/explorer/BndtoolsExplorer.java b/bndtools.core/src/bndtools/explorer/BndtoolsExplorer.java index eeb799fff2..22b1459791 100644 --- a/bndtools.core/src/bndtools/explorer/BndtoolsExplorer.java +++ b/bndtools.core/src/bndtools/explorer/BndtoolsExplorer.java @@ -336,9 +336,11 @@ private void updateTreeViewer() { if (!installed) { installed = true; installFilter(); + model.filterDirty.set(true); } - getTreeViewer().refresh(); + if (model.filterDirty.getAndSet(false)) + getTreeViewer().refresh(); } private void installFilter() { diff --git a/bndtools.core/src/bndtools/explorer/Model.java b/bndtools.core/src/bndtools/explorer/Model.java index 7174eb4439..155ac29f6b 100644 --- a/bndtools.core/src/bndtools/explorer/Model.java +++ b/bndtools.core/src/bndtools/explorer/Model.java @@ -24,6 +24,7 @@ class Model { String message = "initializing workspace"; int severity; String filterText; + final AtomicBoolean filterDirty = new AtomicBoolean(false); final List updates = new ArrayList<>(); final AtomicBoolean dirty = new AtomicBoolean(false); final Set pinned = new HashSet<>(); @@ -48,6 +49,7 @@ void setFilterText(String value) { glob = null; else glob = new Glob(value); + filterDirty.set(true); update(); } @@ -77,6 +79,7 @@ void updateMessage() { void setSeverity(int severity) { if (this.severity != severity) { this.severity = severity; + filterDirty.set(true); update(); } } @@ -84,7 +87,7 @@ void setSeverity(int severity) { private String getPrompt(Workspace ws) { try { if (prompt == null || prompt.isEmpty()) - prompt = "${basename;${workspace}} ${def;Bundle-Version} change macro def"; + prompt = "${basename;${workspace}} ${def;Bundle-Version} [?]"; else if ("-".equals(prompt)) return ""; @@ -113,16 +116,6 @@ void update() { * This runs async on the display thread. */ private void update0() { - try { - // coalesce some more updates on - // the worker thread(s). - Thread.sleep(50); - } catch (InterruptedException e) { - Thread.currentThread() - .interrupt(); - return; - } - if (dirty.getAndSet(false)) { updates.forEach(Runnable::run); } @@ -138,6 +131,7 @@ void doPin() { } else { pinned.add(p); } + filterDirty.set(true); update(); } From e94a24b0d4868daa33ed58462c9a27572243600a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Nov 2022 09:29:41 +0000 Subject: [PATCH 3/3] build(deps): Bump spock-core in /gradle-plugins Bumps spock-core from 2.1-groovy-3.0 to 2.3-groovy-4.0. --- updated-dependencies: - dependency-name: org.spockframework:spock-core dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- gradle-plugins/biz.aQute.bnd.gradle/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle-plugins/biz.aQute.bnd.gradle/build.gradle.kts b/gradle-plugins/biz.aQute.bnd.gradle/build.gradle.kts index 27090b9353..8d86184462 100644 --- a/gradle-plugins/biz.aQute.bnd.gradle/build.gradle.kts +++ b/gradle-plugins/biz.aQute.bnd.gradle/build.gradle.kts @@ -72,7 +72,7 @@ dependencies { implementation("biz.aQute.bnd:biz.aQute.repository:${version}") implementation("biz.aQute.bnd:biz.aQute.resolve:${version}") runtimeOnly("biz.aQute.bnd:biz.aQute.bnd.embedded-repo:${version}") - testImplementation("org.spockframework:spock-core:2.3-groovy-3.0") + testImplementation("org.spockframework:spock-core:2.3-groovy-4.0") } // Gradle plugin descriptions