Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332606 - IllegalArgumentException in BundleManifestSourceLocationManager
Summary: IllegalArgumentException in BundleManifestSourceLocationManager
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.7 RC1   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-15 04:28 EST by Gunnar Wagenknecht CLA
Modified: 2011-05-16 17:06 EDT (History)
3 users (show)

See Also:
ankur_sharma: review+


Attachments
Fix (3.31 KB, patch)
2011-05-04 16:56 EDT, Curtis Windatt CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gunnar Wagenknecht CLA 2010-12-15 04:28:42 EST
When starting 3.7M4 with PDE I constantly get the following exceptions in my log file. I suspect it has something to do with missing source bundles or invalid source bundle references.

I think PDE should be more graceful here and don't throw an exception but log (or show?) a more useful warning.



java.lang.IllegalArgumentException: invalid format
at org.osgi.framework.Version.<init>(Version.java:148)
at org.eclipse.pde.internal.core.BundleManifestSourceLocationManager.setPlugins(BundleManifestSourceLocationManager.java:214)
at org.eclipse.pde.internal.core.SourceLocationManager.initializeBundleManifestLocations(SourceLocationManager.java:386)
at org.eclipse.pde.internal.core.SourceLocationManager.getBundleManifestLocator(SourceLocationManager.java:216)
at org.eclipse.pde.internal.core.SourceLocationManager.getBundleManifestLocation(SourceLocationManager.java:208)
at org.eclipse.pde.internal.core.SourceLocationManager.searchBundleManifestLocations(SourceLocationManager.java:293)
at org.eclipse.pde.internal.core.SourceLocationManager.findSourcePath(SourceLocationManager.java:58)
at org.eclipse.pde.internal.core.ClasspathUtilCore.getSourceAnnotation(ClasspathUtilCore.java:154)
at org.eclipse.pde.internal.core.PDEClasspathContainer.addExternalPlugin(PDEClasspathContainer.java:66)
at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.addPlugin(RequiredPluginsClasspathContainer.java:256)
at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.addDependency(RequiredPluginsClasspathContainer.java:230)
at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.addDependency(RequiredPluginsClasspathContainer.java:242)
at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.addDependency(RequiredPluginsClasspathContainer.java:214)
at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.computePluginEntries(RequiredPluginsClasspathContainer.java:129)
at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.getClasspathEntries(RequiredPluginsClasspathContainer.java:88)
at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2658)
at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2790)
at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1922)
at org.eclipse.jdt.core.JavaCore.initializeAfterLoad(JavaCore.java:3532)
at org.eclipse.jdt.internal.ui.InitializeAfterLoadJob$RealJob.run(InitializeAfterLoadJob.java:35)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(Unknown Source)
at org.osgi.framework.Version.<init>(Version.java:134)
... 20 more
Comment 1 Curtis Windatt CLA 2010-12-15 15:03:22 EST
You are correct that this is from bad information in a source bundle header. We extract the name and version of the bundle that the source bundle provides source for.  If the name or version does not exist, we ignore the source bundle, but if the version is invalid, we log an error.

It would be good to understand what bundle is causing this problem.  The bundle header is invalid, which is the purpose of the logged error.  It is unfortunate that the error returned by the Version constructor doesn't say what the invalid argument was.

The only option for PDE to handle this more gracefully is to ignore the bundle without logging.  I figured that an incorrect header would be rare enough that a logged error would be helpful information.
Comment 2 Gunnar Wagenknecht CLA 2010-12-15 15:06:03 EST
(In reply to comment #1)
> The only option for PDE to handle this more gracefully is to ignore the bundle
> without logging.  I figured that an incorrect header would be rare enough that
> a logged error would be helpful information.

Logging a warning is ok. I just think the stack-trace isn't necessary. I also don't remember seeing the bundle name somewhere. Maybe the log message could say which bundle caused the issue? It just says "Problem processing bundle manifest source header".
Comment 3 Alain Picard CLA 2011-04-22 15:05:13 EDT
I just had the same issue and it took me hours to figure out that the version number from a source plugin from Orbit was incorrect.

The following easy patch would make everyone's life much easier, and can be applied easily and rapidly:

try {
  version = new Version(versionEntry);
} catch (IllegalArgumentException e) {
  PDECore.log(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind(PDECoreMessages.SourceLocationManager_problemProcessingBundleManifestSourceHeader, versionEntry, currentPlugin.getName(), path.toString(), e));
}

and replace  									
PDECoreMessages.SourceLocationManager_problemProcessingBundleManifestSourceHeader
with:
 Problem processing bundle manifest source header, version: {0}, plugin: {1}, location: {2}

Thanks
Alain
Comment 4 Curtis Windatt CLA 2011-05-04 16:56:15 EDT
Created attachment 194768 [details]
Fix
Comment 5 Curtis Windatt CLA 2011-05-04 16:56:58 EDT
The fix provides a proper warning for the bad header.

Ankur please review for RC1 inclusion.
Comment 6 Ankur Sharma CLA 2011-05-08 05:32:36 EDT
+1

Applied to HEAD
Comment 7 Curtis Windatt CLA 2011-05-16 17:06:06 EDT
Verified in I20110514-0800