Skip to content

Parallel start example#64

Merged
vogella merged 3 commits into
mainfrom
parallel-start-example
Apr 16, 2026
Merged

Parallel start example#64
vogella merged 3 commits into
mainfrom
parallel-start-example

Conversation

@vogella
Copy link
Copy Markdown
Member

@vogella vogella commented Apr 16, 2026

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request upgrades the project to Java 25 and introduces two new plugins: com.vogella.ide.iconreplacer for dynamic icon patching and com.vogella.ide.parallelstart to optimize startup performance. It also refactors the AsciiDoc editor by removing legacy components and enhancing the Language Server Protocol (LSP) implementation with improved sorting and link resolution. Feedback highlights a critical bug in the icon patching logic where subsequent updates overwrite previous ones, and recommends using FileLocator for more robust bundle file access. Additionally, improvements are suggested for logging practices and broadening relative path support in document links.

}

try (InputStream patched = rebuildJar(bundle, iconPath, replacement)) {
bundle.update(patched);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There is a critical bug in the update logic. bundle.update() is called for every single icon replacement. Because rebuildJar reads from bundle.getLocation() (which points to the original installation source), each subsequent update will overwrite the previous one. If a bundle has multiple icons mapped, only the last one processed will remain; all others will be reverted to their original state from the source JAR. You must group all replacements for a single bundle and apply them in a single rebuildJar and bundle.update() operation.

throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try (ZipOutputStream zout = new ZipOutputStream(buffer)) {
try (ZipInputStream zin = new ZipInputStream(new URL(bundle.getLocation()).openStream())) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using new URL(bundle.getLocation()) is unreliable for two reasons:

  1. bundle.getLocation() often returns strings with OSGi-specific prefixes like reference:file:, which will cause new URL() to throw a MalformedURLException if the protocol handler is not registered globally.
  2. If the bundle is installed as a directory (unpacked), openStream() will not provide a ZIP stream, causing ZipInputStream to fail.
    A more robust approach in Eclipse is to use org.eclipse.core.runtime.FileLocator.getBundleFile(bundle) to get the actual file or directory on disk.


for (Map.Entry<String, List<String>> entry : mapping.entrySet()) {
String iconFileName = entry.getKey();
URL replacement = iconFolderUrl.toURI().resolve(iconFileName).toURL();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using toURI() on OSGi-specific URL protocols (like bundleentry or bundleresource) can fail because they may not be strictly compatible with the java.net.URI specification. Since iconFolderUrl is obtained via Bundle.getEntry(), it is safer to use the URL(URL context, String spec) constructor to resolve the replacement icon path, even though it is deprecated in newer Java versions, as it correctly handles custom protocol resolution in OSGi.

Suggested change
URL replacement = iconFolderUrl.toURI().resolve(iconFileName).toURL();
URL replacement = new URL(iconFolderUrl, iconFileName);

Comment on lines +135 to +136
System.out.println("ParallelStartConfigurator: marked " + count
+ " bundles for parallel activation");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid using System.out.println for logging in Eclipse plugins. It is better practice to use the platform logging facility (Platform.getLog(getClass())) or a dedicated logging framework to ensure messages are properly captured in the error log and can be managed by the user.

if (path.startsWith("http://") || path.startsWith("https://")) {
// External link - use URL directly
targetUri = path;
} else if (path.startsWith("./") || path.startsWith("../")) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The check path.startsWith("./") || path.startsWith("../") is too restrictive for internal file links. In AsciiDoc, a link can be a simple relative path without these prefixes (e.g., link:sub/file.adoc[Label]). Since resolveFileLocation already handles relative path resolution correctly, this explicit check should be removed to support all valid relative links.

Suggested change
} else if (path.startsWith("./") || path.startsWith("../")) {
} else {

@vogella vogella force-pushed the parallel-start-example branch from b3ad251 to ca38db8 Compare April 16, 2026 11:06
vogella and others added 3 commits April 16, 2026 13:11
- Introduced com.vogella.ide.iconreplacer module for dynamic icon replacement
- Added iconreplacer to parent pom.xml and updatesite category.xml
- Included documentation in icon-replacement-plugin.md
- Cleaned up manual Asciidoc test files (Help.adoc, Testing.adoc)
- Updated AsciidocCompletionTest.java to use assertNull where appropriate
BundlePatcher:
- Group all icon replacements per bundle to apply them in a single
  rebuildJar/update cycle (fixes bug where only the last replacement
  survived per bundle)
- Use FileLocator.getBundleFileLocation() instead of new URL(bundle.getLocation())
  to handle OSGi-specific location prefixes (reference:file:, etc.)
- Use URL(context, spec) constructor for resolving icon folder URLs
  to avoid issues with OSGi-specific URL protocols and toURI()

ParallelStartConfigurator:
- Replace System.out.println with java.util.logging.Logger

AsciidocTextDocumentService:
- Remove overly restrictive ./ and ../ prefix check for internal
  file links, allowing all relative paths to resolve

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vogella vogella force-pushed the parallel-start-example branch from ca38db8 to 63cc85a Compare April 16, 2026 11:12
@vogella vogella merged commit 81d2000 into main Apr 16, 2026
1 check passed
@vogella vogella deleted the parallel-start-example branch April 16, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant