@@ -528,13 +528,7 @@ public void shouldAllowExistingTransactionToCompleteAfterDifferentConnectionBrea
528
528
}
529
529
530
530
// rediscovery should happen for the new write query
531
- String session4Bookmark ;
532
- try ( Session session4 = driver .session () )
533
- {
534
- session4 .run ( "CREATE (n:Node3 {name: 'Node3'})" ).consume ();
535
- session4Bookmark = session4 .lastBookmark ();
536
- }
537
-
531
+ String session4Bookmark = createNodeAndGetBookmark ( driver .session (), "Node3" , "name" , "Node3" );
538
532
try ( Session session5 = driver .session ( session4Bookmark ) )
539
533
{
540
534
assertEquals ( 1 , countNodes ( session5 , "Node3" , "name" , "Node3" ) );
@@ -810,21 +804,27 @@ private static Callable<String> createNodeAndGetBookmark( final Driver driver, f
810
804
@ Override
811
805
public String call ()
812
806
{
813
- try ( Session session = driver .session () )
814
- {
815
- session .writeTransaction ( new TransactionWork <Void >()
816
- {
817
- @ Override
818
- public Void execute ( Transaction tx )
819
- {
820
- tx .run ( "CREATE (n:" + label + ") SET n." + property + " = $value" ,
821
- parameters ( "value" , value ) );
822
- return null ;
823
- }
824
- } );
825
- return session .lastBookmark ();
826
- }
807
+ return createNodeAndGetBookmark ( driver .session (), label , property , value );
827
808
}
828
809
};
829
810
}
811
+
812
+ private static String createNodeAndGetBookmark ( final Session session , final String label , final String property ,
813
+ final String value )
814
+ {
815
+ try ( Session localSession = session )
816
+ {
817
+ localSession .writeTransaction ( new TransactionWork <Void >()
818
+ {
819
+ @ Override
820
+ public Void execute ( Transaction tx )
821
+ {
822
+ tx .run ( "CREATE (n:" + label + ") SET n." + property + " = $value" ,
823
+ parameters ( "value" , value ) );
824
+ return null ;
825
+ }
826
+ } );
827
+ return localSession .lastBookmark ();
828
+ }
829
+ }
830
830
}
0 commit comments