Commit 7a9a28c
committed
okhttp: optimize HPACK to index :path and fix dynamic table eviction bugs (grpc#12819)
Allow the :path pseudo-header to be added to the HPACK dynamic table in
the gRPC-Java OkHttp transport, resolving the original goal of grpc#12819
and redoing reverted commit 397d3e7 (grpc#12799, grpc#12820).
Background & Root Cause:
In gRPC over HTTP/2, :path headers represent static service/method names
(e.g., /package.Service/Method), which are constant across RPC calls.
Previously, indexing :path was reverted (grpc#12820) because high dynamic
table churn uncovered latent bugs in legacy OkHttp Hpack.java:
1. Off-by-one NPE loop bound in evictToRecoverBytes:
When bytesToRecover exceeded total dynamic table size, the loop condition
(j >= nextDynamicTableIndex) inspected the unallocated nextDynamicTableIndex
slot containing null, throwing a NullPointerException. Fixed by changing
the loop bound to (j > nextDynamicTableIndex).
2. Reference leak post-eviction:
System.arraycopy shifted active entries rightward, but left stale
Header/ByteString references in vacated array slots. Fixed by setting
vacated array slots to null via Arrays.fill().
3. Case sensitivity normalization:
Header entries inserted into dynamicTable are now guaranteed to store
lowercased name keys, preventing failed dynamic table header lookups.
4. Table Size Setting Handling:
Works in conjunction with grpc#12818 (SETTINGS_HEADER_TABLE_SIZE handling).
Fixes grpc#12819
Related: grpc#12799, grpc#12818, grpc#12820, b/5146880161 parent bc01994 commit 7a9a28c
2 files changed
Lines changed: 39 additions & 14 deletions
File tree
- okhttp/third_party/okhttp
- main/java/io/grpc/okhttp/internal/framed
- test/java/io/grpc/okhttp/internal/framed
Lines changed: 13 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
| |||
489 | 490 | | |
490 | 491 | | |
491 | 492 | | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
496 | 501 | | |
497 | 502 | | |
498 | 503 | | |
499 | 504 | | |
500 | 505 | | |
501 | 506 | | |
502 | | - | |
| 507 | + | |
503 | 508 | | |
504 | 509 | | |
505 | 510 | | |
| |||
557 | 562 | | |
558 | 563 | | |
559 | 564 | | |
560 | | - | |
| 565 | + | |
561 | 566 | | |
562 | 567 | | |
563 | 568 | | |
564 | 569 | | |
565 | 570 | | |
566 | 571 | | |
567 | 572 | | |
| 573 | + | |
568 | 574 | | |
569 | 575 | | |
570 | 576 | | |
| |||
Lines changed: 26 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1108 | 1108 | | |
1109 | 1109 | | |
1110 | 1110 | | |
1111 | | - | |
1112 | | - | |
1113 | | - | |
1114 | | - | |
1115 | 1111 | | |
1116 | 1112 | | |
1117 | 1113 | | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
1121 | 1122 | | |
1122 | 1123 | | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
1123 | 1129 | | |
1124 | 1130 | | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
1125 | 1137 | | |
1126 | 1138 | | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
1127 | 1146 | | |
1128 | 1147 | | |
1129 | 1148 | | |
| |||
0 commit comments