Skip to content

Commit

Permalink
Fixed a recursion issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint committed Dec 1, 2011
1 parent f876396 commit c045267
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions shell/src/main/java/org/neo4j/shell/impl/AbstractClient.java
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -203,36 +204,37 @@ 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 )
{
throw new RuntimeException( e );
}
}

protected void possiblyGrabDefaultVariableFromServer( String key,
protected void possiblyGrabDefaultVariableFromServer( ShellServer server, String key,
Serializable defaultValue )
{
try
{
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 );
}
Expand All @@ -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 );
}
}

Expand Down
2 changes: 1 addition & 1 deletion shell/src/main/java/org/neo4j/shell/impl/RemoteClient.java
Expand Up @@ -97,7 +97,7 @@ public ShellServer getServer()
{
this.server = findRemoteServer();
getOutput().println( "[Reconnected to server]" );
regrabVariablesFromServer();
regrabVariablesFromServer( this.server );
}
catch ( ShellException ee )
{
Expand Down

0 comments on commit c045267

Please sign in to comment.