utility method for enabling/disabling collection phpstorm/142.3120 webstorm/142.3121
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Thu, 9 Jul 2015 11:47:58 +0000 (14:47 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Thu, 9 Jul 2015 11:50:40 +0000 (14:50 +0300)
java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java
java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java

index 3215d726ad365edf5b36ceb7008b570501067d98..3bbc65d8305ebbd8c07b4a5fe07052168043b320 100644 (file)
@@ -1087,7 +1087,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
                 // ensure args are not collected
                 for (Object arg : myArgs) {
                   if (arg instanceof ObjectReference) {
-                    ((ObjectReference)arg).disableCollection();
+                    DebuggerUtilsEx.disableCollection((ObjectReference)arg);
                   }
                 }
               }
@@ -1108,7 +1108,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
                 // ensure args are not collected
                 for (Object arg : myArgs) {
                   if (arg instanceof ObjectReference) {
-                    ((ObjectReference)arg).enableCollection();
+                    DebuggerUtilsEx.enableCollection((ObjectReference)arg);
                   }
                 }
               }
index dedf307ddb50fba7ff711098f92c9acabbac9793..952df87609275328f8803101d68dd9ee1000b00a 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.debugger.DebuggerBundle;
 import com.intellij.debugger.engine.evaluation.EvaluateException;
 import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
 import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
+import com.intellij.debugger.impl.DebuggerUtilsEx;
 import com.intellij.debugger.jdi.StackFrameProxyImpl;
 import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
 import com.intellij.openapi.diagnostic.Logger;
@@ -83,12 +84,7 @@ public abstract class SuspendContextImpl extends XSuspendContext implements Susp
     try {
       if (!Patches.IBM_JDK_DISABLE_COLLECTION_BUG) {
         for (ObjectReference objectReference : myKeptReferences) {
-          try {
-            objectReference.enableCollection();
-          }
-          catch (UnsupportedOperationException ignored) {
-            // ignore: some J2ME implementations does not provide this operation
-          }
+          DebuggerUtilsEx.enableCollection(objectReference);
         }
         myKeptReferences.clear();
       }
@@ -204,12 +200,7 @@ public abstract class SuspendContextImpl extends XSuspendContext implements Susp
     if (!Patches.IBM_JDK_DISABLE_COLLECTION_BUG) {
       final boolean added = myKeptReferences.add(reference);
       if (added) {
-        try {
-          reference.disableCollection();
-        }
-        catch (UnsupportedOperationException ignored) {
-          // ignore: some J2ME implementations does not provide this operation
-        }
+        DebuggerUtilsEx.disableCollection(reference);
       }
     }
   }
index d190ca1d672f55694c3691f62cbc7d116c49356c..87bf1bcbef9269085ff46075ae6d7a21ea79977d 100644 (file)
@@ -886,4 +886,21 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
     }
   };
 
+  public static void disableCollection(ObjectReference reference) {
+    try {
+      reference.disableCollection();
+    }
+    catch (UnsupportedOperationException ignored) {
+      // ignore: some J2ME implementations does not provide this operation
+    }
+  }
+
+  public static void enableCollection(ObjectReference reference) {
+    try {
+      reference.enableCollection();
+    }
+    catch (UnsupportedOperationException ignored) {
+      // ignore: some J2ME implementations does not provide this operation
+    }
+  }
 }