From c045267294e4f5c1dbbc4f26de413ad888503fa1 Mon Sep 17 00:00:00 2001 From: Mattias Persson Date: Thu, 1 Dec 2011 10:31:53 +0100 Subject: [PATCH] Fixed a recursion issue --- .../org/neo4j/shell/impl/AbstractClient.java | 26 ++++++++++--------- .../org/neo4j/shell/impl/RemoteClient.java | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/shell/src/main/java/org/neo4j/shell/impl/AbstractClient.java b/shell/src/main/java/org/neo4j/shell/impl/AbstractClient.java index ec746632f..d6f4e6811 100644 --- a/shell/src/main/java/org/neo4j/shell/impl/AbstractClient.java +++ b/shell/src/main/java/org/neo4j/shell/impl/AbstractClient.java @@ -34,6 +34,7 @@ import org.neo4j.shell.Session; import org.neo4j.shell.ShellClient; import org.neo4j.shell.ShellException; +import org.neo4j.shell.ShellServer; import org.neo4j.shell.TextUtil; /** @@ -203,20 +204,21 @@ protected void init() { try { - possiblyGrabDefaultVariableFromServer( PROMPT_KEY, "$ " ); - possiblyGrabDefaultVariableFromServer( TITLE_KEYS_KEY, null ); - possiblyGrabDefaultVariableFromServer( TITLE_MAX_LENGTH, null ); - this.getOutput().println( this.getServer().welcome() ); + ShellServer server = getServer(); + possiblyGrabDefaultVariableFromServer( server, PROMPT_KEY, "$ " ); + possiblyGrabDefaultVariableFromServer( server, TITLE_KEYS_KEY, null ); + possiblyGrabDefaultVariableFromServer( server, TITLE_MAX_LENGTH, null ); + getOutput().println( server.welcome() ); // Grab a jline console if available, else a standard one. - this.console = JLineConsole.newConsoleOrNullIfNotFound( this ); - if ( this.console == null ) + console = JLineConsole.newConsoleOrNullIfNotFound( this ); + if ( console == null ) { System.out.println( "Want bash-like features? throw in " + "jLine (http://jline.sourceforge.net) on the classpath" ); - this.console = new StandardConsole(); + console = new StandardConsole(); } - this.getOutput().println(); + getOutput().println(); } catch ( RemoteException e ) { @@ -224,7 +226,7 @@ protected void init() } } - protected void possiblyGrabDefaultVariableFromServer( String key, + protected void possiblyGrabDefaultVariableFromServer( ShellServer server, String key, Serializable defaultValue ) { try @@ -232,7 +234,7 @@ protected void possiblyGrabDefaultVariableFromServer( String key, if ( this.session().get( key ) == null ) { grabbedKeysFromServer.add( key ); - Serializable value = this.getServer().getProperty( key ); + Serializable value = server.getProperty( key ); if ( value == null ) value = defaultValue; if ( value != null ) session().set( key, value ); } @@ -243,12 +245,12 @@ protected void possiblyGrabDefaultVariableFromServer( String key, } } - protected void regrabVariablesFromServer() + protected void regrabVariablesFromServer( ShellServer server ) { for ( String key : grabbedKeysFromServer ) { Serializable value = this.session().remove( key ); - possiblyGrabDefaultVariableFromServer( key, value ); + possiblyGrabDefaultVariableFromServer( server, key, value ); } } diff --git a/shell/src/main/java/org/neo4j/shell/impl/RemoteClient.java b/shell/src/main/java/org/neo4j/shell/impl/RemoteClient.java index 382611bd0..adc443b8a 100644 --- a/shell/src/main/java/org/neo4j/shell/impl/RemoteClient.java +++ b/shell/src/main/java/org/neo4j/shell/impl/RemoteClient.java @@ -97,7 +97,7 @@ public ShellServer getServer() { this.server = findRemoteServer(); getOutput().println( "[Reconnected to server]" ); - regrabVariablesFromServer(); + regrabVariablesFromServer( this.server ); } catch ( ShellException ee ) {