diff options
author | John Ross | 2013-11-13 17:08:03 +0000 |
---|---|---|
committer | John Ross | 2013-11-13 19:23:32 +0000 |
commit | 5bdaa4451d78c0dab69157169c53ee3ab40996c7 (patch) | |
tree | d31304767aba25705a97fc641de50f1af7bfd9d8 | |
parent | 8402ed44617f584caa868d297a6466ba98750891 (diff) | |
download | rt.equinox.bundles-5bdaa4451d78c0dab69157169c53ee3ab40996c7.tar.gz rt.equinox.bundles-5bdaa4451d78c0dab69157169c53ee3ab40996c7.tar.xz rt.equinox.bundles-5bdaa4451d78c0dab69157169c53ee3ab40996c7.zip |
Bug 421487 - Provide more information in messages.I20131119-0800
4 files changed, 49 insertions, 45 deletions
diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java index 6b1e58e25..1a241b9ef 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java +++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java @@ -103,7 +103,7 @@ public class CoordinationImpl { // any thread, and there's nothing to compare. If the coordination // is using this thread, then we can't block due to risk of deadlock. if (t == Thread.currentThread()) { - throw new CoordinationException(Messages.Deadlock, referent, CoordinationException.DEADLOCK_DETECTED); + throw new CoordinationException(NLS.bind(Messages.Deadlock, new Object[]{participant, getName(), getId()}), referent, CoordinationException.DEADLOCK_DETECTED); } } } @@ -115,10 +115,11 @@ public class CoordinationImpl { try { coordination.join(1000); } catch (InterruptedException e) { - coordinator.getLogService().log(LogService.LOG_DEBUG, Messages.LockInterrupted, e); + String message = NLS.bind(Messages.LockInterrupted, new Object[]{participant, name, id, coordination.getName(), coordination.getId()}); + coordinator.getLogService().log(LogService.LOG_DEBUG, message, e); // This thread was interrupted while waiting for the coordination // to terminate. - throw new CoordinationException(Messages.LockInterrupted, referent, CoordinationException.LOCK_INTERRUPTED, e); + throw new CoordinationException(message, referent, CoordinationException.LOCK_INTERRUPTED, e); } } } @@ -133,7 +134,7 @@ public class CoordinationImpl { // Coordinations may only be ended by the same thread that // pushed them onto the stack, if any. if (thread != Thread.currentThread()) { - throw new CoordinationException(Messages.EndingThreadNotSame, referent, CoordinationException.WRONG_THREAD); + throw new CoordinationException(NLS.bind(Messages.EndingThreadNotSame, new Object[]{name, id, thread, Thread.currentThread()}), referent, CoordinationException.WRONG_THREAD); } // Unwind the stack in case there are other coordinations higher // up than this one. See bug 421487 for why peek() may be null. @@ -154,6 +155,7 @@ public class CoordinationImpl { // Notify participants this coordination has ended. Track whether or // not a partial ending has occurred. Exception exception = null; + Participant exceptionParticipant = null; // No additional synchronization is needed here because the participant // list will not be modified post termination. List<Participant> participantsToNotify = new ArrayList<Participant>(this.participants); @@ -162,10 +164,12 @@ public class CoordinationImpl { try { participant.ended(referent); } catch (Exception e) { - coordinator.getLogService().log(LogService.LOG_WARNING, Messages.ParticipantEndedError, e); + coordinator.getLogService().log(LogService.LOG_WARNING, NLS.bind(Messages.ParticipantEndedError, new Object[]{participant, name, id}), e); // Only the first exception will be propagated. - if (exception == null) + if (exception == null) { exception = e; + exceptionParticipant = participant; + } } } synchronized (this) { @@ -174,7 +178,7 @@ public class CoordinationImpl { } // If a partial ending has occurred, throw the required exception. if (exception != null) { - throw new CoordinationException(Messages.CoordinationPartiallyEnded, referent, CoordinationException.PARTIALLY_ENDED, exception); + throw new CoordinationException(NLS.bind(Messages.CoordinationPartiallyEnded, new Object[]{name, id, exceptionParticipant}), referent, CoordinationException.PARTIALLY_ENDED, exception); } } @@ -230,7 +234,7 @@ public class CoordinationImpl { checkTerminated(); } catch (InterruptedException e) { - throw new CoordinationException(Messages.InterruptedTimeoutExtension, referent, CoordinationException.UNKNOWN, e); + throw new CoordinationException(NLS.bind(Messages.InterruptedTimeoutExtension, new Object[]{totalTimeout, getName(), getId(), timeInMillis}), referent, CoordinationException.UNKNOWN, e); } } // Create the new timeout. @@ -248,7 +252,7 @@ public class CoordinationImpl { coordinator.checkPermission(CoordinationPermission.PARTICIPATE, name); // The reason must not be null. if (reason == null) - throw new NullPointerException(Messages.MissingFailureCause); + throw new NullPointerException(NLS.bind(Messages.MissingFailureCause, getName(), getId())); // Terminating the coordination must be atomic. synchronized (this) { // If this coordination is terminated, return false. Do not throw a @@ -269,7 +273,7 @@ public class CoordinationImpl { try { participant.failed(referent); } catch (Exception e) { - coordinator.getLogService().log(LogService.LOG_WARNING, Messages.ParticipantFailedError, e); + coordinator.getLogService().log(LogService.LOG_WARNING, NLS.bind(Messages.ParticipantFailedError, new Object[]{participant, name, id}), e); } } synchronized (this) { @@ -390,11 +394,11 @@ public class CoordinationImpl { // must be thrown. if (failure != null) { // The fail() method was called indicating the coordination failed. - throw new CoordinationException(Messages.CoordinationFailed, referent, CoordinationException.FAILED, failure); + throw new CoordinationException(NLS.bind(Messages.CoordinationFailed, name, id), referent, CoordinationException.FAILED, failure); } // The coordination did not fail, so it either partially ended or // ended successfully. - throw new CoordinationException(Messages.CoordinationEnded, referent, CoordinationException.ALREADY_ENDED); + throw new CoordinationException(NLS.bind(Messages.CoordinationEnded, name, id), referent, CoordinationException.ALREADY_ENDED); } private void terminate() throws CoordinationException { @@ -425,11 +429,11 @@ public class CoordinationImpl { } } if (!valid) - throw new IllegalArgumentException(Messages.InvalidCoordinationName); + throw new IllegalArgumentException(NLS.bind(Messages.InvalidCoordinationName, name)); } private static void validateTimeout(long timeout) { if (timeout < 0) - throw new IllegalArgumentException(Messages.InvalidTimeInterval); + throw new IllegalArgumentException(NLS.bind(Messages.InvalidTimeInterval, timeout)); } } diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationTimerTask.java b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationTimerTask.java index b65321e4b..215bde5a6 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationTimerTask.java +++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationTimerTask.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2011 IBM Corporation and others. + * Copyright (c) 2010, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,7 +32,7 @@ public class CoordinationTimerTask extends TimerTask { try { coordination.fail(Coordination.TIMEOUT); } catch (Throwable t) { - coordination.getLogService().log(LogService.LOG_ERROR, Messages.CoordinationTimedOutError, t); + coordination.getLogService().log(LogService.LOG_ERROR, NLS.bind(Messages.CoordinationTimedOutError, new Object[]{coordination.getName(), coordination.getId(), Thread.currentThread()}), t); } } } diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinatorImpl.java b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinatorImpl.java index 1f2b5a6d5..37c9a796d 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinatorImpl.java +++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinatorImpl.java @@ -38,7 +38,7 @@ public class CoordinatorImpl implements Coordinator { private synchronized static long getNextId() { if (Long.MAX_VALUE == lastId) - throw new IllegalStateException(Messages.MaxCoordinationIdExceeded); + throw new IllegalStateException(NLS.bind(Messages.MaxCoordinationIdExceeded, lastId)); // First ID will be 1. return ++lastId; } @@ -82,7 +82,7 @@ public class CoordinatorImpl implements Coordinator { public void push(CoordinationImpl c) { if (contains(c)) - throw new CoordinationException(Messages.CoordinationAlreadyExists, c.getReferent(), CoordinationException.ALREADY_PUSHED); + throw new CoordinationException(NLS.bind(Messages.CoordinationAlreadyExists, new Object[]{c.getName(), c.getId(), Thread.currentThread()}), c.getReferent(), CoordinationException.ALREADY_PUSHED); c.setThreadAndEnclosingCoordination(Thread.currentThread(), coordinations.isEmpty() ? null : coordinations.getFirst()); coordinations.addFirst(c); } @@ -102,7 +102,7 @@ public class CoordinatorImpl implements Coordinator { this.timer = timer; coordinations = new ArrayList<CoordinationImpl>(); if (maxTimeout < 0) - throw new IllegalArgumentException(Messages.InvalidTimeInterval); + throw new IllegalArgumentException(NLS.bind(Messages.InvalidTimeInterval, maxTimeout)); this.maxTimeout = maxTimeout; } @@ -128,7 +128,7 @@ public class CoordinatorImpl implements Coordinator { // Override the requested timeout with the max timeout, if necessary. if (maxTimeout != 0) { if (timeout == 0 || maxTimeout < timeout) { - logService.log(LogService.LOG_WARNING, NLS.bind(Messages.MaximumTimeout, timeout, maxTimeout)); + logService.log(LogService.LOG_WARNING, NLS.bind(Messages.MaximumTimeout, new Object[]{timeout, maxTimeout, name})); timeout = maxTimeout; } } @@ -145,7 +145,7 @@ public class CoordinatorImpl implements Coordinator { coordination.reference = new CoordinationWeakReference(referent, coordination); synchronized (this) { if (shutdown) - throw new IllegalStateException(Messages.CoordinatorShutdown); + throw new IllegalStateException(NLS.bind(Messages.CoordinatorShutdown, name, timeout)); synchronized (CoordinatorImpl.class) { coordinations.add(coordination); idToCoordination.put(new Long(coordination.getId()), coordination); @@ -179,7 +179,7 @@ public class CoordinatorImpl implements Coordinator { try { checkPermission(CoordinationPermission.ADMIN, result.getName()); } catch (SecurityException e) { - logService.log(LogService.LOG_DEBUG, Messages.GetCoordinationNotPermitted, e); + logService.log(LogService.LOG_DEBUG, NLS.bind(Messages.GetCoordinationNotPermitted, new Object[]{Thread.currentThread(), result.getName(), result.getId()}), e); result = null; } } @@ -200,7 +200,7 @@ public class CoordinatorImpl implements Coordinator { checkPermission(CoordinationPermission.ADMIN, coordination.getName()); result.add(coordination.getReferent()); } catch (SecurityException e) { - logService.log(LogService.LOG_DEBUG, Messages.GetCoordinationNotPermitted, e); + logService.log(LogService.LOG_DEBUG, NLS.bind(Messages.GetCoordinationNotPermitted, new Object[]{Thread.currentThread(), coordination.getName(), coordination.getId()}), e); } } } diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/messages.properties b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/messages.properties index 75aafd831..13fdcf844 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/messages.properties +++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/messages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2010, 2011 IBM Corporation. +# Copyright (c) 2010, 2013 IBM Corporation. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -8,24 +8,24 @@ # Contributors: # IBM Corporation - initial API and implementation ############################################################################### -NullParameter=Parameter must not be null: {0} -Deadlock=Deadlock detected -InvalidCoordinationName=The coordination name does not match the Bundle Symbolic Name pattern -MissingFailureCause=A reason must be specified when failing a coordination -InvalidTimeInterval=A time interval must be a non-negative integer -InterruptedTimeoutExtension=The timeout could not be extended because the previous one had already expired. The current thread was interrupted before it was possible to determine how this coordination terminated. -EndingThreadNotSame=Coordinations may only be ended by the same thread that pushed them onto the thread local stack -LockInterrupted=The lock was interrupted -ParticipantEndedError=A participant indicated an error occurred while the coordination was ending -CoordinationPartiallyEnded=Partially ended -ParticipantFailedError=A participant indicated an error occurred while the coordination was failing -CoordinationFailed=Coordination has failed -CoordinationEnded=Coordination has already ended -CoordinationTimedOutError=An unexpected exception occurred while failing a coordination. This will not stop the timer thread. -MaxCoordinationIdExceeded=The next coordination ID would exceed the maximum possible value -GetCoordinationNotPermitted=A requester did not have permission to view a coordination -CoordinatorShutdown=This coordinator has been shutdown -CoordinationAlreadyExists=Coordination already exists -CanceledTaskNotPurged=Unable to purge the canceled task -OrphanedCoordinationError=An error occurred while processing orphaned coordination {0} with ID {1}. -MaximumTimeout=A maximum timeout for coordinations has been set. The requested timeout of {0} will become {1}. +NullParameter=Parameter must not be null: "{0}". +Deadlock=Adding participant "{0}" to coordination "{1}" with ID "{2}" would result in a deadlock. +InvalidCoordinationName=Coordination name "{0}" does not match the syntax of a bundle symbolic name. +MissingFailureCause=A reason must be specified in order to fail coordination "{0}" with ID "{1}". +InvalidTimeInterval=Time interval "{0}" is not a non-negative integer. +InterruptedTimeoutExtension=The timeout "{0}" of coordination "{1}" with ID "{2}" could not be extended by "{3}" because it had already expired. The current thread was interrupted before it was possible to determine how the coordination terminated. +EndingThreadNotSame=Coordination "{0}" with ID "{1}" may only be ended by the same thread "{2}" that pushed it onto the thread local stack. Thread "{3}" attempted to end it. +LockInterrupted=Participant "{0}" could not be immediately added to coordination "{1}" with ID "{2}" because it was already participating in coordination "{3}" with ID "{4}", and an interruption occurred while waiting for the other coordination to end. +ParticipantEndedError=Participant "{0}" indicated an error occurred while coordination "{1}" with ID "{2}" was ending. +CoordinationPartiallyEnded=Coordination "{0}" with ID "{1}" is partially ending because at least one participant indicated an error occurred. The first participant to do so was "{2}". +ParticipantFailedError=Participant "{0}" indicated an error occurred while coordination "{1}" with ID "{2}" was failing. +CoordinationFailed=Coordination "{0}" with ID "{1}" has failed. +CoordinationEnded=Coordination "{0}" with ID "{1}" has already ended. +CoordinationTimedOutError=An unexpected error occurred while failing coordination "{0}" with ID "{1}" because it had timed out. This will not stop timer thread "{2}". +MaxCoordinationIdExceeded=The next coordination ID would exceed the maximum possible value. The last ID was "{0}". +GetCoordinationNotPermitted=A requester on thread "{0}" did not have permission to view coordination "{1}" with ID "{2}". +CoordinatorShutdown=Coordination "{0}" with timeout "{1}" could not be created because the coordinator has been shutdown. +CoordinationAlreadyExists=Coordination "{0}" with ID "{1}" already exists on the stack of thread "{2}". +CanceledTaskNotPurged=Unable to purge the canceled task. +OrphanedCoordinationError=An error occurred while processing orphaned coordination "{0}" with ID "{1}". +MaximumTimeout=A maximum timeout for coordinations has been set. The requested timeout of "{0}" will become "{1}" for coordination "{2}". |