Skip to content

Commit a07cbc9

Browse files
authored
#3724 fix: revert Groovy 5.0.4 to 4.0.28 — GremlinServerPlugin fails to start (#3725)
1 parent 012159b commit a07cbc9

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

gremlin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<commons-configuration2.version>2.13.0</commons-configuration2.version>
4242
<commons-beanutils.version>1.11.0</commons-beanutils.version>
4343
<commons-lang3.version>3.20.0</commons-lang3.version>
44-
<groovy.version>5.0.4</groovy.version>
44+
<groovy.version>4.0.28</groovy.version>
4545
<antlr4.version>4.9.1</antlr4.version>
4646
</properties>
4747

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright © 2021-present Arcade Data Ltd (info@arcadedata.com)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-FileCopyrightText: 2021-present Arcade Data Ltd (info@arcadedata.com)
17+
* SPDX-License-Identifier: Apache-2.0
18+
*/
19+
package com.arcadedb.gremlin;
20+
21+
import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine;
22+
import org.apache.tinkerpop.gremlin.jsr223.CoreGremlinPlugin;
23+
import org.apache.tinkerpop.gremlin.jsr223.Customizer;
24+
import org.junit.jupiter.api.Test;
25+
26+
import javax.script.ScriptException;
27+
28+
import static org.assertj.core.api.Assertions.assertThat;
29+
30+
/**
31+
* Verifies that the Gremlin Groovy script engine initialises correctly with the TinkerPop
32+
* core imports. With Groovy 5 (incompatible with TinkerPop 3.8.x) this fails with
33+
* "The name valueOf is already declared" because {@code ImportGroovyCustomizer} adds a
34+
* wildcard static import ({@code import static Enum.*}) for every enum in
35+
* {@link org.apache.tinkerpop.gremlin.jsr223.CoreImports}, and Groovy 5 rejects duplicate
36+
* {@code valueOf} symbols introduced by multiple such imports.
37+
*
38+
* <p>Regression test for <a href="https://github.com/ArcadeData/arcadedb/issues/3724">#3724</a>.
39+
*/
40+
class GremlinGroovyEngineTest {
41+
42+
@Test
43+
void groovyEngineInitializesWithCoreImports() throws ScriptException {
44+
final Customizer[] customizers = CoreGremlinPlugin.instance()
45+
.getCustomizers("gremlin-groovy")
46+
.orElse(new Customizer[0]);
47+
48+
final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(customizers);
49+
50+
// A successful eval proves the engine started without "valueOf is already declared"
51+
assertThat(engine.eval("1 + 1")).isEqualTo(2);
52+
}
53+
}

0 commit comments

Comments
 (0)