You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2023/12/06 18:03:54 UTC
(tinkerpop) 02/03: Merge branch '3.6-dev' into 3.7-dev
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 4e1bbf3a5de7c3a0ef4ff1640306d051b9b85e6e
Merge: 898c12e5a8 500252dcfc
Author: Stephen Mallette <st...@amazon.com>
AuthorDate: Wed Dec 6 13:01:45 2023 -0500
Merge branch '3.6-dev' into 3.7-dev
CHANGELOG.asciidoc | 2 +-
.../main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
index 830ca2093e,b594937203..1641d823bc
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
@@@ -112,33 -111,14 +112,33 @@@ public final class JavaTranslator<S ext
if (object instanceof Bytecode.Binding)
return translateObject(((Bytecode.Binding) object).value());
else if (object instanceof Bytecode) {
- try {
- final Traversal.Admin<?, ?> traversal = (Traversal.Admin) this.anonymousTraversalStart.invoke(null);
- for (final Bytecode.Instruction instruction : ((Bytecode) object).getStepInstructions()) {
- invokeMethod(traversal, Traversal.class, instruction.getOperator(), instruction.getArguments());
+ // source based bytecode at this stage of translation could have special meaning, but generally this is
+ // going to spawn a new anonymous traversal.
+ final Bytecode bc = (Bytecode) object;
+ if (!bc.getSourceInstructions().isEmpty()) {
+ // currently, valid source instructions will be singly defined. would be odd to get this error. could
+ // be just bad construction from a language variant if it appears. maybe better as an assertion but
+ // third-party variants might benefit from this error
+ if (bc.getSourceInstructions().size() != 1) {
+ throw new IllegalStateException("More than one source instruction defined in bytecode");
+ }
+
+ final Bytecode.Instruction inst = bc.getSourceInstructions().get(0);
+ if (inst.getOperator().equals(CardinalityValueTraversal.class.getSimpleName())) {
+ return CardinalityValueTraversal.from(inst);
+ } else {
+ throw new IllegalStateException(String.format("Unknown source instruction for %s", inst.getOperator()));
+ }
+ } else {
+ try {
+ final Traversal.Admin<?, ?> traversal = (Traversal.Admin) this.anonymousTraversalStart.invoke(null);
+ for (final Bytecode.Instruction instruction : bc.getStepInstructions()) {
+ invokeMethod(traversal, Traversal.class, instruction.getOperator(), instruction.getArguments());
+ }
+ return traversal;
+ } catch (final Throwable e) {
- throw new IllegalStateException(e.getMessage());
++ throw new IllegalStateException(e.getMessage(), e);
}
- return traversal;
- } catch (final Throwable e) {
- throw new IllegalStateException(e.getMessage(), e);
}
} else if (object instanceof TraversalStrategyProxy) {
final Map<String, Object> map = new HashMap<>();