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()
109
109
ensureNoUnrecoverableError ();
110
110
ensureConnectionIsOpen ();
111
111
112
+ if ( currentTransaction != null )
113
+ {
114
+ currentTransaction .markToClose ();
115
+ }
112
116
connection .resetAsync ();
113
117
}
114
118
Original file line number Diff line number Diff line change 27
27
import org .neo4j .driver .v1 .util .TestNeo4j ;
28
28
29
29
import static org .hamcrest .CoreMatchers .equalTo ;
30
+ import static org .hamcrest .CoreMatchers .startsWith ;
30
31
import static org .hamcrest .Matchers .greaterThan ;
31
32
import static org .junit .Assert .assertFalse ;
32
33
import static org .junit .Assert .assertThat ;
@@ -238,4 +239,26 @@ public void shouldAllowMoreTxAfterSessionReset()
238
239
}
239
240
}
240
241
}
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
+ }
241
264
}
You can’t perform that action at this time.
0 commit comments