@@ -164,7 +164,7 @@ func (r *Reader) commitOffsetsWithRetry(gen *Generation, offsetStash offsetStash
164
164
msgsForPartition [partition ] = commitInfo .offset
165
165
}
166
166
}
167
- var illegalGenerationErr error
167
+ var illegalGenerationErr bool
168
168
for generationID , messages := range messagesToSendForGeneration {
169
169
for attempt := 0 ; attempt < retries ; attempt ++ {
170
170
if attempt != 0 {
@@ -173,25 +173,24 @@ func (r *Reader) commitOffsetsWithRetry(gen *Generation, offsetStash offsetStash
173
173
}
174
174
}
175
175
176
- if commitErr : = gen .CommitOffsetsForGenID (generationID , messages ); commitErr == nil {
176
+ if err = gen .CommitOffsetsForGenID (generationID , messages ); err == nil {
177
177
continue
178
- } else {
179
- // IllegalGeneration error is not retriable, but we should attempt to
180
- // perform the remaining commits
181
- if commitErr == IllegalGeneration {
182
- r .withErrorLogger (func (l Logger ) { l .Printf ("%v" , commitErr ) })
183
- illegalGenerationErr = commitErr
184
- offsetStash .removeGenerationID (generationID )
185
- } else {
186
- err = commitErr
187
- }
178
+ }
179
+
180
+ // IllegalGeneration error is not retriable, but we should attempt to
181
+ // perform the remaining commits
182
+ if err == IllegalGenerationErr {
183
+ r .withErrorLogger (func (l Logger ) { l .Printf ("%v" , err ) })
184
+ illegalGenerationErr = true
185
+ err = nil
186
+ offsetStash .removeGenerationID (generationID )
188
187
}
189
188
}
190
189
}
191
190
192
191
// if configured to ignore the error
193
- if illegalGenerationErr != nil && r .config .ErrorOnWrongGenerationCommit {
194
- err = illegalGenerationErr
192
+ if illegalGenerationErr && r .config .ErrorOnWrongGenerationCommit {
193
+ err = IllegalGenerationErr
195
194
}
196
195
return // err will not be nil
197
196
}
0 commit comments