[jbosstools-issues] [JBoss JIRA] (JBIDE-9525) PublishCopyUtil#copyFile throws an Exception but it's impl catches it and returns an IStatus instead

Max Rydahl Andersen (Resolved) (JIRA) jira-events at lists.jboss.org
Tue Nov 8 10:45:45 EST 2011


     [ https://issues.jboss.org/browse/JBIDE-9525?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Max Rydahl Andersen resolved JBIDE-9525.
----------------------------------------

    Resolution: Rejected


the logic is we still report to user something went wrong for unknown exceptions but only do a hard stop when we are sure we understand the error.

Cases like Throable/Error conditions still will just fall through as expected.
                
> PublishCopyUtil#copyFile throws an Exception but it's impl catches it and returns an IStatus instead
> ----------------------------------------------------------------------------------------------------
>
>                 Key: JBIDE-9525
>                 URL: https://issues.jboss.org/browse/JBIDE-9525
>             Project: Tools (JBoss Tools)
>          Issue Type: Enhancement
>          Components: JBossAS/Servers
>    Affects Versions: 3.3.0.M3
>            Reporter: Andre Dietisheim
>            Assignee: Rob Stryker
>            Priority: Minor
>             Fix For: 3.3.x
>
>
> 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).
> {code}
> 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;
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jbosstools-issues mailing list