Bug 20323 - Can not create plugin jars if plugin.xml not under CVS control
Summary: Can not create plugin jars if plugin.xml not under CVS control
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: Dejan Glozic CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 20917 (view as bug list)
Depends on:
Blocks: 20148
  Show dependency tree
 
Reported: 2002-06-14 05:54 EDT by Hendrik Hoefer CLA
Modified: 2002-06-25 17:08 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hendrik Hoefer CLA 2002-06-14 05:54:24 EDT
In case plugin.xml is not under version control but the project itself is, the 
generation of plugin jars via popup fails with "Invalid thread access" from 
SWT. The reason is, that BuildPluginAction.enusre wants to show an error after 
finding out that there are problems with plugin.xml.
Comment 1 Dejan Glozic CLA 2002-06-19 14:04:28 EDT
The problem is that PDE is logging exception in  non-GUI thread. It should not 
do that. Here is the offending code:

	IRunnableWithProgress op = new IRunnableWithProgress() {
		public void run(IProgressMonitor monitor) {
			IWorkspaceRunnable wop = new IWorkspaceRunnable() {
			public void run(IProgressMonitor monitor) throws 
CoreException {
				try {
				    doBuildPlugin(monitor);
				} catch (InvocationTargetException e) {
				   PDEPlugin.logException(e);
				}
			  }
		   };
		   try {
			PDEPlugin.getWorkspace().run(wop, monitor);
		   } catch (CoreException e) {
		      PDEPlugin.logException(e);
		   }
	     }
	};

Recommended fix: 

try/catch block within the operation should not call 'logException' at all. It 
should take CoreException, wrap it in InvocationTargetException and rethrow it. 
The actual code to logException (that may also open an error dialog) is already 
in the main code that runs the operation and that code is running in the GUI 
thread.

F4 candidate:
Value: Medium - confusing when an operation fails and also fails to tell why it 
failed due to the SWT error.
Risk: Low - the proposed error handling pattern is already used everywhere in 
PDE.
Comment 2 Dejan Glozic CLA 2002-06-20 14:00:25 EDT
Fixed
Comment 3 Dejan Glozic CLA 2002-06-24 19:46:50 EDT
Not fixed!!

The current code in HEAD has two problems:

1) Method 'ensureValid' calls 'getActiveWorkbenchShell' that returns null 
when called from within the wizard.

		IMarker[] markers =
			featureFile.findMarkers(IMarker.PROBLEM, true, 
IResource.DEPTH_ZERO);
		if (markers.length > 0) {
			// There are errors against this file - abort
			String message;
			message = PDEPlugin.getResourceString
(KEY_ERRORS_MESSAGE);
			MessageDialog.openError(
	This	--->		PDEPlugin.getActiveWorkbenchShell(),
				PDEPlugin.getResourceString(KEY_ERRORS_TITLE),
				message);
			return false;
		}

The fix for this is to pass 'null' instead (openError method can work with null)

2) Method 'syncLogException' fails with NPE because of the same problem.

	private void syncLogException(final Throwable e) {
this ---->	final Display display = PDEPlugin.getActiveWorkbenchShell
().getDisplay();
		display.syncExec(new Runnable() {
			public void run() {
				PDEPlugin.logException(e);
			}
		});
	}

The proposed fix is to use SWTUtil.getStandardDisplay that is implemented
as follows:

	public static Display getStandardDisplay() {
		Display display;
		display = Display.getCurrent();
		if (display == null)
			display = Display.getDefault();
		return display;
	}

If this method returns null, exception will only be logged (no error message).
Just logging the error does not require being in the GUI thread.

If not approved for fixing, the bug will show up every time one of the 
following happens:

1) There are error markers agains the plug-in project or its children
2) Build script creation fails with a CoreException.

We should consider fixing this (again!) for 2.0 because users are not
informed about the primary problem due to the secondary exception
in the problem-reporting code.
Comment 4 Dejan Glozic CLA 2002-06-24 19:48:37 EDT
*** Bug 20917 has been marked as a duplicate of this bug. ***
Comment 5 Dejan Glozic CLA 2002-06-24 19:57:41 EDT
Yet another problem with 'ensureValid': it should not block the build if there 
are any 'PROBLEM' markers associated with the plug-ins project. It should only 
care for errors, not warnings or infos. In particular, infos markers crated by 
Team (e.g. "Not under CVS control" variety) should not prevent plug-in build.

See bug #20148.
Comment 6 Dejan Glozic CLA 2002-06-25 09:19:22 EDT
Risk: Small, code is in hand
Effort: Small, code is in hand
Comment 7 Dejan Glozic CLA 2002-06-25 17:08:30 EDT
Fixed in GM3