Skip to content

Commit e7310e8

Browse files
author
Zhen
committed
put all logic of checking null bookmark into setBookmark
1 parent 068949c commit e7310e8

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

driver/src/main/java/org/neo4j/driver/internal/NetworkSession.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public synchronized void reset()
126126
if ( currentTransaction != null )
127127
{
128128
currentTransaction.markToClose();
129-
updateLastBookmarkFrom( currentTransaction );
129+
setBookmark( currentTransaction.bookmark() );
130130
currentTransaction = null;
131131
}
132132
if ( currentConnection != null )
@@ -179,10 +179,7 @@ public synchronized Transaction beginTransaction()
179179
@Override
180180
public synchronized Transaction beginTransaction( String bookmark )
181181
{
182-
if ( bookmark != null )
183-
{
184-
setBookmark( bookmark );
185-
}
182+
setBookmark( bookmark );
186183
return beginTransaction();
187184
}
188185

@@ -203,7 +200,10 @@ public <T> T writeTransaction( TransactionWork<T> work )
203200
// is a valid requirement for some test scenarios.
204201
void setBookmark( String bookmark )
205202
{
206-
this.bookmark = bookmark;
203+
if( bookmark != null )
204+
{
205+
this.bookmark = bookmark;
206+
}
207207
}
208208

209209
@Override
@@ -230,7 +230,7 @@ public synchronized void onTransactionClosed( ExplicitTransaction tx )
230230
if ( currentTransaction != null && currentTransaction == tx )
231231
{
232232
closeCurrentConnection();
233-
updateLastBookmarkFrom( currentTransaction );
233+
setBookmark( currentTransaction.bookmark() );
234234
currentTransaction = null;
235235
}
236236
}
@@ -395,14 +395,6 @@ private void closeCurrentConnection( boolean sync )
395395
}
396396
}
397397

398-
private void updateLastBookmarkFrom( ExplicitTransaction tx )
399-
{
400-
if ( tx.bookmark() != null )
401-
{
402-
bookmark = tx.bookmark();
403-
}
404-
}
405-
406398
private static List<Throwable> recordError( Throwable error, List<Throwable> errors )
407399
{
408400
if ( errors == null )

0 commit comments

Comments
 (0)