Commit 199a7ea
authored
xds: Improve XdsNR's selectConfig() variable handling
The variables from the do-while are no longer initialized to let the
compiler verify that the loop sets each. Unnecessary comparisons to null
are also removed and is more obvious as the variables are never set to
null. Added a minor optimization of computing the RPCs path once instead
of once for each route. The variable declarations were also sorted to
match their initialization order.
This does fix an unlikely bug where if the old code could successfully
matched a route but fail to retain the cluster, then when trying a
second time if the route was _not_ matched it would re-use the prior route
and thus infinite-loop failing to retain that same cluster.
It also adds a missing cast to unsigned long for a uint32 weight. The old
code would detect if the _sum_ was negative, but a weight using 32 bits
would have been negative and never selected.1 parent ea3f644 commit 199a7ea
File tree
3 files changed
+28
-20
lines changed- xds/src/main/java/io/grpc/xds
3 files changed
+28
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
| 227 | + | |
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
391 | 391 | | |
| 392 | + | |
392 | 393 | | |
393 | 394 | | |
| 395 | + | |
394 | 396 | | |
395 | | - | |
396 | | - | |
397 | | - | |
| 397 | + | |
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
| 415 | + | |
415 | 416 | | |
416 | 417 | | |
417 | 418 | | |
418 | 419 | | |
419 | 420 | | |
420 | 421 | | |
421 | | - | |
| 422 | + | |
422 | 423 | | |
423 | 424 | | |
424 | 425 | | |
| |||
431 | 432 | | |
432 | 433 | | |
433 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
434 | 438 | | |
435 | 439 | | |
| 440 | + | |
| 441 | + | |
436 | 442 | | |
437 | 443 | | |
438 | | - | |
439 | | - | |
440 | | - | |
| 444 | + | |
441 | 445 | | |
442 | 446 | | |
443 | 447 | | |
444 | 448 | | |
445 | 449 | | |
446 | 450 | | |
447 | 451 | | |
448 | | - | |
449 | | - | |
| 452 | + | |
450 | 453 | | |
451 | 454 | | |
452 | 455 | | |
| |||
459 | 462 | | |
460 | 463 | | |
461 | 464 | | |
462 | | - | |
463 | | - | |
| 465 | + | |
464 | 466 | | |
465 | 467 | | |
466 | 468 | | |
| |||
469 | 471 | | |
470 | 472 | | |
471 | 473 | | |
472 | | - | |
| 474 | + | |
473 | 475 | | |
474 | 476 | | |
475 | 477 | | |
| |||
757 | 759 | | |
758 | 760 | | |
759 | 761 | | |
| 762 | + | |
| 763 | + | |
760 | 764 | | |
761 | 765 | | |
762 | 766 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
499 | | - | |
500 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
501 | 502 | | |
502 | 503 | | |
503 | 504 | | |
| |||
609 | 610 | | |
610 | 611 | | |
611 | 612 | | |
612 | | - | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
613 | 616 | | |
614 | 617 | | |
615 | 618 | | |
| |||
0 commit comments