You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2020/07/20 03:43:41 UTC

[servicecomb-pack] 01/01: SCB-2044 Fixed the Environment class instance thread issue

This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch SCB-2044
in repository https://gitbox.apache.org/repos/asf/servicecomb-pack.git

commit f91ed8d2fc5b7cf464c2f0260f3d0393fb91b623
Author: Willem Jiang <wi...@gmail.com>
AuthorDate: Mon Jul 20 11:38:06 2020 +0800

    SCB-2044 Fixed the Environment class instance thread issue
---
 .../java/org/apache/servicecomb/pack/common/Environment.java  | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/pack-common/src/main/java/org/apache/servicecomb/pack/common/Environment.java b/pack-common/src/main/java/org/apache/servicecomb/pack/common/Environment.java
index 691aafb..94b94f1 100644
--- a/pack-common/src/main/java/org/apache/servicecomb/pack/common/Environment.java
+++ b/pack-common/src/main/java/org/apache/servicecomb/pack/common/Environment.java
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
 
 public class Environment {
   private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-  private static Environment instance;
+  private static Environment instance = new Environment();
   private static final int PAYLOADS_MAX_LENGTH = 10240;
   private int payloadsMaxLength = 0;
 
@@ -46,17 +46,10 @@ public class Environment {
   }
 
   public static Environment getInstance(){
-    if (instance == null) {
-      synchronized (Environment.class) {
-        if (instance == null) {
-          instance = new Environment();
-        }
-      }
-    }
     return instance;
   }
 
   public int getPayloadsMaxLength() {
     return this.payloadsMaxLength;
   }
-}
\ No newline at end of file
+}