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

matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new d505b71a9b JPDA Evaluator: Value, Description and Children should not 
be fetched on the EDT
     new 75d723505c Merge pull request #5877 from matthiasblaesing/jpda_edt
d505b71a9b is described below

commit d505b71a9bdfd56b38f061f775fda4f1c12b9488
Author: Matthias Bläsing <mblaes...@doppel-helix.eu>
AuthorDate: Mon Apr 24 21:15:53 2023 +0200

    JPDA Evaluator: Value, Description and Children should not be fetched on 
the EDT
    
    While running NetBeans with assertions enabled, while tryping to open
    the detail/value dialog for the "String value", an AssertionError was
    observed.
    
    java.lang.AssertionError: Debugger lock taken in AWT Event Queue!
      at 
org.netbeans.modules.debugger.jpda.JPDADebuggerImpl$DebuggerReentrantReadWriteLock$DebuggerReadLock.lock(JPDADebuggerImpl.java:2710)
      at 
org.netbeans.modules.debugger.jpda.models.JPDAThreadImpl$ThreadReentrantReadWriteLock$ThreadWriteLock.lock(JPDAThreadImpl.java:2581)
      at 
org.netbeans.modules.debugger.jpda.JPDADebuggerImpl.invokeMethod(JPDADebuggerImpl.java:1080)
      at 
org.netbeans.modules.debugger.jpda.JPDADebuggerImpl.invokeMethod(JPDADebuggerImpl.java:1022)
      at 
org.netbeans.modules.debugger.jpda.models.AbstractObjectVariable.getToStringValue(AbstractObjectVariable.java:500)
      at 
org.netbeans.modules.debugger.jpda.models.AbstractObjectVariable.getToStringValue(AbstractObjectVariable.java:464)
      at 
org.netbeans.modules.debugger.jpda.models.AbstractObjectVariable.getToStringValue(AbstractObjectVariable.java:428)
      at 
org.netbeans.modules.debugger.jpda.ui.models.VariablesTableModel.getValueAt(VariablesTableModel.java:108)
      at 
org.netbeans.spi.viewmodel.Models$DelegatingTableModel.getValueAt(Models.java:2249)
      at 
org.netbeans.modules.debugger.jpda.ui.models.NumericDisplayFilter.getValueAt(NumericDisplayFilter.java:112)
      at 
org.netbeans.spi.viewmodel.Models$CompoundTableModel.getValueAt(Models.java:1439)
      at 
org.netbeans.modules.debugger.jpda.ui.models.VariablesTreeModelFilter.getValueAt(VariablesTreeModelFilter.java:530)
      at 
org.netbeans.spi.viewmodel.Models$CompoundTableModel.getValueAt(Models.java:1439)
      at 
org.netbeans.modules.debugger.jpda.ui.models.EvaluatorTableModelFilter.getValueAt(EvaluatorTableModelFilter.java:71)
      at 
org.netbeans.spi.viewmodel.Models$CompoundTableModel.getValueAt(Models.java:1439)
      at 
org.netbeans.spi.viewmodel.Models$CompoundTableModel.getValueAt(Models.java:1441)
      at 
org.netbeans.spi.viewmodel.Models$CompoundTableModel.getValueAt(Models.java:1441)
      at 
org.netbeans.spi.viewmodel.Models$CompoundModel.getValueAt(Models.java:4565)
      at 
org.netbeans.modules.viewmodel.TreeModelNode$MyProperty.updateShortDescription(TreeModelNode.java:2094)
      at 
org.netbeans.modules.viewmodel.TreeModelNode$MyProperty.getShortDescription(TreeModelNode.java:2076)
      at 
org.openide.explorer.propertysheet.CustomEditorAction.actionPerformed(CustomEditorAction.java:290)
      at 
org.openide.explorer.propertysheet.PropertyPanel$CustomEditorProxyAction.actionPerformed(PropertyPanel.java:1199)
      at 
org.openide.explorer.view.OutlineView$OutlineViewOutline.editCellAt(OutlineView.java:2115)
      at 
java.desktop/javax.swing.plaf.basic.BasicTableUI$Handler.adjustSelection(BasicTableUI.java:1147)
      at 
java.desktop/javax.swing.plaf.basic.BasicTableUI$Handler.mousePressed(BasicTableUI.java:1077)
    
    Indeed here the call comes from the EDT and directly tries to access
    the JPDA connection.
    
    The fix is inspired from JPDAAsynchronousModel and moves value fetching
    from the EDT to the JPDA thread.
---
 .../jpda/ui/models/EvaluatorTableModelFilter.java  | 43 +++++++++++++++++++---
 1 file changed, 37 insertions(+), 6 deletions(-)

diff --git 
a/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/EvaluatorTableModelFilter.java
 
b/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/EvaluatorTableModelFilter.java
index 5dc216241d..c0932190ed 100644
--- 
a/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/EvaluatorTableModelFilter.java
+++ 
b/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/EvaluatorTableModelFilter.java
@@ -21,38 +21,55 @@ package org.netbeans.modules.debugger.jpda.ui.models;
 
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.List;
+import java.util.concurrent.Executor;
+import org.netbeans.api.debugger.jpda.JPDADebugger;
+import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
+import org.netbeans.spi.debugger.ContextProvider;
 import org.netbeans.spi.debugger.DebuggerServiceRegistration;
-import org.netbeans.spi.debugger.ui.CodeEvaluator;
 import org.netbeans.spi.debugger.ui.CodeEvaluator.Result.DefaultHistoryItem;
 import org.netbeans.spi.debugger.ui.Constants;
+import org.netbeans.spi.viewmodel.AsynchronousModelFilter;
 import org.netbeans.spi.viewmodel.ModelListener;
 import org.netbeans.spi.viewmodel.TableModel;
 import org.netbeans.spi.viewmodel.TableModelFilter;
 import org.netbeans.spi.viewmodel.UnknownTypeException;
 
+import static org.netbeans.spi.viewmodel.AsynchronousModelFilter.CALL.CHILDREN;
+import static 
org.netbeans.spi.viewmodel.AsynchronousModelFilter.CALL.DISPLAY_NAME;
+import static 
org.netbeans.spi.viewmodel.AsynchronousModelFilter.CALL.SHORT_DESCRIPTION;
+import static org.netbeans.spi.viewmodel.AsynchronousModelFilter.CALL.VALUE;
+import static 
org.netbeans.spi.viewmodel.AsynchronousModelFilter.CURRENT_THREAD;
+
 @DebuggerServiceRegistration(path="netbeans-JPDASession/ResultsView",
-                             types=TableModelFilter.class,
+                             types = { TableModelFilter.class, 
AsynchronousModelFilter.class },
                              position=330)
-public class EvaluatorTableModelFilter implements TableModelFilter {
+public class EvaluatorTableModelFilter implements TableModelFilter, 
AsynchronousModelFilter {
 
-    private final Collection<ModelListener> listeners = new 
HashSet<ModelListener>();
+    private final Executor rp;
+    private final Collection<ModelListener> listeners = new HashSet<>();
 
-    public EvaluatorTableModelFilter() {
+    public EvaluatorTableModelFilter(ContextProvider lookupProvider) {
+        JPDADebuggerImpl debugger = (JPDADebuggerImpl) lookupProvider.
+                lookupFirst(null, JPDADebugger.class);
+        rp = debugger.getRequestProcessor();
     }
 
+    @Override
     public void addModelListener(ModelListener l) {
         synchronized (listeners) {
             listeners.add (l);
         }
     }
 
+    @Override
     public void removeModelListener (ModelListener l) {
         synchronized (listeners) {
             listeners.remove (l);
         }
     }
 
+    @Override
+    @SuppressWarnings("ConvertToStringSwitch")
     public Object getValueAt(TableModel original, Object node, String 
columnID) throws UnknownTypeException {
         if (node instanceof DefaultHistoryItem) {
             DefaultHistoryItem item = (DefaultHistoryItem) node;
@@ -71,6 +88,7 @@ public class EvaluatorTableModelFilter implements 
TableModelFilter {
         return original.getValueAt(node, columnID);
     }
 
+    @Override
     public boolean isReadOnly(TableModel original, Object node, String 
columnID) throws UnknownTypeException {
         if (node instanceof DefaultHistoryItem || node instanceof 
EvaluatorTreeModel.HistoryNode) {
             return true;
@@ -78,6 +96,7 @@ public class EvaluatorTableModelFilter implements 
TableModelFilter {
         return original.isReadOnly(node, columnID);
     }
 
+    @Override
     public void setValueAt(TableModel original, Object node, String columnID, 
Object value) throws UnknownTypeException {
         if (node instanceof DefaultHistoryItem || node instanceof 
EvaluatorTreeModel.HistoryNode) {
             return;
@@ -85,4 +104,16 @@ public class EvaluatorTableModelFilter implements 
TableModelFilter {
         original.setValueAt(node, columnID, value);
     }
 
+    @Override
+    public Executor asynchronous(Executor exec, CALL asynchCall, Object 
object) {
+        switch (asynchCall) {
+            case VALUE:
+            case CHILDREN:
+            case SHORT_DESCRIPTION:
+                return rp;
+            case DISPLAY_NAME:
+                return CURRENT_THREAD;
+        }
+        return null; // ??
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to