Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.4
-
Component/s: Configuration
-
Labels:None
-
Number of attachments :
Description
While configuring a new Sonar server, it's possible to get a NullPointerException at line 140 if an unexpected exception occurs while testing the new url.
@Override
public void widgetSelected(SelectionEvent e) {
// We need those variables - in other case we would get an IllegalAccessException
final String serverUrl = getServerUrl();
final String username = getUsername();
final String password = getPassword();
try {
getWizard().getContainer().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Testing", IProgressMonitor.UNKNOWN);
try {
if (SonarCorePlugin.getServersManager().testSonar(serverUrl, username, password)) {
status = new Status(Status.OK, ISonarConstants.PLUGIN_ID, Messages.ServerLocationWizardPage_msg_connected);
} else {
status = new Status(Status.ERROR, ISonarConstants.PLUGIN_ID, Messages.ServerLocationWizardPage_msg_error);
}
} catch (CoreException e) {
status = e.getStatus();
} catch (OperationCanceledException e) {
status = Status.CANCEL_STATUS;
throw new InterruptedException();
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
});
} catch (InvocationTargetException e1) {
LoggerFactory.getLogger(getClass()).error(e1.getMessage(), e1);
} catch (InterruptedException e1) {
}
getWizard().getContainer().updateButtons();
String message = status.getMessage(); <- PROBLEM IS HERE, status CAN BE NULL
switch (status.getSeverity()) {
case IStatus.OK:
setMessage(message, IMessageProvider.INFORMATION);
break;
default:
setMessage(message, IMessageProvider.ERROR);
break;
}
}
No easy way to manually test it.