You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2024/09/06 17:10:43 UTC
(groovy) branch GROOVY_4_0_X updated (2ffb44549d -> ab3bc99c7b)
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a change to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
discard 2ffb44549d Use Thread subclass instead of Closure in Console(closes #2084)
new ab3bc99c7b Use Thread subclass instead of Closure in Console(closes #2084)
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (2ffb44549d)
\
N -- N -- N refs/heads/GROOVY_4_0_X (ab3bc99c7b)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
(groovy) 01/01: Use Thread subclass instead of Closure in Console(closes #2084)
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit ab3bc99c7b663fba284403b768b2e7179a298439
Author: Paolo Di Tommaso <pa...@gmail.com>
AuthorDate: Sat Sep 7 01:09:48 2024 +0800
Use Thread subclass instead of Closure in Console(closes #2084)
---
.../main/groovy/groovy/console/ui/Console.groovy | 90 +++++++++++-----------
1 file changed, 47 insertions(+), 43 deletions(-)
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
index c78aac38e0..bfd65c36ec 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
@@ -1363,55 +1363,59 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener, Fo
// Kick off a new thread to do the evaluation
// Run in a thread outside of EDT, this method is usually called inside the EDT
- runThread = Thread.start {
- try {
- systemOutInterceptor.setConsoleId(this.getConsoleId())
- // TODO should systemErrorInterceptor receive the console id, too?
- SwingUtilities.invokeLater { showExecutingMessage() }
- if (beforeExecution) {
- beforeExecution()
- }
- Tuple2<Object, Long> resultAndElapsedTime
- if (useScriptClassLoaderForScriptExecution) {
- ClassLoader savedThreadContextClassLoader = Thread.currentThread().contextClassLoader
- try {
- Thread.currentThread().contextClassLoader = shell.classLoader
+ runThread = new Thread() {
+ @Override
+ void run() {
+ try {
+ systemOutInterceptor.setConsoleId(this.getConsoleId())
+ // TODO should systemErrorInterceptor receive the console id, too?
+ SwingUtilities.invokeLater { showExecutingMessage() }
+ if (beforeExecution) {
+ beforeExecution()
+ }
+ Tuple2<Object, Long> resultAndElapsedTime
+ if (useScriptClassLoaderForScriptExecution) {
+ ClassLoader savedThreadContextClassLoader = Thread.currentThread().contextClassLoader
+ try {
+ Thread.currentThread().contextClassLoader = shell.classLoader
+ resultAndElapsedTime = doRun(selected, st, record)
+ }
+ finally {
+ Thread.currentThread().contextClassLoader = savedThreadContextClassLoader
+ }
+ } else {
resultAndElapsedTime = doRun(selected, st, record)
}
- finally {
- Thread.currentThread().contextClassLoader = savedThreadContextClassLoader
+ if (afterExecution) {
+ afterExecution()
+ }
+ SwingUtilities.invokeLater { finishNormal(resultAndElapsedTime.v1, resultAndElapsedTime.v2) }
+ } catch (Throwable t) {
+ if (t instanceof StackOverflowError) {
+ // set the flag that will be used in printing exception details in output pane
+ stackOverFlowError = true
+ clearOutput()
+ }
+ SwingUtilities.invokeLater { finishException(t, true) }
+ } finally {
+ runThread = null
+ scriptRunning = false
+ interruptAction.enabled = false
+ systemOutInterceptor.removeConsoleId()
+ if (loopMode) {
+ int delay = prefs.getInt('loopModeDelay', ConsolePreferences.DEFAULT_LOOP_MODE_DELAY_MILLIS)
+ Timer timer = new Timer(delay, {
+ if (inputAreaContentHash == inputArea.getText().hashCode()) {
+ runScriptImpl(selected, st)
+ }
+ })
+ timer.repeats = false
+ timer.start()
}
- } else {
- resultAndElapsedTime = doRun(selected, st, record)
- }
- if (afterExecution) {
- afterExecution()
- }
- SwingUtilities.invokeLater { finishNormal(resultAndElapsedTime.v1, resultAndElapsedTime.v2) }
- } catch (Throwable t) {
- if (t instanceof StackOverflowError) {
- // set the flag that will be used in printing exception details in output pane
- stackOverFlowError = true
- clearOutput()
- }
- SwingUtilities.invokeLater { finishException(t, true) }
- } finally {
- runThread = null
- scriptRunning = false
- interruptAction.enabled = false
- systemOutInterceptor.removeConsoleId()
- if( loopMode ) {
- int delay = prefs.getInt('loopModeDelay', ConsolePreferences.DEFAULT_LOOP_MODE_DELAY_MILLIS)
- Timer timer = new Timer(delay, {
- if( inputAreaContentHash == inputArea.getText().hashCode() ) {
- runScriptImpl(selected, st)
- }
- })
- timer.repeats = false
- timer.start()
}
}
}
+ runThread.start()
}
@CompileStatic