[jbosstools-issues] [JBoss JIRA] Created: (JBIDE-9525) PublishCopyUtil#copyFile throws an Exception but it's impl catches it and returns an IStatus instead
Andre Dietisheim (JIRA)
jira-events at lists.jboss.org
Thu Aug 11 07:16:25 EDT 2011
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
Affects Versions: 3.3.0.M3
Reporter: Andre Dietisheim
Assignee: Rob Stryker
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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jbosstools-issues
mailing list