Commit 7a51187
authored
MINOR: Use TransactionOperation enum instead of String for pending state checks (#21218)
### PR Description
this PR refactors `TransactionManager#throwIfPendingState` to use a
typed `TransactionOperation` enum instead of a raw String.
###Background / Motivation
The previous String-based API relies on manually passing operation
names, which can make it easier for naming to drift or become
inconsistent over time. Using an enum makes the intent more explicit and
keeps the operation naming centralized.
### What’s changed
- Added a `TransactionOperation` enum with a `displayName` (and
`toString()` override) to preserve readable exception messages.
- Updated relevant call sites (`beginTransaction`, `prepareTransaction`,
`sendOffsetsToTransaction`, `maybeAddPartition`) to pass the
corresponding enum value.
- Updated `throwIfPendingState` to accept `TransactionOperation` instead
of `String`.
### Behavior / Compatibility
- No behavioral change is intended. The exception message remains
human-readable and consistent via `TransactionOperation#toString()`.
### Testing
No additional tests were added since this is a small refactor; existing
tests should continue to cover the pending-transition behavior.
Reviewers: TaiJuWu <tjwu1217@gmail.com>, Chia-Ping Tsai
<chia7712@gmail.com>1 parent 2bae9c3 commit 7a51187
File tree
1 file changed
+23
-5
lines changed- clients/src/main/java/org/apache/kafka/clients/producer/internals
1 file changed
+23
-5
lines changedLines changed: 23 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
208 | 226 | | |
209 | 227 | | |
210 | 228 | | |
| |||
331 | 349 | | |
332 | 350 | | |
333 | 351 | | |
334 | | - | |
| 352 | + | |
335 | 353 | | |
336 | 354 | | |
337 | 355 | | |
| |||
343 | 361 | | |
344 | 362 | | |
345 | 363 | | |
346 | | - | |
| 364 | + | |
347 | 365 | | |
348 | 366 | | |
349 | 367 | | |
| |||
406 | 424 | | |
407 | 425 | | |
408 | 426 | | |
409 | | - | |
| 427 | + | |
410 | 428 | | |
411 | 429 | | |
412 | 430 | | |
| |||
438 | 456 | | |
439 | 457 | | |
440 | 458 | | |
441 | | - | |
| 459 | + | |
442 | 460 | | |
443 | 461 | | |
444 | 462 | | |
| |||
1248 | 1266 | | |
1249 | 1267 | | |
1250 | 1268 | | |
1251 | | - | |
| 1269 | + | |
1252 | 1270 | | |
1253 | 1271 | | |
1254 | 1272 | | |
| |||
0 commit comments