src/share/classes/com/sun/corba/se/spi/orb/ORB.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -168,10 +168,16 @@
     // wrapperMap maintains a table of LogWrapper instances used by
     // different classes to log exceptions.  The key is a StringPair
     // representing LogDomain and ExceptionGroup.
     private Map wrapperMap ;
 
+    static class Holder {
+        static final PresentationManager defaultPresentationManager =
+            setupPresentationManager();
+    }
+    private static final Object pmLock = new Object();
+
     private static Map staticWrapperMap = new ConcurrentHashMap();
 
     protected MonitoringManager monitoringManager;
 
     private static PresentationManager setupPresentationManager() {

@@ -233,19 +239,30 @@
      * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific
      * AppContext to hold it. Creates and records one if needed.
      */
     public static PresentationManager getPresentationManager()
     {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null && AppContext.getAppContexts().size() > 0) {
         AppContext ac = AppContext.getAppContext();
-        PresentationManager pm = (PresentationManager) ac.get(PresentationManager.class);
+            if (ac != null) {
+                synchronized (pmLock) {
+                    PresentationManager pm = 
+                        (PresentationManager) ac.get(PresentationManager.class);
         if (pm == null) {
             pm = setupPresentationManager();
             ac.put(PresentationManager.class, pm);
         }
         return pm;
     }
+            }
+        }
 
+        // No security manager or AppContext
+        return Holder.defaultPresentationManager;
+    }
+
     /** Get the appropriate StubFactoryFactory.  This
      * will be dynamic or static depending on whether
      * com.sun.CORBA.ORBUseDynamicStub is true or false.
      */
     public static PresentationManager.StubFactoryFactory