Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344382

Summary: NPE when using "autodetect workflow" (XMLRPC)
Product: z_Archived Reporter: Severin Gehwolf <sgehwolf>
Component: MylynAssignee: Frank Becker <eclipse>
Status: RESOLVED FIXED QA Contact: Frank Becker <eclipse>
Severity: normal    
Priority: P3 CC: overholt, robert.elves, steffen.pingel
Version: 3.5   
Target Milestone: 3.6   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Fedora's MANIFEST.MF patch to make xmlrpc work with the system library
none
patch V2
none
mylyn/context/zip
none
patch V3
none
mylyn/context/zip none

Description Severin Gehwolf CLA 2011-04-30 14:32:32 EDT
When I attempt to use autodetect workflow (XMLRPC) I get a NullPointerException. Here is the stack trace:

java.lang.NullPointerException
at org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient.getXmlRpcClient(BugzillaClient.java:2338)
at org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient.getRepositoryConfiguration(BugzillaClient.java:749)
at org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector.getRepositoryConfiguration(BugzillaRepositoryConnector.java:756)
at org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector.updateRepositoryConfiguration(BugzillaRepositoryConnector.java:466)
at org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector.updateRepositoryConfiguration(AbstractRepositoryConnector.java:341)
at org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientManager$1.run(BugzillaClientManager.java:117)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Note that we have a patched MANIFEST.MF of org.eclipse.mylyn.commons.xmlrpc (I'll attach the patch).
Comment 1 Severin Gehwolf CLA 2011-04-30 14:34:42 EDT
Created attachment 194429 [details]
Fedora's MANIFEST.MF patch to make xmlrpc work with the system library

We use the system xmlrpc 

$ rpm -q xmlrpc3-client
xmlrpc3-client-3.1.3-5.fc15.noarch
Comment 2 Severin Gehwolf CLA 2011-04-30 14:45:34 EDT
A little debugging discovered that location.getCredentials(AuthenticationType.REPOSITORY) in BugzillaClient.java returns null and getUserName() is called on that object without checking for null. When I change the code to:

private BugzillaXmlRpcClient getXmlRpcClient() {
		boolean useXMLRPC = Boolean.parseBoolean(configParameters.get(IBugzillaConstants.BUGZILLA_USE_XMLRPC));
		if (useXMLRPC && xmlRpcClient == null) {
			WebLocation webLocation = new WebLocation(this.repositoryUrl + "/xmlrpc.cgi"); //$NON-NLS-1$
			String username = ""; //$NON-NLS-1$
			String password = ""; //$NON-NLS-1$
			if (location.getCredentials(AuthenticationType.REPOSITORY) != null) {
				username = location.getCredentials(AuthenticationType.REPOSITORY).getUserName();
			}
			if (location.getCredentials(AuthenticationType.REPOSITORY) != null) {
				password = location.getCredentials(AuthenticationType.REPOSITORY).getPassword();
			}
			webLocation.setCredentials(AuthenticationType.REPOSITORY, username, password);
			xmlRpcClient = new BugzillaXmlRpcClient(webLocation);
			xmlRpcClient.setContentTypeCheckingEnabled(true);
		}
		return xmlRpcClient;
	}
	
I get a bit further, but this does not allow me to a.) use anonymous connections (XMLRPC error username/pwd invalid) and b.) if I use valid credentials I get:

java.lang.NullPointerException
at org.eclipse.mylyn.internal.bugzilla.core.service.BugzillaXmlRpcClient.updateProductInfo(BugzillaXmlRpcClient.java:379)
at org.eclipse.mylyn.internal.bugzilla.core.service.BugzillaXmlRpcClient.updateConfiguration(BugzillaXmlRpcClient.java:370)
at org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient.getRepositoryConfiguration(BugzillaClient.java:751)
at org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient.getTaskData(BugzillaClient.java:1981)
at org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler.getMultiTaskData(BugzillaTaskDataHandler.java:337)
at org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler.getTaskData(BugzillaTaskDataHandler.java:261)
at org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector.getTaskData(BugzillaRepositoryConnector.java:526)
at org.eclipse.mylyn.internal.tasks.ui.OpenRepositoryTaskJob.run(OpenRepositoryTaskJob.java:112)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

In general, I think it would be a good to move to Import-Package over Require-Bundle ([1][2]) entirely ;-)

[1] http://www.osgi.org/blog/2008/06/jsr-277-and-import-package.html
[2] http://www.osgi.org/blog/2006/04/misconceptions-about-osgi-headers.html

Thanks for having a look at this.
Comment 3 Severin Gehwolf CLA 2011-04-30 14:55:20 EDT
I can reproduce by using R_3_5_0 and apply the attached MANIFEST.MF patch and using said system library (which comes from: http://ws.apache.org/xmlrpc/)
Comment 4 Frank Becker CLA 2011-05-02 15:24:41 EDT
Created attachment 194532 [details]
patch V2

Steffen,

I did not know what we need to change in org.eclipse.mylyn.relang and org.eclipse.mylyn.gerrit.tests.

Can you look into this?
Comment 5 Frank Becker CLA 2011-05-02 15:24:44 EDT
Created attachment 194533 [details]
mylyn/context/zip
Comment 6 Steffen Pingel CLA 2011-05-06 16:12:53 EDT
Frank, let's carefully consider that change from Import-Package to Require-Bundle since it impacts downstream integrators and requires careful testing. As far as I understand it's a separate concern from the problem described on this bug? If that is the case please open a separate bug report to change that for all distributed bundles. If the problem is related to the XML-RPC dependency please clarify how it impacts the credentials handling.
Comment 7 Frank Becker CLA 2011-05-10 14:38:50 EDT
(In reply to comment #6)
> Frank, let's carefully consider that change from Import-Package to
> Require-Bundle since it impacts downstream integrators and requires careful
> testing. As far as I understand it's a separate concern from the problem
> described on this bug? If that is the case please open a separate bug report to
> change that for all distributed bundles. If the problem is related to the
> XML-RPC dependency please clarify how it impacts the credentials handling.

Steffen,

I change this from Require-Bundle to Import-Package. But maybe I include some errors.

I agree that we should be careful.
Comment 8 Steffen Pingel CLA 2011-05-22 16:25:16 EDT
Severin, can you file a separate bug for changing require bundle to import package? We won't be able to do that for 3.6 but we can consider it for the next release.

Frank, did you already commit the changes to BugzillaClient? I think those make sense to fix the NPE but I would prefer if we didn't change manifests and features at this point.
Comment 9 Frank Becker CLA 2011-05-22 23:51:21 EDT
Created attachment 196303 [details]
patch V3

committed patch.

This only fix the NPE!!!
Comment 10 Frank Becker CLA 2011-05-22 23:51:23 EDT
Created attachment 196304 [details]
mylyn/context/zip
Comment 11 Steffen Pingel CLA 2011-05-28 10:55:50 EDT
Thanks Frank. I'll mark this as resolved. Severin, please feel free to open another bug for the manifest changes.