File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
main/java/org/neo4j/driver/internal
test/java/org/neo4j/driver/v1/integration Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,10 @@ public void reset()
109109 ensureNoUnrecoverableError ();
110110 ensureConnectionIsOpen ();
111111
112+ if ( currentTransaction != null )
113+ {
114+ currentTransaction .markToClose ();
115+ }
112116 connection .resetAsync ();
113117 }
114118
Original file line number Diff line number Diff line change 2727import org .neo4j .driver .v1 .util .TestNeo4j ;
2828
2929import static org .hamcrest .CoreMatchers .equalTo ;
30+ import static org .hamcrest .CoreMatchers .startsWith ;
3031import static org .hamcrest .Matchers .greaterThan ;
3132import static org .junit .Assert .assertFalse ;
3233import static org .junit .Assert .assertThat ;
@@ -238,4 +239,26 @@ public void shouldAllowMoreTxAfterSessionReset()
238239 }
239240 }
240241 }
242+
243+ @ Test
244+ public void shouldMarkTxAsFailedAndDisAllowRunAfterSessionReset ()
245+ {
246+ // Given
247+ try ( Driver driver = GraphDatabase .driver ( neo4j .uri () );
248+ Session session = driver .session () )
249+ {
250+ try ( Transaction tx = session .beginTransaction () )
251+ {
252+ // When reset the state of this session
253+ session .reset ();
254+ // Then
255+ tx .run ( "Return 1" );
256+ fail ( "Should not allow tx run as tx is already failed." );
257+ }
258+ catch ( Exception e )
259+ {
260+ assertThat ( e .getMessage (), startsWith ( "Cannot run more statements in this transaction" ) );
261+ }
262+ }
263+ }
241264}
You can’t perform that action at this time.
0 commit comments