Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-9525

PublishCopyUtil#copyFile throws an Exception but it's impl catches it and returns an IStatus instead

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • 3.3.0.M4
    • 3.3.0.M3
    • server
    • None

      see https://source.jboss.org/cru/REV-JBIDE-4/#c79

      PublishCopyUtil#copyFile should either throw Exceptions or return status objects. The current impl where exceptions are declared in the method signature but catched in the impl makes no sense. We have to decide what strategy to take (either throw or catch and return status).

      private IStatus copyFile(InputStream in, IPath to, long ts, IModuleFile mf) throws CoreException {
      	File tempFile = null;
      	try {
      		File file = to.toFile();
      		tempFile = writeToTempFile(in, to);
      		moveTempFile(tempFile, file);
      		if (ts != IResource.NULL_STAMP && ts != 0)
      			file.setLastModified(ts);
      	} catch (CoreException e) {
      		throw e;
      	} catch (Exception e) {
      		IPath path = mf.getModuleRelativePath().append(mf.getName());
      		return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID,  IEventCodes.JST_PUB_FAIL, NLS.bind(Messages.errorCopyingFile, path.toOSString(), e.getLocalizedMessage()), null);
      	} finally {
      		if (tempFile != null && tempFile.exists())
      			tempFile.deleteOnExit();
      		try {
      			if (in != null)
      				in.close();
      		} catch (Exception ex) {
      			// ignore
      		}
      	}
      	return null;
      }
      

              rob.stryker Rob Stryker (Inactive)
              adietish@redhat.com André Dietisheim
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: