Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Better feedback when working with around dangling transactions

  • Loading branch information...
commit 14b66aadb50f1c663852a8fbcdba4756b911d44c 1 parent a5b10a5
@systay authored
View
1  shell/src/main/java/org/neo4j/shell/kernel/apps/Begin.java
@@ -69,6 +69,7 @@ protected Continuation exec( AppCommandParser parser, Session session, Output ou
} else
{
count = 1;
+ out.println( "Warning: transaction found that was not started by the shell." );
}
} else
{
View
38 shell/src/main/java/org/neo4j/shell/kernel/apps/Commit.java
@@ -19,6 +19,8 @@
*/
package org.neo4j.shell.kernel.apps;
+import static org.neo4j.shell.ShellException.wrapCause;
+
import java.rmi.RemoteException;
import javax.transaction.SystemException;
@@ -43,6 +45,18 @@ public String getDescription()
return "Commits a transaction";
}
+ private Transaction getCurrectTransaction() throws ShellException
+ {
+ try
+ {
+
+ return getServer().getDb().getTxManager().getTransaction();
+ } catch ( SystemException e )
+ {
+ throw wrapCause( e );
+ }
+ }
+
@Override
protected Continuation exec( AppCommandParser parser, Session session, Output out )
throws ShellException, RemoteException
@@ -55,20 +69,22 @@ protected Continuation exec( AppCommandParser parser, Session session, Output ou
Integer txCount = (Integer) session.get( TX_COUNT );
+ Transaction tx = getCurrectTransaction();
if ( txCount == null || txCount.equals( 0 ) )
{
- throw new ShellException( "Not in a transaction" );
- } else if ( txCount.equals( 1 ) )
- {
- Transaction tx;
- try
+ if ( tx != null )
{
- tx = getServer().getDb().getTxManager().getTransaction();
- if ( tx == null )
- {
- throw fail( session, "Not in a transaction" );
- }
- } catch ( SystemException e )
+ out.println( "Warning: committing a transaction not started by the shell" );
+ txCount = 1;
+ } else
+ {
+ throw new ShellException( "Not in a transaction" );
+ }
+ }
+
+ if ( txCount.equals( 1 ) )
+ {
+ if ( tx == null )
{
throw fail( session, "Not in a transaction" );
}
Please sign in to comment.
Something went wrong with that request. Please try again.