Author: rob.stryker(a)jboss.com
Date: 2010-04-20 23:26:29 -0400 (Tue, 20 Apr 2010)
New Revision: 21567
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Messages.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Messages.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
Log:
JBIDE-5857 - changes exception handling on I/O errors during publishing to fail
immediately if a renameTo fails (so that it does not fail repeatedly on the next 10,000
files and make the publish look frozen)
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Messages.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Messages.java 2010-04-21
03:22:35 UTC (rev 21566)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Messages.java 2010-04-21
03:26:29 UTC (rev 21567)
@@ -82,6 +82,7 @@
public static String JMXResumeScannerError;
public static String JMXScannerCanceled;
public static String CannotSaveServersStartArgs;
+ public static String PublishRenameFailure;
static {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Messages.properties
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Messages.properties 2010-04-21
03:22:35 UTC (rev 21566)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Messages.properties 2010-04-21
03:26:29 UTC (rev 21567)
@@ -43,6 +43,7 @@
FullPublishFail=Full publish failed for module {0}
IncrementalPublishFail=Incremental publish failed for module {0}
+PublishRenameFailure=Error renaming {0} to {1}
DeleteModuleFail=Unable to delete module {0}
DeleteModuleFail2=Some files were not removed from the server
CountModifiedMembers={0} files modified in module {1}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java 2010-04-21
03:22:35 UTC (rev 21566)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java 2010-04-21
03:26:29 UTC (rev 21567)
@@ -68,12 +68,18 @@
if( deltaKind != ServerBehaviourDelegate.REMOVED)
deltas = behaviour.getPublishedResourceDelta(module);
if( publisher != null ) {
- IStatus result = publisher.publishModule(
- this,
- behaviour.getServer(), module,
- publishType, deltas, monitor);
- if( result != null )
- ServerLogger.getDefault().log(behaviour.getServer(), result);
+ try {
+ IStatus result = publisher.publishModule(
+ this,
+ behaviour.getServer(), module,
+ publishType, deltas, monitor);
+ if( result != null )
+ ServerLogger.getDefault().log(behaviour.getServer(), result);
+ } catch( CoreException ce) {
+ // Let the user know
+ ServerLogger.getDefault().log(behaviour.getServer(), ce.getStatus());
+ throw ce;
+ }
return publisher.getPublishState();
}
return IServer.PUBLISH_STATE_INCREMENTAL;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java 2010-04-21
03:22:35 UTC (rev 21566)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java 2010-04-21
03:26:29 UTC (rev 21567)
@@ -127,7 +127,7 @@
public String getDefaultRunVMArgs() {
IConstants c = new IConstants(){};
String name = getRuntime().getName();
- String ret = c.SYSPROP + c.PROGRAM_NAME_ARG + c.EQ + c.QUOTE +
+ String ret = c.QUOTE + c.SYSPROP + c.PROGRAM_NAME_ARG + c.EQ +
"JBossTools: " + name + c.QUOTE + c.SPACE; //$NON-NLS-1$
if( Platform.getOS().equals(Platform.OS_MACOSX))
ret += c.SERVER_ARG + c.SPACE;
@@ -145,7 +145,7 @@
ret += c.SYSPROP + c.JAVA_PREFER_IP4_ARG + c.EQ + true + c.SPACE;
ret += c.SYSPROP + c.SUN_CLIENT_GC_ARG + c.EQ + 3600000 + c.SPACE;
ret += c.SYSPROP + c.SUN_SERVER_GC_ARG + c.EQ + 3600000 + c.SPACE;
- ret += c.SYSPROP + c.ENDORSED_DIRS + c.EQ + c.QUOTE +
+ ret += c.QUOTE + c.SYSPROP + c.ENDORSED_DIRS + c.EQ +
(getRuntime().getLocation().append(c.LIB).append(c.ENDORSED)) + c.QUOTE + c.SPACE;
if( getRuntime().getLocation().append(c.BIN).append(c.NATIVE).toFile().exists() )
ret += c.SYSPROP + c.JAVA_LIB_PATH + c.EQ + c.QUOTE +
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2010-04-21
03:22:35 UTC (rev 21566)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2010-04-21
03:26:29 UTC (rev 21567)
@@ -20,7 +20,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -199,7 +198,7 @@
if (ts != IResource.NULL_STAMP && ts != 0)
file.setLastModified(ts);
} catch (CoreException e) {
- return e.getStatus();
+ throw e;
} catch (Exception e) {
IPath path = mf.getModuleRelativePath().append(mf.getName());
return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
NLS.bind(Messages.errorCopyingFile, path.toOSString(), e.getLocalizedMessage()), null);
@@ -256,7 +255,9 @@
}
}
if (!safeRename(tempFile, file, 10))
- throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
NLS.bind(Messages.errorRename, tempFile.toString()), null));
+ throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
+ NLS.bind(org.jboss.ide.eclipse.as.core.Messages.PublishRenameFailure,
+ tempFile.toString(), file.getAbsolutePath()), null));
}
/**
@@ -268,15 +269,16 @@
* @return <code>true</code> if it succeeds, <code>false</code>
otherwise
*/
private boolean safeRename(File from, File to, int retrys) {
+ boolean renamedSafely = false;
// make sure parent dir exists
File dir = to.getParentFile();
if (dir != null && !dir.exists())
dir.mkdirs();
int count = 0;
- while (count < retrys) {
+ while (count < retrys && !renamedSafely) {
if (from.renameTo(to))
- return true;
+ renamedSafely = true;
count++;
// delay if we are going to try again
@@ -288,7 +290,7 @@
}
}
}
- return false;
+ return renamedSafely;
}
protected File getTempFolder() {
@@ -457,19 +459,15 @@
if (resource instanceof IModuleFile) {
IModuleFile file = (IModuleFile) resource;
- try {
- if (kind2 == IModuleResourceDelta.REMOVED) {
- IPath path2 = path.append(file.getModuleRelativePath()).append(file.getName());
- handler.deleteResource(path2, monitor);
- }
- else {
- IPath path2 = path.append(file.getModuleRelativePath()).append(file.getName());
- handler.makeDirectoryIfRequired(path2.removeLastSegments(1), monitor);
- handler.copyFile(file, path2, monitor);
- }
- } catch (CoreException ce) {
- status.add(ce.getStatus());
+ if (kind2 == IModuleResourceDelta.REMOVED) {
+ IPath path2 = path.append(file.getModuleRelativePath()).append(file.getName());
+ handler.deleteResource(path2, monitor);
}
+ else {
+ IPath path2 = path.append(file.getModuleRelativePath()).append(file.getName());
+ handler.makeDirectoryIfRequired(path2.removeLastSegments(1), monitor);
+ handler.copyFile(file, path2, monitor);
+ }
IStatus[] stat = new IStatus[status.size()];
status.toArray(stat);
return stat;
@@ -551,11 +549,7 @@
if( stats.length > 0 && !stats[0].isOK())
addArrayToList(status, stats);
- try {
- addArrayToList(status, handler.copyFile(mf, path, monitor));
- } catch (CoreException ce) {
- status.add(ce.getStatus());
- }
+ addArrayToList(status, handler.copyFile(mf, path, monitor));
}
IStatus[] stat = new IStatus[status.size()];
status.toArray(stat);