You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by jw...@apache.org on 2015/08/28 18:24:16 UTC
svn commit: r1698363 -
/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
Author: jwross
Date: Fri Aug 28 16:24:16 2015
New Revision: 1698363
URL: http://svn.apache.org/r1698363
Log:
ARIES-1356 getInstance method on the core Activator shows up on jvisualvm sampling during performance analysis
Make instance field volatile.
Merge the checkInstance and getInstance methods.
Remove synchronization from the getInstance method.
Remove entry/exit tracing.
Modified:
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java?rev=1698363&r1=1698362&r2=1698363&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java (original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java Fri Aug 28 16:24:16 2015
@@ -50,20 +50,12 @@ public class Activator implements Bundle
public static final String LOG_ENTRY = "Method entry: {}, args {}";
public static final String LOG_EXIT = "Method exit: {}, returning {}";
- private static Activator instance;
-
- public static synchronized Activator getInstance() {
- logger.debug(LOG_ENTRY, "getInstance");
- checkInstance();
- logger.debug(LOG_EXIT, "getInstance", instance);
- return instance;
- }
-
- private static synchronized void checkInstance() {
- logger.debug(LOG_ENTRY, "checkInstance");
- if (instance == null)
- throw new IllegalStateException("The activator has not been initialized or has been shutdown");
- logger.debug(LOG_EXIT, "checkInstance");
+ private static volatile Activator instance;
+ public static Activator getInstance() {
+ Activator result = instance;
+ if (result == null)
+ throw new IllegalStateException("The activator has not been initialized or has been shutdown");
+ return result;
}
// @GuardedBy("this")