[ 
https://issues.apache.org/jira/browse/TINKERPOP-3040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18008800#comment-18008800
 ] 

ASF GitHub Bot commented on TINKERPOP-3040:
-------------------------------------------

andreachild commented on code in PR #3162:
URL: https://github.com/apache/tinkerpop/pull/3162#discussion_r2220273471


##########
gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/RemoteParser.groovy:
##########
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.console
+
+import org.apache.groovy.groovysh.ParseCode
+import org.apache.groovy.groovysh.ParseStatus
+import org.apache.groovy.groovysh.Parsing
+import org.codehaus.groovy.control.CompilerConfiguration
+import org.codehaus.groovy.control.MultipleCompilationErrorsException
+import org.codehaus.groovy.control.messages.Message
+import org.codehaus.groovy.control.messages.SyntaxErrorMessage
+
+/**
+ * A {@link Parsing} implementation that detects if a Groovy script is 
complete or incomplete. This implementation uses
+ * the Groovy compiler to try to compile the script and analyzes any 
compilation errors to determine if the script is
+ * incomplete. It does not evaluate the script, which prevents local execution 
and potential local failure.
+ */
+class RemoteParser implements Parsing {

Review Comment:
   Nit: `RemoteParser` name to me indicates that parsing is happening remotely 
but the reality is the opposite. How about something like `LocalSafeParser`?





> Remote Console won't send queries that cause exceptions locally
> ---------------------------------------------------------------
>
>                 Key: TINKERPOP-3040
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3040
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: console
>    Affects Versions: 3.7.0
>            Reporter: Ken Hu
>            Priority: Critical
>
> From: https://groups.google.com/g/gremlin-users/c/U2gIxmRcrI8/m/x12banhdAAAJ
> It appears that if an exception occurs when the remote console is executing a 
> command locally then it won't send that query to the server.
>  
> Example:
> {code:java}
>          \,,,/
>          (o o)
> -----oOOo-(3)-oOOo-----
> plugin activated: tinkerpop.server
> plugin activated: tinkerpop.utilities
> plugin activated: tinkerpop.tinkergraph
> plugin activated: janusgraph.imports
> gremlin> :remote connect tinkerpop.server conf/remote.yaml
> ==>Configured localhost/127.0.0.1:45940
> gremlin> :remote console
> ==>All scripts will now be sent to Gremlin Server - 
> [localhost/127.0.0.1:45940] - type ':remote console' to return to local mode
> gremlin> JanusGraphFactory.getGraphNames()
> Gremlin Server must be configured to use the JanusGraphManager.
> Type ':help' or ':h' for help.
> Display stack trace? [yN]y
> java.lang.NullPointerException: Gremlin Server must be configured to use the 
> JanusGraphManager.
>       at 
> com.google.common.base.Preconditions.checkNotNull(Preconditions.java:921)
>       at 
> org.janusgraph.core.JanusGraphFactory.getGraphNames(JanusGraphFactory.java:187)
>       at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
>       at groovysh_evaluate.run(groovysh_evaluate:3)
>       at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.selectMethod(IndyInterface.java:355)
>       at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
>       at 
> org.apache.groovy.groovysh.Interpreter.evaluate(Interpreter.groovy:82)
>       at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
>       at 
> org.apache.tinkerpop.gremlin.console.GremlinGroovysh.execute(GremlinGroovysh.groovy:118)
>       at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
>       at org.apache.groovy.groovysh.Shell.leftShift(Shell.groovy:121)
>       at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
>       at org.apache.groovy.groovysh.ShellRunner.work(ShellRunner.groovy:93)
>       at 
> org.apache.groovy.groovysh.InteractiveShellRunner.work(InteractiveShellRunner.groovy:124)
>       at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
>       at org.apache.groovy.groovysh.ShellRunner.run(ShellRunner.groovy:57)
>       at 
> org.apache.groovy.groovysh.InteractiveShellRunner.run(InteractiveShellRunner.groovy:96)
>       at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
>       at 
> org.apache.tinkerpop.gremlin.console.Console.<init>(Console.groovy:175)
>       at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
>       at org.apache.tinkerpop.gremlin.console.Console.main(Console.groovy:574)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to