Commit 1bd2db0
authored
Null check bug fixes and tweak accessibility of properties on
`DefaultResponseFactory` was throwing if the response stream was null.
This can occur when an exception is thrown when sending the request
(e.g., `HttpRequestException`), for example, when the `HttpClient`
cannot connect to the endpoint. Rather than throwing a null exception
here, we still want to return a response with the original exception
attached.
In `StreamResponse`, we must safety-check that any linked disposables
are not null before attempting to dispose of them.
The final change in `TransportResponse` is a tweak for the ingest work.
The `BulkStreamingResponse` was initially derived from the
`StreamResponse` to share behaviour. However, this causes the `Body`
property (stream) to be present on the derived type. As we are handling
stream reading internally, this is unnecessary and could produce weird
behaviour if the consumer tries to access the stream directly. Instead,
`BulkStreamingResponse` derives directly from `TransportResponse`,
overriding `LeaveOpen` and handling `LinkedDisposables` in its own
`Dispose` method.
This means we could potentially seal `StreamResponse` again. However, it
might still be helpful for consumers to derive responses from this for
advanced scenarios, with the base class doing the right thing during
disposal. I am open to thoughts on whether that's likely to happen.
@flobernd, were you deriving from this in the client?TransportResponse (#144)1 parent efe6b75 commit 1bd2db0
File tree
6 files changed
+98
-55
lines changed- src/Elastic.Transport
- Diagnostics/OpenTelemetry
- Responses
- Special
6 files changed
+98
-55
lines changedLines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
56 | 64 | | |
57 | 65 | | |
58 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | 127 | | |
131 | 128 | | |
132 | 129 | | |
| |||
261 | 258 | | |
262 | 259 | | |
263 | 260 | | |
| 261 | + | |
264 | 262 | | |
265 | 263 | | |
266 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
267 | 268 | | |
268 | 269 | | |
269 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | 82 | | |
85 | 83 | | |
86 | 84 | | |
87 | 85 | | |
88 | | - | |
| 86 | + | |
89 | 87 | | |
90 | 88 | | |
91 | 89 | | |
| |||
Lines changed: 11 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | 18 | | |
26 | | - | |
27 | | - | |
28 | | - | |
| 19 | + | |
29 | 20 | | |
30 | | - | |
31 | 21 | | |
32 | 22 | | |
33 | | - | |
34 | | - | |
35 | | - | |
| 23 | + | |
36 | 24 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | 25 | | |
41 | 26 | | |
42 | | - | |
| 27 | + | |
43 | 28 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 29 | + | |
63 | 30 | | |
64 | 31 | | |
65 | | - | |
| 32 | + | |
66 | 33 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
72 | 38 | | |
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
0 commit comments