Skip to content

Caught the exception when a version is malformed in target file#2157

Open
nburnwal09 wants to merge 2 commits intoeclipse-pde:masterfrom
nburnwal09:p2inf_editor
Open

Caught the exception when a version is malformed in target file#2157
nburnwal09 wants to merge 2 commits intoeclipse-pde:masterfrom
nburnwal09:p2inf_editor

Conversation

@nburnwal09
Copy link

Issue: #1945
Exception is caught to open the target editor when a version is malformed.

@github-actions
Copy link

github-actions bot commented Dec 19, 2025

Test Results

   519 files  ±0     519 suites  ±0   1h 5m 18s ⏱️ + 1m 20s
 3 602 tests ±0   3 548 ✅ ±0   54 💤 ±0  0 ❌ ±0 
11 127 runs  ±0  10 964 ✅ ±0  163 💤 ±0  0 ❌ ±0 

Results for commit d2ee895. ± Comparison against base commit 753c00b.

♻️ This comment has been updated with latest results.

@nburnwal09 nburnwal09 force-pushed the p2inf_editor branch 2 times, most recently from 7e72db5 to a606e61 Compare January 12, 2026 07:01
@nburnwal09
Copy link
Author

@HannesWell @laeubi
I have added a few IllegalArgumentExceptions here for the issue.

The test case is failing for UpdateUnitVersionsCommandTests.java at function (confirmVersionUpdates.)
The failure doesn’t appear to be related to my changes. I’ve also noticed similar test failures occurring across other PRs. Could you please confirm if this is likely a false positive?

assertEquals("ID: " + expectedID + " has the incorrect version. updatedText=" + updatedText,

@vogella
Copy link
Contributor

vogella commented Jan 19, 2026

@ptziegler can you also have a look?

@vogella
Copy link
Contributor

vogella commented Jan 19, 2026

@HannesWell @laeubi I have added a few IllegalArgumentExceptions here for the issue.

The test case is failing for UpdateUnitVersionsCommandTests.java at function (confirmVersionUpdates.) The failure doesn’t appear to be related to my changes. I’ve also noticed similar test failures occurring across other PRs. Could you please confirm if this is likely a false positive?

assertEquals("ID: " + expectedID + " has the incorrect version. updatedText=" + updatedText,

#2187 is supposed to improve the failing test.

TargetEditor_4=Target Editor
TargetEditor_5=Unable to load target definition model. Fix the target definition model in Source View.
TargetEditor_6=The editor input ''{0}'' is not supported.
TargetEditor_7=Unable to parse the IU version
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
TargetEditor_7=Unable to parse the IU version
TargetEditor_7=Unable to parse the IU version. Fix the target definition model in Source View.

I generally not only like if an error message tells me what's wrong, but also how to fix it.

Comment on lines +567 to +569
} catch (IllegalArgumentException e) {
fTarget = service.newTarget();
throw new CoreException(Status.error(e.getMessage(), e));
Copy link
Contributor

@ptziegler ptziegler Jan 20, 2026

Choose a reason for hiding this comment

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

Suggested change
} catch (IllegalArgumentException e) {
fTarget = service.newTarget();
throw new CoreException(Status.error(e.getMessage(), e));
}

I don't think catching the exception here is a good idea. If you do this, the editor will automatically switch to the source tab without showing the error dialog.

Additionally you can freely switch from the source tab to any other tab, without the dialog appearing. You need to go back to the source tab first and only then will the dialog appear, when trying to switch to a different tab again.

Without this catch block, the editor tries to open the definition tab, show the error dialog and then switches to the source tab.

@nburnwal09
Copy link
Author

@ptziegler
So sorry, I had made the changes locally earlier but forgot to commit them.
Could you please review now?

@merks
Copy link
Contributor

merks commented Feb 13, 2026

It would seem good for the user to know which IU and which version string is causing the problem (if that isn't already diagnosed by an error marker that draw attention to the location).

@nburnwal09 nburnwal09 requested a review from ptziegler February 16, 2026 03:56
@nburnwal09
Copy link
Author

nburnwal09 commented Feb 16, 2026

@laeubi @HannesWell
I have applied the opening of build.properties behaviours to p2.inf in the latest changes.

Also, this PR is for the addition of p2.inf in manifest and feature editor tab just like build.properties.
I will take up the auto-completion and validation part as suggested in the follow up PR once this gets approved.

Sorry this comment was meant for other PR. Please ignore it.

@ptziegler
Copy link
Contributor

@nburnwal09 Apologies for the slow response. I played around with the change and noticed that it's not really possible to save the editor, even after the version has been corrected. I assume that's why you initially caught the exception in loadTargetDefinition()?

If so, then the catch block is apparently still needed. But instead of converting it to a CoreException, I would rethrow it as is, in order to avoid the side effects described in #2157 (comment)

e.g.

private ITargetDefinition loadTargetDefinition() throws CoreException {
	ITargetPlatformService service = getTargetPlatformService();
	try {
		if (fInput instanceof IFileEditorInput) {
			ITargetHandle fileHandle = service.getTarget(((IFileEditorInput) fInput).getFile());
			fTarget = fileHandle.getTargetDefinition();
		} else if (fInput instanceof IURIEditorInput) {
			ITargetHandle externalTarget = service.getTarget(((IURIEditorInput) fInput).getURI());
			fTarget = externalTarget.getTargetDefinition();
		}
	} catch (CoreException | IllegalArgumentException e) {
		fTarget = service.newTarget();
		throw e;
	}
	PlatformUI.getWorkbench().getDisplay().asyncExec(
			() -> TargetEditor.this.getTargetChangedListener().contentsChanged(fTarget, this, true, false));
	return fTarget;
}

It would seem good for the user to know which IU and which version string is causing the problem (if that isn't already diagnosed by an error marker that draw attention to the location).

@merks The problem is that the error itself is thrown by Equinox. So there is little that can be done on the PDE with regards to the error message. The invalid version is shown in the underlying exception, which at least to me is sufficient to find the invalid IU.

image

@nburnwal09
Copy link
Author

@ptziegler
Yes,

@nburnwal09 Apologies for the slow response. I played around with the change and noticed that it's not really possible to save the editor, even after the version has been corrected. I assume that's why you initially caught the exception in loadTargetDefinition()?

Yes, you you are right. The correction of editor didn't save the editor.

e.g.

private ITargetDefinition loadTargetDefinition() throws CoreException {
	ITargetPlatformService service = getTargetPlatformService();
	try {
		if (fInput instanceof IFileEditorInput) {
			ITargetHandle fileHandle = service.getTarget(((IFileEditorInput) fInput).getFile());
			fTarget = fileHandle.getTargetDefinition();
		} else if (fInput instanceof IURIEditorInput) {
			ITargetHandle externalTarget = service.getTarget(((IURIEditorInput) fInput).getURI());
			fTarget = externalTarget.getTargetDefinition();
		}
	} catch (CoreException | IllegalArgumentException e) {
		fTarget = service.newTarget();
		throw e;
	}
	PlatformUI.getWorkbench().getDisplay().asyncExec(
			() -> TargetEditor.this.getTargetChangedListener().contentsChanged(fTarget, this, true, false));
	return fTarget;
}

But somehow I didn't see any difference with your suggested change too((maybe some problem with my local Eclipse). Let me go through it once again. Will update the change then

@eclipse-pde-bot
Copy link
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 096ecec18fb34f6a1342079ed3b3ee2038d94ba8 Mon Sep 17 00:00:00 2001
From: Eclipse PDE Bot <pde-bot@eclipse.org>
Date: Thu, 5 Mar 2026 07:44:09 +0000
Subject: [PATCH] Version bump(s) for 4.40 stream


diff --git a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
index 87bb6898ee..ddaa9c6ccc 100644
--- a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
+++ b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %name
 Bundle-SymbolicName: org.eclipse.pde.ui; singleton:=true
-Bundle-Version: 3.16.400.qualifier
+Bundle-Version: 3.16.500.qualifier
 Bundle-Activator: org.eclipse.pde.internal.ui.PDEPlugin
 Bundle-Vendor: %provider-name
 Bundle-Localization: plugin
-- 
2.53.0

Further information are available in Common Build Issues - Missing version increments.

@nburnwal09
Copy link
Author

nburnwal09 commented Mar 6, 2026

@ptziegler sorry for replying late, got catch up with other work items.
I have applied the suggested changes, and it seems to be working fine.
Could you please review this now?

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.

6 participants