Skip to content

Commit abaea23

Browse files
author
rcartwright
committed
This revision is yet another chapter in the continued refactoring of
the synchronization protocol for the interactions pane. Some intermittent unit testing failures on Windows promppted me to rexamine the code for upating the caret. I realized that the documentation mutation forcing the caret update needs to be performed in the event thread (not jut the caret update portion of the operation), to make the document revision + caret updating into a single atomic operation. After I made this change, I discovered that the caret was being advanced double the distance that my code explicitly directed. When I tracked down the reason, I was humbled because the AbstractDocument framework already includes code that moves the cursor when text is inserted in front fo it. The cursor is bound to a Position, not an offset. This caret update was invisible/garbled in earlier editions of the code because the corresponding document update was not properly synchronized (it must execute in the event thread because the caret position determines the meaning of other asynchronous events (e.g. keyboard input) being handled by the event thread. This commit also attempts to address some other problems that showed up during extensive Windows testing. Since the tests perform many operations outside the event thread that are performed in the event thread in normal DrJav execution, additional synchronization is required between these operations and subsequent operations that inspect their effects. In particular, Utilities.clearEventQueue() has to be inserted after such operations to make sure that event thread tasks spawned by the externally executed operations complete before other operation query their effects. In some cases, mutliple consecutive calls to Utilities.clearEventQueue may be required because a spawned event thread task can spawn its own even thread tasks (using SwingUtilities.invokeLater). In Windows testing, here is still an intermittent problem with what I believe is JVM bug 6612928. The bug spews repeated instances of java.util.concurrent.RejectedExecutionException during JVM shutdown. Since the problem occurs during shutdown after testing has finished JUnit does not classify the exceptions as test failures but prints the tracebacks, which are nearly useless because they do not reach back to DrJava code. The following files were modified: M testFiles/drjava.basic.config M src/edu/rice/cs/drjava/DrJavaTestCase.java M src/edu/rice/cs/drjava/DrJava.java M src/edu/rice/cs/drjava/model/GlobalModelIOTest.java M src/edu/rice/cs/drjava/model/GlobalModelTestCase.java M src/edu/rice/cs/drjava/model/DefaultGlobalModel.java M src/edu/rice/cs/drjava/model/definitions/indent/Indenter.java M src/edu/rice/cs/drjava/model/definitions/indent/IndentRulesTestCase.java M src/edu/rice/cs/drjava/model/definitions/ColoringGlyphPainter.java M src/edu/rice/cs/drjava/model/definitions/IndentHelperTest.java M src/edu/rice/cs/drjava/model/repl/InteractionsScriptModel.java M src/edu/rice/cs/drjava/model/repl/InteractionsDJDocumentTest.java M src/edu/rice/cs/drjava/model/repl/InteractionsModelTest.java M src/edu/rice/cs/drjava/model/repl/InteractionsModel.java M src/edu/rice/cs/drjava/model/repl/newjvm/MainJVM.java M src/edu/rice/cs/drjava/model/repl/RMIInteractionsModel.java M src/edu/rice/cs/drjava/model/repl/SimpleInteractionsModel.java M src/edu/rice/cs/drjava/model/AbstractGlobalModel.java M src/edu/rice/cs/drjava/config/Configuration.java M src/edu/rice/cs/drjava/config/FileConfiguration.java M src/edu/rice/cs/drjava/config/ConfigOptionListeners.java M src/edu/rice/cs/drjava/config/OptionMapLoader.java M src/edu/rice/cs/drjava/ui/InteractionsPane.java M src/edu/rice/cs/drjava/ui/KeyBindingManager.java M src/edu/rice/cs/drjava/ui/NewVersionPopup.java M src/edu/rice/cs/drjava/ui/config/LabelComponent.java M src/edu/rice/cs/drjava/ui/config/IntegerOptionComponent.java M src/edu/rice/cs/drjava/ui/config/IntegerOptionComponentTest.java M src/edu/rice/cs/drjava/ui/config/VectorOptionComponent.java M src/edu/rice/cs/drjava/ui/config/VectorFileOptionComponentTest.java M src/edu/rice/cs/drjava/ui/config/ToolbarOptionComponent.java M src/edu/rice/cs/drjava/ui/config/ConfigFrame.java M src/edu/rice/cs/drjava/ui/config/DirectoryOptionComponent.java M src/edu/rice/cs/drjava/ui/config/StringOptionComponent.java M src/edu/rice/cs/drjava/ui/config/FontOptionComponent.java M src/edu/rice/cs/drjava/ui/config/FontOptionComponentTest.java M src/edu/rice/cs/drjava/ui/config/ConfigPanel.java M src/edu/rice/cs/drjava/ui/config/ForcedChoiceOptionComponentTest.java M src/edu/rice/cs/drjava/ui/config/ForcedChoiceOptionComponent.java M src/edu/rice/cs/drjava/ui/config/ColorOptionComponentTest.java M src/edu/rice/cs/drjava/ui/config/ColorOptionComponent.java M src/edu/rice/cs/drjava/ui/config/FileOptionComponentTest.java M src/edu/rice/cs/drjava/ui/config/FileOptionComponent.java M src/edu/rice/cs/drjava/ui/config/BooleanOptionComponentTest.java M src/edu/rice/cs/drjava/ui/config/BooleanOptionComponent.java M src/edu/rice/cs/drjava/ui/config/OptionComponent.java M src/edu/rice/cs/drjava/ui/config/KeyStrokeOptionComponent.java M src/edu/rice/cs/drjava/ui/config/KeyStrokeOptionComponentTest.java M src/edu/rice/cs/drjava/ui/config/ButtonComponent.java M src/edu/rice/cs/drjava/ui/AbstractDJPane.java M src/edu/rice/cs/drjava/ui/ProjectMenuTest.java M src/edu/rice/cs/drjava/ui/InteractionsPaneTest.java M src/edu/rice/cs/drjava/ui/InteractionsScriptController.java M src/edu/rice/cs/drjava/ui/InteractionsController.java M src/edu/rice/cs/util/text/ConsoleDocument.java M src/edu/rice/cs/util/swing/FileSelectorComponent.java git-svn-id: file:///tmp/test-svn/trunk@4498 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent e753017 commit abaea23

File tree

56 files changed

+1667
-1734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1667
-1734
lines changed

drjava/src/edu/rice/cs/drjava/DrJava.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static void displayUsage() {
378378
* accidentally used.
379379
*/
380380
static void setPropertiesFile(String fileName) {
381-
if (!fileName.endsWith(".java")) _propertiesFile = new File(fileName);
381+
if (! fileName.endsWith(".java")) _propertiesFile = new File(fileName);
382382
}
383383

384384
/** Initializes the configuration object with the current notion of the properties file.
@@ -457,5 +457,14 @@ protected static void _saveConfig() {
457457
//
458458
// int result = JOptionPane.showConfirmDialog(null, text, "Locate 'tools.jar'?", JOptionPane.YES_NO_OPTION);
459459
// return result == JOptionPane.YES_OPTION;
460-
// }
460+
// }
461+
462+
/* Erase all non-final bindings created in this class. Only used in testing. */
463+
public static void cleanUp() {
464+
_propertiesFile = null;
465+
_filesToOpen.clear();
466+
_jvmArgs.clear();
467+
_config = null;
468+
}
469+
461470
}

drjava/src/edu/rice/cs/drjava/DrJavaTestCase.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,25 @@ public class DrJavaTestCase extends TestCase {
5959
* @throws Exception
6060
*/
6161
protected void setUp() throws Exception {
62-
super.setUp();
62+
super.setUp(); // declared to throw Exception, forcing throws clause on preceding line
6363
Utilities.TEST_MODE = true;
6464
final String newName = System.getProperty(TEST_DRJAVA_CONFIG_PROPERTY);
65+
assert newName != null;
6566
if (newName != null) {
67+
// Utilities.show("Setting '" + newName + "' as DrJava configuration file");
6668
DrJava.setPropertiesFile(newName);
69+
Utilities.clearEventQueue();
6770
DrJava._initConfig();
71+
Utilities.clearEventQueue();
6872
}
6973
}
7074

71-
/** Clean up for every test case.
75+
/** Clean up for every test case. Only used in unit tests. Added because Windows would intermittently throw
76+
* a java.util.concurrent.RejectedExecutionException during cleanup.
7277
* @throws Exception
7378
*/
74-
protected void tearDown() throws Exception { super.tearDown(); }
79+
protected void tearDown() throws Exception {
80+
DrJava.cleanUp(); // clobbers _config
81+
super.tearDown();
82+
}
7583
}

0 commit comments

Comments
 (0)