changeset 39826:5dba95a26226

8162563: Fix double checked locking in System.console() Reviewed-by: rriggs, sherman
author martin
date Tue, 26 Jul 2016 15:41:40 -0700
parents 6441823cea46
children 21a9b8df49f5
files jdk/src/java.base/share/classes/java/lang/System.java
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/share/classes/java/lang/System.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/System.java	Tue Jul 26 15:41:40 2016 -0700
@@ -236,10 +236,12 @@
      * @since   1.6
      */
      public static Console console() {
-         Console c = cons;
-         if (c == null) {
+         Console c;
+         if ((c = cons) == null) {
              synchronized (System.class) {
-                 cons = c = SharedSecrets.getJavaIOAccess().console();
+                 if ((c = cons) == null) {
+                     cons = c = SharedSecrets.getJavaIOAccess().console();
+                 }
              }
          }
          return c;