Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-vcm-dev] Possible NullPointerException bug in "Synchronize with Target..."


Please enter a bug report (so that you are reporter) and we'll have a look for 2.1.

Kevin




"Joss Wright" <joss.wright@xxxxxxxxxx>
Sent by: platform-vcm-dev-admin@xxxxxxxxxxx

02/25/2003 08:31 PM
Please respond to platform-vcm-dev

       
        To:        "Platform-Vcm-Dev" <platform-vcm-dev@xxxxxxxxxxx>
        cc:        
        Subject:        [platform-vcm-dev] Possible NullPointerException bug in "Synchronize with Target..."



I've been trying to track down a problem I've been having displaying
TeamException error messages and believe it may be a bug in the
org.eclipse.team.internal.ui.target.TargetSyncCompareInput.collectResourceCh
anges(IDiffContainer, IRemoteSyncElement, IProgressMonitor) method.

I am using Eclipse 2.0.0 on Windows 2000 and have not had the chance to
check 2.0.2 but the bug database does not indicate this as a known bug,
although I assume it could still have been fixed.

TargetSyncCompareInput.collectResourceChanges(...) is called by
SyncCompareUnit.doServerDelta(IProgressMonitor pm) contains the following
lines:

                // org.eclipse.team.internal.ui.target.SyncCompareUnit class
                void doServerDelta(IProgressMonitor pm) throws InterruptedException {
                                 pm.beginTask(null, trees.length * 1000);
                                 pm.setTaskName(Policy.bind("SyncCompareInput.taskTitle")); //$NON-NLS-1$
                                 for (int i = 0; i < trees.length; i++) {
                                                  IRemoteSyncElement tree = trees[i];
                                                  IProgressMonitor monitor = Policy.subMonitorFor(pm, 1000);
                                                  monitor.beginTask(null, 1000);
                                                  IDiffElement localRoot = collectResourceChanges(null, tree, monitor);
                                                  monitor.done();
                                                  makeParents(localRoot);
                                 }
                }

                // org.eclipse.team.internal.ui.target.TargetSyncCompareInput class
                protected IDiffElement collectResourceChanges(
                                 final IDiffContainer parent,
                                 final IRemoteSyncElement tree,
                                 IProgressMonitor pm) {

                                 final IDiffElement[] result = new IDiffElement[] {null};
                                 try {
                                                  TargetProvider provider =
TargetManager.getProvider(tree.getLocal().getProject());
                                                  provider.run(new ITargetRunnable() {
                                                                   public void run(IProgressMonitor monitor) throws TeamException {
                                                                                    result[0] = TargetSyncCompareInput.super.collectResourceChanges(parent,
tree, monitor);
                                                                   }
                                                  }, pm);
                                 } catch (TeamException e) {
                                                  TeamUIPlugin.log(e.getStatus());
                                 }
                                 return result[0];
                }

However if I throw a TeamExeption within my TargetProvider class this passes
up the hierarchy to collectResourceChanges(...) and causes a null
IDiffElement[] to be returned to doServerDelta(...), this method, in turn,
tries to call SyncCompareUnit.makeParents(localRoot) but localRoot is now
null and causes a NullPointerException to be thrown. The
NullPointerException is caught by SyncView.run():

                 private boolean run(IRunnableWithProgress op) {
                                 ProgressMonitorDialog dialog = new
ProgressMonitorDialog(getSite().getShell());
                                 try {
                                                  dialog.run(true, true, op);
                                                  return true;
                                 } catch (InvocationTargetException e) {
                                                  Throwable throwable = e.getTargetException();
                                                  IStatus error = null;
                                                  if (throwable instanceof TeamException) {
                                                                   error = ((TeamException)throwable).getStatus();
                                                  } else if (throwable instanceof CoreException) {
                                                                   error = ((CoreException)throwable).getStatus();
                                                  } else {
                                                                   error = new Status(IStatus.ERROR, TeamUIPlugin.ID, 1,
Policy.bind("simpleInternal"), throwable);
                                                  }
                                                  ErrorDialog.openError(getSite().getShell(),
Policy.bind("SyncView.unableSynchronize"), null, error);
                                                  TeamUIPlugin.log(error);
                                 } catch (InterruptedException e) {
                                 }
                                 return false;
                }

However this just causes a "simpleInternal" error message to be displayed
rather than my TeamException message, because the target exception is now an
instance of NullPointerException and not of TeamException.

The problem can be repeated with the FTP Team Plugin on a dialup network,
where the timeout is set low enough to trigger a ConnectionException. If the
site is kept when prompted, subsequently selecting "Synchronise with
Target.." from the project context menu will cause a ConnectionException if
a timeout occurs, but this will get displayed as simply "Internal Error" due
to the above NullPointerException.

I hope this doesn't waste your time but it's taken me 2 or 3 hours to find
the problem and I want to document it before I forget it.

Regards,

Joss






_______________________________________________
platform-vcm-dev mailing list
platform-vcm-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-vcm-dev



Back to the top