Commit 79deb5f
authored
Fix bug that let responsePayloadBytes get set to -1 (#6721)
Fix a bug in `InstrHttpInputStream` that let
`NetworkRequestMetric.responsePayloadBytes` get set to -1 in some
conditions.
While investigating [b/398063523](http://b/398063523), I found that
`inputStream.read(...)` can return 0 in some cases, for example, when
the byte buffer length is 0. When this happens, it was possible to set
`responsePayloadBytes` to -1 because `-1 + 0 = -1`. I didn't just have
`bytesRead` initialize to 0 because there is a difference between 0
bytes read, and no read happened. Tested manually by hacking a test app
to force this to happen, and by unit tests.1 parent d701c34 commit 79deb5f
File tree
3 files changed
+52
-20
lines changed- firebase-perf
- src
- main/java/com/google/firebase/perf/network
- test/java/com/google/firebase/perf/network
3 files changed
+52
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
Lines changed: 22 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 33 | + | |
40 | 34 | | |
41 | 35 | | |
42 | 36 | | |
| |||
99 | 93 | | |
100 | 94 | | |
101 | 95 | | |
102 | | - | |
| 96 | + | |
| 97 | + | |
103 | 98 | | |
104 | 99 | | |
105 | 100 | | |
106 | 101 | | |
107 | | - | |
| 102 | + | |
108 | 103 | | |
109 | 104 | | |
110 | 105 | | |
| |||
124 | 119 | | |
125 | 120 | | |
126 | 121 | | |
127 | | - | |
| 122 | + | |
| 123 | + | |
128 | 124 | | |
129 | 125 | | |
130 | 126 | | |
131 | 127 | | |
132 | | - | |
| 128 | + | |
133 | 129 | | |
134 | 130 | | |
135 | 131 | | |
| |||
148 | 144 | | |
149 | 145 | | |
150 | 146 | | |
151 | | - | |
| 147 | + | |
| 148 | + | |
152 | 149 | | |
153 | 150 | | |
154 | 151 | | |
155 | 152 | | |
156 | | - | |
| 153 | + | |
157 | 154 | | |
158 | 155 | | |
159 | 156 | | |
| |||
183 | 180 | | |
184 | 181 | | |
185 | 182 | | |
186 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
187 | 186 | | |
188 | 187 | | |
189 | 188 | | |
190 | | - | |
| 189 | + | |
191 | 190 | | |
192 | 191 | | |
193 | 192 | | |
| |||
197 | 196 | | |
198 | 197 | | |
199 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
200 | 207 | | |
Lines changed: 29 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | | - | |
| 51 | + | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
| |||
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
56 | | - | |
| 61 | + | |
57 | 62 | | |
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
62 | 72 | | |
63 | 73 | | |
64 | 74 | | |
| |||
80 | 90 | | |
81 | 91 | | |
82 | 92 | | |
83 | | - | |
| 93 | + | |
84 | 94 | | |
85 | 95 | | |
86 | 96 | | |
| |||
89 | 99 | | |
90 | 100 | | |
91 | 101 | | |
92 | | - | |
| 102 | + | |
93 | 103 | | |
94 | 104 | | |
95 | 105 | | |
| |||
108 | 118 | | |
109 | 119 | | |
110 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
111 | 135 | | |
112 | 136 | | |
113 | 137 | | |
| |||
0 commit comments