Commit 7525934
committed
fix(csi): sort ArgumentSpecification by index when generating partial-argument advice
Stream.sorted() without a comparator requires Comparable, but
ArgumentSpecification does not implement it. This caused a
ClassCastException in AdviceGeneratorImpl.writeStackOperations whenever
an advice method captured a strict subset (≥2 args) of a target
method's parameters positionally — e.g. capturing args 0 and 1 from a
3-arg target method.
Single-argument partial captures were unaffected because TimSort never
calls compare() on a one-element list.
Fix: use Comparator.comparingInt on ArgumentSpecification.getIndex().
Add a regression test with a @before advice that captures two of three
arguments from String.format(Locale, String, Object[]).1 parent 42f154d commit 7525934
2 files changed
Lines changed: 40 additions & 1 deletion
File tree
- buildSrc/call-site-instrumentation-plugin/src
- main/java/datadog/trace/plugin/csi/impl
- test/java/datadog/trace/plugin/csi/impl
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
266 | 267 | | |
267 | 268 | | |
268 | 269 | | |
269 | | - | |
| 270 | + | |
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
| |||
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
429 | 467 | | |
430 | 468 | | |
431 | 469 | | |
| |||
0 commit comments