Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3039)

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightingManager_NEW.java

Issue 885653005: Issue 22191. Grab the document lock before positionsLock to prevent deadlock. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightingManager_NEW.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightingManager_NEW.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightingManager_NEW.java
index 9a66fd1d0ca4a63294b7ece482b77aa6a58d9679..996da72e7768a12384b3dc3398d2353316738ed3 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightingManager_NEW.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightingManager_NEW.java
@@ -33,6 +33,7 @@ import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IPositionUpdater;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ISynchronizable;
import org.eclipse.jface.text.ITextPresentationListener;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.TextPresentation;
@@ -335,11 +336,26 @@ public class SemanticHighlightingManager_NEW implements AnalysisServerHighlights
HighlightRegion highlight = highlights[i];
newPositions[i] = new HighlightPosition(highlight);
}
- synchronized (positionsLock) {
- lastText = document.get();
- lastRegions = highlights;
- positions = newPositions;
+ synchronized (getDocumentLockObject()) {
Paul Berry 2015/01/28 18:30:22 It would be nice to have a comment here explaining
scheglov 2015/01/28 18:33:41 Done.
+ synchronized (positionsLock) {
+ lastText = document.get();
+ lastRegions = highlights;
+ positions = newPositions;
+ }
+ }
+ }
+
+ /**
+ * Returns the lock to use to synchronize {@link #document} access.
+ */
+ private Object getDocumentLockObject() {
+ if (document instanceof ISynchronizable) {
+ Object lock = ((ISynchronizable) document).getLockObject();
+ if (lock != null) {
+ return lock;
+ }
}
+ return document;
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698