[hg] main-silver: #236095: Reduce the code, which is executed un...

  • From:
  • To:
  • Subject: [hg] main-silver: #236095: Reduce the code, which is executed un...
  • Date: Thu, 19 Sep 2013 05:31:16 -0700

changeset cfc7e8141046 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/cfc7e8141046
description:
        #236095: Reduce the code, which is executed under synchronized block.

diffstat:

 
debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/LineTranslations.java
 |  20 +++++++--
 1 files changed, 15 insertions(+), 5 deletions(-)

diffs (38 lines):

diff --git 
a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/LineTranslations.java
 
b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/LineTranslations.java
--- 
a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/LineTranslations.java
+++ 
b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/LineTranslations.java
@@ -425,19 +425,29 @@
             }
         }
         
-        public synchronized void attach() throws IOException {
-            LineCookie lc = dataObject.getLookup().lookup (LineCookie.class);
+        public void attach() throws IOException {
+            DataObject dobj;
+            synchronized (this) {
+                dobj = this.dataObject;
+            }
+            LineCookie lc = dobj.getLookup().lookup (LineCookie.class);
             if (lc == null) {
                 return ;
             }
             lb.addPropertyChangeListener(this);
             try {
-                this.line = lc.getLineSet().getCurrent(lb.getLineNumber() - 
1);
-                line.addPropertyChangeListener(this);
+                final Line lineNew = 
lc.getLineSet().getCurrent(lb.getLineNumber() - 1);
+                synchronized (this) {
+                    if (line != null) {
+                        line.removePropertyChangeListener(this);
+                    }
+                    this.line = lineNew;
+                }
+                lineNew.addPropertyChangeListener(this);
                 StyledDocument document = NbDocument.getDocument(new 
Lookup.Provider() {
                                               @Override
                                               public Lookup getLookup() {
-                                                  return line.getLookup();
+                                                  return lineNew.getLookup();
                                               }
                                           });
                 if (document instanceof BaseDocument) {

[hg] main-silver: #236095: Reduce the code, which is executed un...

mentlicher 09/19/2013

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close