minor refactoring
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Mon, 29 Feb 2016 16:54:00 +0000 (19:54 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Mon, 29 Feb 2016 18:01:52 +0000 (21:01 +0300)
java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java

index 05e7e380cb078197999b1f792da2969b02894413..e1fe0f99696787c87f4eb4ac04d2cbae8373ad7b 100644 (file)
@@ -135,7 +135,7 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy {
           candidates.removeAll(nested2);
         }
         
-        nestedTypes = candidates.isEmpty()? Collections.<ReferenceType>emptyList() : new ArrayList<>(candidates);
+        nestedTypes = candidates.isEmpty() ? Collections.emptyList() : new ArrayList<>(candidates);
       }
       else {
         nestedTypes = Collections.emptyList();
@@ -193,10 +193,7 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy {
 
   public void threadStarted(ThreadReference thread) {
     DebuggerManagerThreadImpl.assertIsManagerThread();
-    final Map<ThreadReference, ThreadReferenceProxyImpl> allThreads = myAllThreads;
-    if (!allThreads.containsKey(thread)) {
-      allThreads.put(thread, new ThreadReferenceProxyImpl(this, thread));
-    }
+    getThreadReferenceProxy(thread); // add a proxy
   }
 
   public void threadStopped(ThreadReference thread) {
@@ -576,13 +573,7 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy {
       return null;
     }
 
-    ThreadReferenceProxyImpl proxy = myAllThreads.get(thread);
-    if (proxy == null) {
-      proxy = new ThreadReferenceProxyImpl(this, thread);
-      myAllThreads.put(thread, proxy);
-    }
-
-    return proxy;
+    return myAllThreads.computeIfAbsent(thread, t -> new ThreadReferenceProxyImpl(this, t));
   }
 
   public ThreadGroupReferenceProxyImpl getThreadGroupReferenceProxy(ThreadGroupReference group) {