Skip to content

Commit

Permalink
Merge pull request #404 from Workiva/tweak_collection_dep
Browse files Browse the repository at this point in the history
Nullable fixes
  • Loading branch information
rmconsole7-wk authored Aug 19, 2023
2 parents 925e98b + 2c8b36a commit 877a823
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
23 changes: 18 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
## [5.0.0] (<https://github.com/Workiva/w_transport/compare/4.1.6...5.0.0>)
## [5.0.1](https://github.com/Workiva/w_transport/compare/5.0.0...5.0.1)

- Updated to null safety
- Made `RequestException.request` nullable and re-add the null check, as we
found unsound consumer usages where this could be null.
- Bumped `collection` dependency to a non-pre-release version.

## [4.1.6] (https://github.com/Workiva/w_transport/compare/4.1.5...4.1.6)
## [5.0.0](https://github.com/Workiva/w_transport/compare/4.1.6...5.0.0)

- Updated to null safety:
- Made as much of the public API non-nullable as safely possible.
- One notable behavioral change that was required in order to make the request
dispatch methods (like `.get()` and `.post()`) return non-nullable: if any
response interceptor takes a non-null response but returns a null response,
the original non-null response will be used instead. In practice, we don't
think this is common, and being able to make request methods return
non-nullable was worth it.

## [4.1.6](https://github.com/Workiva/w_transport/compare/4.1.5...4.1.6)

- **Bug Fix:** When using `MockTransports.install(fallThrough: true)`, the
optional `body` param on the `send()` method will now properly be applied when
the request "falls through" the mock config to a real request.
- **Docs:** Suggest using `.streamGet()` over `.get()` for binary responses that
will be read as bytes (via `body.asBytes()`).

## [4.1.4] (https://github.com/Workiva/w_transport/compare/4.1.3...4.1.4)
## [4.1.4](https://github.com/Workiva/w_transport/compare/4.1.3...4.1.4)

- Widen ranges on `fluri` and `http_parser`

## [4.1.3] (https://github.com/Workiva/w_transport/compare/4.1.2...4.1.3)
## [4.1.3](https://github.com/Workiva/w_transport/compare/4.1.2...4.1.3)

- **Improvement** JSON content will always decode as utf-8. Previously it would
fall back to the encoding specified for the body, or to ISO-8859-1, which was
Expand Down
9 changes: 5 additions & 4 deletions lib/src/http/request_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RequestException implements Exception {
final String? method;

/// Failed request.
final BaseRequest request;
final BaseRequest? request;

/// Response to the failed request (some of the properties may be unavailable).
final BaseResponse? response;
Expand All @@ -42,10 +42,11 @@ class RequestException implements Exception {
/// response status.
String get message {
String msg;
if (request.autoRetry.numAttempts > 1) {
var r = request;
if (r != null && r.autoRetry.numAttempts > 1) {
msg = '$method $uri';
for (int i = 0; i < request.autoRetry.failures.length; i++) {
final failure = request.autoRetry.failures[i];
for (int i = 0; i < r.autoRetry.failures.length; i++) {
final failure = r.autoRetry.failures[i];
String attempt = '\n\tAttempt #${i + 1}:';
if (failure.response != null) {
attempt +=
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
mime: '>=0.9.6+3 <2.0.0'
quiver: '>=2.1.5 <4.0.0'
sockjs_client_wrapper: ^1.0.14
collection: ^1.15.0-nullsafety.4
collection: ^1.15.0

dev_dependencies:
_test_server:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/http/request_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ void _runCommonRequestSuiteFor(String name,
request.abort();
expect(future, throwsA(predicate((dynamic error) {
return error is transport.RequestException &&
error.request.autoRetry.numAttempts == 1;
error.request?.autoRetry.numAttempts == 1;
})));
});

Expand Down

0 comments on commit 877a823

Please sign in to comment.