File tree Expand file tree Collapse file tree 1 file changed +15
-19
lines changed
src/MongoDB.Driver.Core/Core/Operations Expand file tree Collapse file tree 1 file changed +15
-19
lines changed Original file line number Diff line number Diff line change @@ -81,20 +81,18 @@ public void Dispose()
81
81
public bool MoveNext ( CancellationToken cancellationToken = default ( CancellationToken ) )
82
82
{
83
83
bool hasMore ;
84
- try
84
+ while ( true )
85
85
{
86
- hasMore = _cursor . MoveNext ( cancellationToken ) ;
87
- }
88
- catch ( Exception ex )
89
- {
90
- if ( RetryabilityHelper . IsResumableChangeStreamException ( ex ) )
86
+ try
91
87
{
92
- _cursor = _changeStreamOperation . Resume ( _binding , cancellationToken ) ;
93
88
hasMore = _cursor . MoveNext ( cancellationToken ) ;
89
+ break ;
94
90
}
95
- else
91
+ catch ( Exception ex ) when ( RetryabilityHelper . IsResumableChangeStreamException ( ex ) )
96
92
{
97
- throw ;
93
+ var newCursor = _changeStreamOperation . Resume ( _binding , cancellationToken ) ;
94
+ _cursor . Dispose ( ) ;
95
+ _cursor = newCursor ;
98
96
}
99
97
}
100
98
@@ -104,22 +102,20 @@ public void Dispose()
104
102
105
103
/// <inheritdoc/>
106
104
public async Task < bool > MoveNextAsync ( CancellationToken cancellationToken = default ( CancellationToken ) )
107
- {
105
+ {
108
106
bool hasMore ;
109
- try
107
+ while ( true )
110
108
{
111
- hasMore = await _cursor . MoveNextAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
112
- }
113
- catch ( Exception ex )
114
- {
115
- if ( RetryabilityHelper . IsResumableChangeStreamException ( ex ) )
109
+ try
116
110
{
117
- _cursor = await _changeStreamOperation . ResumeAsync ( _binding , cancellationToken ) . ConfigureAwait ( false ) ;
118
111
hasMore = await _cursor . MoveNextAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
112
+ break ;
119
113
}
120
- else
114
+ catch ( Exception ex ) when ( RetryabilityHelper . IsResumableChangeStreamException ( ex ) )
121
115
{
122
- throw ;
116
+ var newCursor = await _changeStreamOperation . ResumeAsync ( _binding , cancellationToken ) . ConfigureAwait ( false ) ;
117
+ _cursor . Dispose ( ) ;
118
+ _cursor = newCursor ;
123
119
}
124
120
}
125
121
You can’t perform that action at this time.
0 commit comments