You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/02/19 07:27:10 UTC

[GitHub] JaroslavTulach closed pull request #423: Deadlock in lexing

JaroslavTulach closed pull request #423: Deadlock in lexing
URL: https://github.com/apache/incubator-netbeans/pull/423
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/javadoc/src/org/netbeans/modules/javadoc/highlighting/Highlighting.java b/javadoc/src/org/netbeans/modules/javadoc/highlighting/Highlighting.java
index 684e55911..2f1cfb9aa 100644
--- a/javadoc/src/org/netbeans/modules/javadoc/highlighting/Highlighting.java
+++ b/javadoc/src/org/netbeans/modules/javadoc/highlighting/Highlighting.java
@@ -26,6 +26,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.NoSuchElementException;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.swing.text.AttributeSet;
@@ -61,7 +62,7 @@
     
     private final Document document;
     private TokenHierarchy<? extends Document> hierarchy = null;
-    private long version = 0;
+    private final AtomicLong version = new AtomicLong();
     
     /** Creates a new instance of Highlighting */
     public Highlighting(Document doc) {
@@ -94,7 +95,7 @@ public Highlighting(Document doc) {
     public HighlightsSequence getHighlights(int startOffset, int endOffset) {
         synchronized(this) {
             if (hierarchy.isActive()) {
-                return new HSImpl(version, hierarchy, startOffset, endOffset);
+                return new HSImpl(version.get(), hierarchy, startOffset, endOffset);
             } else {
                 return HighlightsSequence.EMPTY;
             }
@@ -132,10 +133,7 @@ public void tokenHierarchyChanged(TokenHierarchyEvent evt) {
         }
         
         if (affectedArea != null) {
-            synchronized (this) {
-                version++;
-            }
-
+            version.incrementAndGet();
             fireHighlightsChange(affectedArea[0], affectedArea[1]);
         }
     }
@@ -308,7 +306,7 @@ public AttributeSet getAttributes() {
         }
         
         private void checkVersion() {
-            if (this.version != Highlighting.this.version) {
+            if (this.version != Highlighting.this.version.get()) {
                 throw new ConcurrentModificationException();
             }
         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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