Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/findbugs-exclude.xml11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/PersistenceDelegateBinding.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractService.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractServiceManager.java34
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java138
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core.scripting/src/org/eclipse/tcf/te/tcf/core/scripting/launcher/ScriptLauncher.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core.scripting/src/org/eclipse/tcf/te/tcf/core/scripting/parser/Parser.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/concurrent/internal/DefaultProxyDescriptor.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/internal/Binding.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppPropertiesSection.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/MapPersistableURIProvider.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/ModelLocationUtil.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java22
17 files changed, 155 insertions, 142 deletions
diff --git a/admin/findbugs-exclude.xml b/admin/findbugs-exclude.xml
index 492eb40a8..db67cf6a4 100644
--- a/admin/findbugs-exclude.xml
+++ b/admin/findbugs-exclude.xml
@@ -37,6 +37,11 @@
<Bug pattern="REC_CATCH_EXCEPTION"/>
</Match>
+ <!-- Ignore all STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE -->
+ <Match>
+ <Bug pattern="STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE"/>
+ </Match>
+
<!-- Ignore all EQ_DOESNT_OVERRIDE_EQUALS -->
<Match>
<Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS"/>
@@ -53,6 +58,12 @@
</Or>
</Match>
+ <!-- Ignore all RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE in hasString(String) methods -->
+ <Match>
+ <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
+ <Method name="hasString" params="java.lang.String" returns="boolean"/>
+ </Match>
+
<!-- Ignore all EI_EXPOSE_REP violations for IAdapterFactory#getAdapterList() -->
<Match>
<Bug pattern="EI_EXPOSE_REP"/>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java
index 095d73e7b..85665f9cb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java
@@ -94,10 +94,14 @@ public abstract class AbstractGsonMapPersistenceDelegate extends ExecutableExten
file = path.addFileExtension(getDefaultFileExtension()).toFile();
}
- Writer writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); //$NON-NLS-1$
- Gson gson = new GsonBuilder().setPrettyPrinting().create();
- gson.toJson(toMap(context), Map.class, writer);
- writer.close();
+ Writer writer = null;
+ try {
+ writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); //$NON-NLS-1$
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ gson.toJson(toMap(context), Map.class, writer);
+ } finally {
+ if (writer != null) writer.close();
+ }
}
else if (container instanceof String || String.class.equals(container)) {
Gson gson = new GsonBuilder().create();
@@ -133,9 +137,13 @@ public abstract class AbstractGsonMapPersistenceDelegate extends ExecutableExten
throw new IOException("URI must denote an absolute file path."); //$NON-NLS-1$
}
- Reader reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$
- data = gson.fromJson(reader, Map.class);
- reader.close();
+ Reader reader = null;
+ try {
+ reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$
+ data = gson.fromJson(reader, Map.class);
+ } finally {
+ if (reader != null) reader.close();
+ }
}
else if (container instanceof String) {
data = gson.fromJson((String)container, Map.class);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/PersistenceDelegateBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/PersistenceDelegateBinding.java
index 20074ab07..9d3bfc863 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/PersistenceDelegateBinding.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/PersistenceDelegateBinding.java
@@ -34,7 +34,7 @@ public class PersistenceDelegateBinding extends ExecutableExtension {
// Initialize the delegate id field by reading the <delegate> extension attribute.
// Throws an exception if the id is empty or null.
delegateId = config != null ? config.getAttribute("delegateId") : null; //$NON-NLS-1$
- if (delegateId == null || (delegateId != null && "".equals(delegateId.trim()))) { //$NON-NLS-1$
+ if (delegateId == null || "".equals(delegateId.trim())) { //$NON-NLS-1$
throw createMissingMandatoryAttributeException("delegateId", config.getContributor().getName()); //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractService.java
index bc3ebfcb5..62ebf85b6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractService.java
@@ -30,7 +30,7 @@ public abstract class AbstractService extends PlatformObject implements IService
*/
@Override
public final void setId(String id) {
- if (id == null) this.id = id;
+ if (this.id == null) this.id = id;
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractServiceManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractServiceManager.java
index 546d82b1c..c0e459ed2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractServiceManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractServiceManager.java
@@ -73,7 +73,7 @@ public abstract class AbstractServiceManager {
// Initialize the id field by reading the <id> extension attribute.
// Throws an exception if the id is empty or null.
id = config.getAttribute("id"); //$NON-NLS-1$
- if (id == null || (id != null && "".equals(id.trim()))) { //$NON-NLS-1$
+ if (id == null || "".equals(id.trim())) { //$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR,
CoreBundleActivator.getUniqueIdentifier(),
NLS.bind(Messages.Extension_error_missingRequiredAttribute, "id", config.getContributor().getName()))); //$NON-NLS-1$
@@ -88,7 +88,7 @@ public abstract class AbstractServiceManager {
clazz = children[0].getAttribute("class"); //$NON-NLS-1$
}
}
- if (clazz == null || (clazz != null && "".equals(clazz.trim()))) { //$NON-NLS-1$
+ if (clazz == null || "".equals(clazz.trim())) { //$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR,
CoreBundleActivator.getUniqueIdentifier(),
NLS.bind(Messages.Extension_error_missingRequiredAttribute, "class", config.getContributor().getName()))); //$NON-NLS-1$
@@ -128,13 +128,11 @@ public abstract class AbstractServiceManager {
if (unique) {
return (IService)service;
}
- else if (service instanceof IService) {
- this.service = (IService)service;
- }
- else {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Service '" + service.getClass().getName() + "' not of type IService."); //$NON-NLS-1$ //$NON-NLS-2$
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
+ this.service = (IService)service;
+ }
+ else {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Service '" + service.getClass().getName() + "' not of type IService."); //$NON-NLS-1$ //$NON-NLS-2$
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
}
}
catch (CoreException e) {
@@ -259,14 +257,28 @@ public abstract class AbstractServiceManager {
return expression;
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof IService) {
+ return equals((IService)obj);
+ }
+ if (obj instanceof ServiceProxy) {
+ return equals((ServiceProxy)obj);
+ }
+ return super.equals(obj);
+ }
+
public boolean equals(IService service) {
Assert.isNotNull(service);
- return clazz.equals(service.getClass().getCanonicalName());
+ return clazz != null ? clazz.equals(service.getClass().getCanonicalName()) : false;
}
public boolean equals(ServiceProxy proxy) {
Assert.isNotNull(proxy);
- return clazz.equals(proxy.clazz);
+ return clazz != null ? clazz.equals(proxy.clazz) : false;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java
index 7c455cac7..58f1d2d1b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java
@@ -78,8 +78,7 @@ public class Stepper implements IStepper {
super();
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#getId()
*/
@Override
@@ -87,8 +86,7 @@ public class Stepper implements IStepper {
return getClass().getName();
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#getLabel()
*/
@Override
@@ -96,8 +94,7 @@ public class Stepper implements IStepper {
return getClass().getName();
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#getDescription()
*/
@Override
@@ -107,17 +104,16 @@ public class Stepper implements IStepper {
/**
* Returns the id of the step group to execute by the stepper.
- *
+ *
* @return The step group id.
*/
protected String getStepGroupId() {
- return getData() != null ? getData()
- .getStringProperty(IStepperProperties.PROP_STEP_GROUP_ID) : null;
+ return getData() != null ? getData().getStringProperty(IStepperProperties.PROP_STEP_GROUP_ID) : null;
}
/**
* Returns the step group for the given step group id.
- *
+ *
* @param The step group id. Must not be <code>null</code>:
* @return The step group or <code>null</code>.
*/
@@ -133,11 +129,11 @@ public class Stepper implements IStepper {
/**
* Creates a new instance of the step executor to use for executing a step.
- *
+ *
* @param step The step. Must not be <code>null</code>.
* @param secondaryId The secondary id or <code>null</code>.
* @param fullQualifiedStepId The fully qualified step id. Must not be <code>null</code>.
- *
+ *
* @return The step executor instance.
*/
protected IStepExecutor doCreateStepExecutor(IStep step, String secondaryId, IFullQualifiedId fullQualifiedStepId) {
@@ -146,13 +142,8 @@ public class Stepper implements IStepper {
return new StepExecutor();
}
- /*
- * (non-Javadoc)
- * @see
- * org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#initialize(org.eclipse.tcf.te.runtime
- * .interfaces.properties.IPropertiesContainer,
- * org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId,
- * org.eclipse.core.runtime.IProgressMonitor)
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#initialize(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public final void initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws IllegalStateException {
@@ -187,7 +178,7 @@ public class Stepper implements IStepper {
/**
* Hook for subclasses to overwrite if subclasses wants to initialize their own state.
- *
+ *
* @param data The data. Must not be <code>null</code>.
* @param fullQualifiedId The full qualified id of this stepper.
* @param monitor The progress monitor. Must not be <code>null</code>.
@@ -205,8 +196,7 @@ public class Stepper implements IStepper {
initialized = true;
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#isInitialized()
*/
@Override
@@ -216,7 +206,7 @@ public class Stepper implements IStepper {
/**
* Sets the cancelable state of the stepper.
- *
+ *
* @param cancelable <code>True</code> if the stepper shall be cancelable, <code>false</code> if
* not.
*/
@@ -226,7 +216,7 @@ public class Stepper implements IStepper {
/**
* Returns the cancelable state of the stepper.
- *
+ *
* @return <code>True</code> if the stepper is cancelable, <code>false</code> if not.
*/
protected final boolean isCancelable() {
@@ -235,7 +225,7 @@ public class Stepper implements IStepper {
/**
* Get the active context.
- *
+ *
* @return The active context or <code>null</code>.
*/
protected IStepContext getContext() {
@@ -244,7 +234,7 @@ public class Stepper implements IStepper {
/**
* Get the context id.
- *
+ *
* @return The context id or <code>null</code>.
*/
protected String getContextId() {
@@ -254,7 +244,7 @@ public class Stepper implements IStepper {
/**
* Returns the currently associated data. The method returns <code>null</code> if the stepper is
* not in initialized state.
- *
+ *
* @return The data or <code>null</code>
*/
protected final IPropertiesContainer getData() {
@@ -263,7 +253,7 @@ public class Stepper implements IStepper {
/**
* Returns the full qualified id for this stepper.
- *
+ *
* @return The full qualified stepper id.
*/
protected final IFullQualifiedId getFullQualifiedId() {
@@ -273,7 +263,7 @@ public class Stepper implements IStepper {
/**
* Returns the currently associated progress monitor. The method returns <code>null</code> if
* the stepper is not in initialized state.
- *
+ *
* @return The progress monitor or <code>null</code>
*/
protected final IProgressMonitor getMonitor() {
@@ -287,8 +277,7 @@ public class Stepper implements IStepper {
finished = true;
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#isFinished()
*/
@Override
@@ -296,8 +285,7 @@ public class Stepper implements IStepper {
return finished;
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#cleanup()
*/
@Override
@@ -316,8 +304,7 @@ public class Stepper implements IStepper {
initialized = false;
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
@@ -329,8 +316,7 @@ public class Stepper implements IStepper {
return buffer.toString();
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#execute()
*/
@Override
@@ -339,9 +325,7 @@ public class Stepper implements IStepper {
CoreBundleActivator.getTraceHandler().trace("Stepper#execute: *** ENTERED", //$NON-NLS-1$
0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
- CoreBundleActivator
- .getTraceHandler()
- .trace(" [" + ISharedConstants.TIME_FORMAT.format(new Date(startTime)) + "]" //$NON-NLS-1$ //$NON-NLS-2$
+ CoreBundleActivator.getTraceHandler().trace(" [" + ISharedConstants.TIME_FORMAT.format(new Date(startTime)) + "]" //$NON-NLS-1$ //$NON-NLS-2$
+ " ***", //$NON-NLS-1$
0, ITraceIds.PROFILE_STEPPING, IStatus.WARNING, this);
@@ -367,8 +351,8 @@ public class Stepper implements IStepper {
// Check if we need a multi status
if (statusContainer.size() > 1) {
- MultiStatus multiStatus = new MultiStatus(CoreBundleActivator.getUniqueIdentifier(), 0, NLS
- .bind(Messages.Stepper_multiStatus_finishedWithWarnings, getLabel()), null);
+ MultiStatus multiStatus = new MultiStatus(CoreBundleActivator.getUniqueIdentifier(), 0,
+ NLS.bind(Messages.Stepper_multiStatus_finishedWithWarnings, getLabel()), null);
for (IStatus subStatus : statusContainer) {
multiStatus.merge(subStatus);
}
@@ -388,8 +372,7 @@ public class Stepper implements IStepper {
long endTime = System.currentTimeMillis();
CoreBundleActivator.getTraceHandler().trace("Stepper#execute: *** DONE", //$NON-NLS-1$
0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
- CoreBundleActivator.getTraceHandler()
- .trace(" [" + ISharedConstants.TIME_FORMAT.format(new Date(endTime)) //$NON-NLS-1$
+ CoreBundleActivator.getTraceHandler().trace(" [" + ISharedConstants.TIME_FORMAT.format(new Date(endTime)) //$NON-NLS-1$
+ " , delay = " + (endTime - startTime) + " ms]" //$NON-NLS-1$ //$NON-NLS-2$
+ " ***", //$NON-NLS-1$
0, ITraceIds.PROFILE_STEPPING, IStatus.WARNING, this);
@@ -398,7 +381,7 @@ public class Stepper implements IStepper {
/**
* Executes a step or step group.
- *
+ *
* @param statusContainer The status container. Must not be <code>null</code>.
* @throws CoreException If the execution fails.
*/
@@ -410,8 +393,8 @@ public class Stepper implements IStepper {
// If no step group id is available, throw an exception
if (stepGroupId == null) {
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), NLS
- .bind(Messages.Stepper_error_missingStepGroupId, getLabel())));
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ NLS.bind(Messages.Stepper_error_missingStepGroupId, getLabel())));
}
// Get the step group
@@ -419,24 +402,22 @@ public class Stepper implements IStepper {
// If no step group could be found, throw an exception
if (stepGroup == null) {
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), NLS
- .bind(Messages.Stepper_error_missingStepGroup, stepGroupId)));
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ NLS.bind(Messages.Stepper_error_missingStepGroup, stepGroupId)));
}
// Initialize the progress monitor
getMonitor().beginTask(stepGroup.getLabel(), calculateTotalWork(stepGroup));
- IFullQualifiedId fullQualifiedId = getFullQualifiedId()
- .createChildId(ID_TYPE_CONTEXT_ID, getContextId(), null);
- fullQualifiedId = fullQualifiedId
- .createChildId(ID_TYPE_STEP_GROUP_ID, stepGroup.getId(), null);
+ IFullQualifiedId fullQualifiedId = getFullQualifiedId().createChildId(ID_TYPE_CONTEXT_ID, getContextId(), null);
+ fullQualifiedId = fullQualifiedId.createChildId(ID_TYPE_STEP_GROUP_ID, stepGroup.getId(), null);
// Execute the step group
executeStepGroup(stepGroup, statusContainer, new ArrayList<ExecutedContextStep>(), fullQualifiedId);
}
/**
* Executes a step group.
- *
+ *
* @param stepGroup The step group. Must not be <code>null</code>.
* @param statusContainer A list holding the warnings occurred during the execution. Must not be
* <code>null</code>.
@@ -444,7 +425,7 @@ public class Stepper implements IStepper {
* <code>null</code>.
* @param fullQualifiedGroupId The hierarchy of all parent step group id's separated by "::".
* Must not be <code>null</code>.
- *
+ *
* @throws CoreException If the execution fails.
*/
private void executeStepGroup(IStepGroup stepGroup, List<IStatus> statusContainer, List<ExecutedContextStep> executedSteps, IFullQualifiedId fullQualifiedGroupId) throws CoreException {
@@ -474,13 +455,11 @@ public class Stepper implements IStepper {
if (iterator != null) {
iterator.initialize(getContext(), getData(), fullQualifiedGroupId, getMonitor());
}
- boolean next = iterator == null || iterator
- .hasNext(getContext(), getData(), fullQualifiedGroupId, getMonitor());
+ boolean next = iterator == null || iterator.hasNext(getContext(), getData(), fullQualifiedGroupId, getMonitor());
while (next) {
if (iterator != null) {
- fullQualifiedIterationId = fullQualifiedGroupId
- .createChildId(ID_TYPE_STEP_GROUP_ITERATION_ID, iterator.getId(), "" + iteration); //$NON-NLS-1$
+ fullQualifiedIterationId = fullQualifiedGroupId.createChildId(ID_TYPE_STEP_GROUP_ITERATION_ID, iterator.getId(), "" + iteration); //$NON-NLS-1$
iterator.next(getContext(), getData(), fullQualifiedIterationId, getMonitor());
}
// Execute the steps or step groups.
@@ -488,14 +467,13 @@ public class Stepper implements IStepper {
executeGroupable(groupable, statusContainer, executedSteps, fullQualifiedIterationId);
}
iteration++;
- next = iterator != null && iterator
- .hasNext(getContext(), getData(), fullQualifiedGroupId, getMonitor());
+ next = iterator != null && iterator.hasNext(getContext(), getData(), fullQualifiedGroupId, getMonitor());
}
}
/**
* Executes a step groupable. The groupable might encapsulate a step or a step group.
- *
+ *
* @param step The step groupable. Must not be <code>null</code>.
* @param statusContainer A list holding the warnings occurred during the execution. Must not be
* <code>null</code>.
@@ -503,7 +481,7 @@ public class Stepper implements IStepper {
* <code>null</code>.
* @param fullQualifiedParentId The hierarchy of all parent step group id's separated by "::".
* Must not be <code>null</code>.
- *
+ *
* @throws CoreException If the execution failed.
*/
private void executeGroupable(IStepGroupable groupable, List<IStatus> statusContainer, List<ExecutedContextStep> executedSteps, IFullQualifiedId fullQualifiedParentId) throws CoreException {
@@ -520,9 +498,7 @@ public class Stepper implements IStepper {
// If the passed in groupable is disabled -> we are done immediately
if (groupable.isDisabled()) {
- CoreBundleActivator
- .getTraceHandler()
- .trace("Stepper#executeGroupable: DROPPED DISABLED groupable: id = '" + groupable.getExtension().getId() + "'" //$NON-NLS-1$ //$NON-NLS-2$
+ CoreBundleActivator.getTraceHandler().trace("Stepper#executeGroupable: DROPPED DISABLED groupable: id = '" + groupable.getExtension().getId() + "'" //$NON-NLS-1$ //$NON-NLS-2$
+ ", secondaryId = '" + groupable.getSecondaryId() + "'", //$NON-NLS-1$ //$NON-NLS-2$
0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
return;
@@ -532,9 +508,7 @@ public class Stepper implements IStepper {
checkForDependenciesExecuted(groupable, executedSteps);
if (groupable.getExtension() instanceof IStepGroup) {
- IFullQualifiedId id = fullQualifiedParentId
- .createChildId(ID_TYPE_STEP_GROUP_ID, groupable.getExtension().getId(), groupable
- .getSecondaryId());
+ IFullQualifiedId id = fullQualifiedParentId.createChildId(ID_TYPE_STEP_GROUP_ID, groupable.getExtension().getId(), groupable.getSecondaryId());
// If the passed in groupable is associated with a step group
// -> get the groupable from that group and execute them
executeStepGroup((IStepGroup) groupable.getExtension(), statusContainer, executedSteps, id);
@@ -545,9 +519,7 @@ public class Stepper implements IStepper {
// create a step executor and invoke the executor.
IStep step = (IStep) groupable.getExtension();
- IFullQualifiedId id = fullQualifiedParentId
- .createChildId(ID_TYPE_STEP_ID, step.getId(), groupable
- .getSecondaryId());
+ IFullQualifiedId id = fullQualifiedParentId.createChildId(ID_TYPE_STEP_ID, step.getId(), groupable.getSecondaryId());
// Create the step executor now
IStepExecutor executor = doCreateStepExecutor(step, groupable.getSecondaryId(), id);
@@ -581,11 +553,11 @@ public class Stepper implements IStepper {
/**
* Checks if all required dependencies have been executed before. If not, the method will throw
* an error status.
- *
+ *
* @param groupable The groupable. Must not be <code>null</code>.
* @param executedSteps A list holding the id's of the steps executed before. Must not be
* <code>null</code>.
- *
+ *
* @throws CoreException If a dependency has not been executed before.
*/
protected void checkForDependenciesExecuted(IStepGroupable groupable, List<ExecutedContextStep> executedSteps) throws CoreException {
@@ -616,11 +588,11 @@ public class Stepper implements IStepper {
}
if (!requiredStepExecuted) {
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), MessageFormat
- .format(Messages.Stepper_error_requiredStepNotExecuted, NLS.bind(groupable
- .getExtension() instanceof IStep ? Messages.Stepper_error_step : Messages.Stepper_error_step, groupable
- .getExtension().getId()), NLS
- .bind(Messages.Stepper_error_requiredStepOrGroup, dependency), ""))); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ MessageFormat.format(Messages.Stepper_error_requiredStepNotExecuted,
+ NLS.bind(groupable.getExtension() instanceof IStep ? Messages.Stepper_error_step : Messages.Stepper_error_stepGroup,
+ groupable.getExtension().getId()),
+ NLS.bind(Messages.Stepper_error_requiredStepOrGroup, dependency), ""))); //$NON-NLS-1$
}
// Recursive checking is not necessary here as the step or step group
@@ -634,7 +606,7 @@ public class Stepper implements IStepper {
* Rollback the steps previously executed to the failed step. The rollback is executed in
* reverse order and the step must be of type {@link IExtendedStep} to participate in the
* rollback.
- *
+ *
* @param executedSteps
* @param progress
*/
@@ -673,10 +645,10 @@ public class Stepper implements IStepper {
* Calculates the total work required for the step group. The total work is the sum of the total
* work of each sub step. If one of the steps returns {@link IProgressMonitor#UNKNOWN}, the
* total work will be unknown for the whole step group.
- *
+ *
* @param stepGroup The step group. Must not be <code>null</code>.
* @return The total work required or {@link IProgressMonitor#UNKNOWN}.
- *
+ *
* @throws CoreException If the total work of the step group cannot be determined.
*/
protected int calculateTotalWork(IStepGroup stepGroup) throws CoreException {
@@ -721,7 +693,7 @@ public class Stepper implements IStepper {
* <p>
* If the associated status contains a CANCEL status object, the passed in exception and the
* associated status objects are returned unmodified.
- *
+ *
* @param e The core exception. Must not be <code>null</code>.
* @param statusContainer The list of non-severe status objects. Must not be <code>null</code>.
* @return The exception to re-throw or <code>null</code>.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core.scripting/src/org/eclipse/tcf/te/tcf/core/scripting/launcher/ScriptLauncher.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core.scripting/src/org/eclipse/tcf/te/tcf/core/scripting/launcher/ScriptLauncher.java
index a16b2ad43..3cbde1f2d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core.scripting/src/org/eclipse/tcf/te/tcf/core/scripting/launcher/ScriptLauncher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core.scripting/src/org/eclipse/tcf/te/tcf/core/scripting/launcher/ScriptLauncher.java
@@ -139,7 +139,9 @@ public class ScriptLauncher extends PlatformObject implements IScriptLauncher {
*/
@Override
public void onChannelClosed(Throwable error) {
- if (traceListener != null) { ((AbstractChannel)ScriptLauncher.this.channel).removeTraceListener(traceListener); traceListener = null; }
+ if (traceListener != null && ScriptLauncher.this.channel != null) {
+ ((AbstractChannel)ScriptLauncher.this.channel).removeTraceListener(traceListener); traceListener = null;
+ }
if (error != null) {
IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
NLS.bind(Messages.ScriptLauncher_error_channelConnectFailed, peer.getID(), error.getLocalizedMessage()),
@@ -320,7 +322,7 @@ public class ScriptLauncher extends PlatformObject implements IScriptLauncher {
Token token = tokens[index];
- IService service = channel.getRemoteService(token.getServiceName());
+ IService service = channel != null ? channel.getRemoteService(token.getServiceName()) : null;
if (service != null) {
new Command(channel, service, token.getCommandName(), token.getArguments()) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core.scripting/src/org/eclipse/tcf/te/tcf/core/scripting/parser/Parser.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core.scripting/src/org/eclipse/tcf/te/tcf/core/scripting/parser/Parser.java
index 8d26de463..a3ab90eea 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core.scripting/src/org/eclipse/tcf/te/tcf/core/scripting/parser/Parser.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core.scripting/src/org/eclipse/tcf/te/tcf/core/scripting/parser/Parser.java
@@ -113,18 +113,19 @@ public class Parser {
if (tok.startsWith("\"")) { //$NON-NLS-1$
// String type
- String fullTok = tok;
- boolean complete = isComplete(fullTok, '"', '"');
+ StringBuilder fullTok = new StringBuilder(tok);
+ boolean complete = isComplete(fullTok.toString(), '"', '"');
while (!complete && tokenizer.hasMoreTokens()) {
- fullTok = fullTok + " " + tokenizer.nextToken(); //$NON-NLS-1$
- complete = isComplete(fullTok, '"', '"');
+ fullTok.append(" "); //$NON-NLS-1$
+ fullTok.append(tokenizer.nextToken());
+ complete = isComplete(fullTok.toString(), '"', '"');
}
if (complete) {
- fullTok = fullTok.trim();
- if (fullTok.startsWith("\"")) fullTok = fullTok.substring(1); //$NON-NLS-1$
- if (fullTok.endsWith("\"")) fullTok = fullTok.substring(0, fullTok.length() - 1); //$NON-NLS-1$
- token.addArgument(fullTok);
+ String fullTokStr = fullTok.toString().trim();
+ if (fullTokStr.startsWith("\"")) fullTokStr = fullTokStr.substring(1); //$NON-NLS-1$
+ if (fullTokStr.endsWith("\"")) fullTokStr = fullTokStr.substring(0, fullTok.length() - 1); //$NON-NLS-1$
+ token.addArgument(fullTokStr);
continue;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/concurrent/internal/DefaultProxyDescriptor.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/concurrent/internal/DefaultProxyDescriptor.java
index 6e1cbd3db..72895d6eb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/concurrent/internal/DefaultProxyDescriptor.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/concurrent/internal/DefaultProxyDescriptor.java
@@ -26,7 +26,7 @@ import org.eclipse.tcf.te.tcf.core.concurrent.interfaces.IProxyDescriptor;
*/
public class DefaultProxyDescriptor implements IProxyDescriptor {
// Descriptor cache to store known proxy descriptors.
- private static Map<Class<?>, IProxyDescriptor> descriptorCache;
+ private volatile static Map<Class<?>, IProxyDescriptor> descriptorCache;
/**
* Get a default proxy descriptor from the cache using the class as the key.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java
index 6ee29740c..9e218919b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java
@@ -902,7 +902,6 @@ public final class ChannelManager extends PlatformObject implements IChannelMana
return;
} else if (channel != null) {
// Channel is not in open state -> drop the instance
- channel = null;
channels.remove(id);
refCounters.remove(id);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/internal/Binding.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/internal/Binding.java
index 8fbf2746e..02399e228 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/internal/Binding.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/internal/Binding.java
@@ -34,7 +34,7 @@ public class Binding extends ExecutableExtension {
// Initialize the value-add id field by reading the <valueadd> extension attribute.
// Throws an exception if the id is empty or null.
valueAddId = config != null ? config.getAttribute("valueAddId") : null; //$NON-NLS-1$
- if (valueAddId == null || (valueAddId != null && "".equals(valueAddId.trim()))) { //$NON-NLS-1$
+ if (valueAddId == null || "".equals(valueAddId.trim())) { //$NON-NLS-1$
throw createMissingMandatoryAttributeException("valueAddId", config.getContributor().getName()); //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java
index b4c0c66e6..c4d796d8d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java
@@ -221,14 +221,19 @@ public class RemoteAppLaunchManagerDelegate extends DefaultLaunchManagerDelegate
public void validate(String launchMode, ILaunchConfiguration launchConfig) throws LaunchServiceException {
super.validate(launchMode, launchConfig);
- String missingAttributes = null;
+ StringBuilder missingAttributes = new StringBuilder();
for (String attribute : MANDATORY_CONFIG_ATTRIBUTES) {
if (!isValidAttribute(attribute, launchConfig, launchMode)) {
- missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$
+ if (missingAttributes.length() == 0) {
+ missingAttributes.append(attribute);
+ } else {
+ missingAttributes.append(", "); //$NON-NLS-1$
+ missingAttributes.append(attribute);
+ }
}
}
- if (missingAttributes != null) {
- throw new LaunchServiceException("Missing launch configuration attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR); //$NON-NLS-1$
+ if (missingAttributes.length() > 0) {
+ throw new LaunchServiceException("Missing launch configuration attributes: " + '\n' + missingAttributes.toString(), LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR); //$NON-NLS-1$
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppPropertiesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppPropertiesSection.java
index 3c44f078c..e200e8854 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppPropertiesSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppPropertiesSection.java
@@ -68,8 +68,8 @@ public class RemoteAppPropertiesSection extends BaseTitledSection {
*/
@Override
public void refresh() {
- processImage.setText(new Path(processImageValue).toPortableString());
- processArgs.setText(processArgsValue);
+ if (processImage != null) processImage.setText(new Path(processImageValue).toPortableString());
+ if (processArgs != null) processArgs.setText(processArgsValue);
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java
index d813e2526..f3f1337a6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java
@@ -297,7 +297,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
// Set the peer state property, if the scanner the runnable
// has been scheduled from is still active.
- if (parentScanner == null || parentScanner != null && !parentScanner.isTerminated()) {
+ if (parentScanner == null || !parentScanner.isTerminated()) {
// Turn off change notifications temporarily
boolean changed = peerNode.setChangeEventsEnabled(false);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/MapPersistableURIProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/MapPersistableURIProvider.java
index eb76c24ea..7eff5a6c3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/MapPersistableURIProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/MapPersistableURIProvider.java
@@ -74,20 +74,18 @@ public class MapPersistableURIProvider implements IPersistableURIProvider {
// Try the bundles state location first (not available if launched with -data @none).
try {
IPath path = CoreBundleActivator.getDefault().getStateLocation().append(".peers"); //$NON-NLS-1$
- if (!path.toFile().exists()) {
- path.toFile().mkdirs();
- }
- if (path.toFile().canRead() && path.toFile().isDirectory()) {
+ boolean exists = path.toFile().exists();
+ if (!exists) exists = path.toFile().mkdirs();
+ if (exists && path.toFile().canRead() && path.toFile().isDirectory()) {
location = path;
}
} catch (IllegalStateException e) {
// Workspace less environments (-data @none)
// The users local peers lookup directory is $HOME/.tcf/.peers.
IPath path = new Path(System.getProperty("user.home")).append(".tcf/.peers"); //$NON-NLS-1$ //$NON-NLS-2$
- if (!path.toFile().exists()) {
- path.toFile().mkdirs();
- }
- if (path.toFile().canRead() && path.toFile().isDirectory()) {
+ boolean exists = path.toFile().exists();
+ if (!exists) exists = path.toFile().mkdirs();
+ if (exists && path.toFile().canRead() && path.toFile().isDirectory()) {
location = path;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/ModelLocationUtil.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/ModelLocationUtil.java
index a486504b9..797510f5b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/ModelLocationUtil.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/ModelLocationUtil.java
@@ -28,8 +28,9 @@ public final class ModelLocationUtil {
public static IPath getStaticPeersRootLocation() {
try {
File file = CoreBundleActivator.getDefault().getStateLocation().append(".peers").toFile(); //$NON-NLS-1$
- if (!file.exists()) file.mkdirs();
- if (file.canRead() && file.isDirectory()) {
+ boolean exists = file.exists();
+ if (!exists) exists = file.mkdirs();
+ if (exists && file.canRead() && file.isDirectory()) {
return new Path(file.toString());
}
} catch (IllegalStateException e) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
index 5da4cfa6a..83437c938 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
@@ -367,17 +367,21 @@ public final class LogManager implements IProtocolStateChangeListener {
// We have to rotate the full cycle, first in cycle to be removed.
int no = 1;
File fileInCycle = path.append(logName + "_" + no + ".log").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
- fileInCycle.delete();
-
- while (no <= maxInCycle) {
- no++;
- fileInCycle = path.append(logName + "_" + no + ".log").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
- File renameTo = path.append(logName + "_" + (no - 1) + ".log").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
- fileInCycle.renameTo(renameTo);
+ boolean rc = fileInCycle.delete();
+ if (rc) {
+ while (no <= maxInCycle) {
+ no++;
+ fileInCycle = path.append(logName + "_" + no + ".log").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
+ File renameTo = path.append(logName + "_" + (no - 1) + ".log").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
+ rc = fileInCycle.renameTo(renameTo);
+ if (!rc) break;
+ }
+
+ // Rename the log file if the rotate succeeded,
+ // Delete the log file if not.
+ rc = rc ? file.renameTo(maxFileInCycle) : file.delete();
}
- // Rename the log file
- file.renameTo(maxFileInCycle);
} else {
// Not at the limit, find the next file name in the cycle
int no = 1;

Back to the top