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 2022/12/17 10:00:00 UTC
[groovy] branch master updated: GROOVY-10877: Record with ThreadInterruptibleASTTransformation applied fails to run
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new a9b16f2dc7 GROOVY-10877: Record with ThreadInterruptibleASTTransformation applied fails to run
a9b16f2dc7 is described below
commit a9b16f2dc743ede5ffa3f42b9d3d799faaf5932c
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Dec 17 17:36:02 2022 +0800
GROOVY-10877: Record with ThreadInterruptibleASTTransformation applied fails to run
---
.../ThreadInterruptibleASTTransformation.groovy | 3 ++-
src/test/groovy/transform/ThreadInterruptTest.groovy | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy b/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy
index 459a94b829..396b2dd77c 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy
@@ -85,7 +85,8 @@ class ThreadInterruptibleASTTransformation extends AbstractInterruptibleASTTrans
@Override
void visitMethod(MethodNode node) {
- if (checkOnMethodStart && !node.isSynthetic() && !node.isAbstract()) {
+ if (checkOnMethodStart && !node.isSynthetic() && !node.isAbstract()
+ && !(node.getDeclaringClass().isRecord() && node.annotations?.any(e -> 'groovy.transform.Generated' == e.classNode.name))) {
def code = node.code
node.code = wrapBlock(code)
}
diff --git a/src/test/groovy/transform/ThreadInterruptTest.groovy b/src/test/groovy/transform/ThreadInterruptTest.groovy
index 95cd0242ec..484f87e48e 100644
--- a/src/test/groovy/transform/ThreadInterruptTest.groovy
+++ b/src/test/groovy/transform/ThreadInterruptTest.groovy
@@ -397,6 +397,23 @@ final class ThreadInterruptTest {
shouldFail(shell, InterruptedException, script)
}
}
+
+ // GROOVY-10877
+ @Test
+ void testThreadInterruptOnRecord() {
+ assertScript '''
+ @groovy.transform.ThreadInterrupt
+ record Point(int x, int y) {
+ String report() {
+ "$x, $y"
+ }
+ }
+
+ def p = new Point(1, 2)
+ assert 'Point[x=1, y=2]' == p.toString()
+ assert '1, 2' == p.report()
+ '''
+ }
}
//--------------------------------------------------------------------------