Skip to content

TINKERPOP-3040 Fixed limitation in multi-line parsing. #3162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 3.7-dev
Choose a base branch
from

Conversation

spmallette
Copy link
Contributor

https://issues.apache.org/jira/browse/TINKERPOP-3040

Added a custom parser to help better detect multi-line inputs that does not involve actual evaluation of the input string which can result in scenarios where the script is not sent to the server.

VOTE +1

class RemoteParser implements Parsing {

// Try to compile the script
def config = new CompilerConfiguration()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: just for consistency

Suggested change
def config = new CompilerConfiguration()
private final CompilerConfiguration config = new CompilerConfiguration();

def config = new CompilerConfiguration()

// Create a custom GroovyClassLoader that doesn't write class files
def gcl = new GroovyClassLoader(this.class.classLoader, config) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: just for consistency

Suggested change
def gcl = new GroovyClassLoader(this.class.classLoader, config) {
private final GroovyClassLoader gcl = new GroovyClassLoader(this.class.classLoader, config) {

* 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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

break
}
throw t
} catch (MissingPropertyException mpe) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This MissingPropertyException handling was not ported into the new RemoteParser, was that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't have a MissingPropertyException anymore because this change stops doing a local evaluation of the code in the interpreter. now it just parses for correctness in the script itself.


switch (status.code) {
case ParseCode.COMPLETE:
if (!Boolean.valueOf(getPreference(INTERPRETER_MODE_PREFERENCE_KEY, 'false')) || isTypeOrMethodDeclaration(current)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does interpretorMode no longer need to be specifically handled with the new RemoteParser?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sense this whole section of code i removed was all unnecessary. Note the interpreterMode tests are still passing so I think it's ok.

Added a custom parser to help better detect multi-line inputs that does not involve actual evaluation of the input string which can result in scenarios where the script is not sent to the server.
Copy link
Contributor

@Cole-Greer Cole-Greer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VOTE +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants