Fixes#845
This change allows Feign Exceptions to be created with the original request as an optional parameter.
Changes include:
* Request field added to FeignException
* New constructors are defended from null in request argument
* Tests to check null instead of request, null message updated
Fixes bug where HeaderTemplate stored values in a HashSet which
caused the following issues:
* Header values could be written in wrong order
* Order was not stable between JVM instances
Fixes#1007
rfc7231 section 7.1.3 states that the Retry-After header can return delay-seconds value
that is a non-negative decimal integer, representing time in seconds.
Some servers return the second delay with a decimal point. Eg instead of 2 they return 2.0
This patch handles this case where the server has included a decimal point in their response.
* This pr resolves issue #927
add apache commons lang3 as mvn dependency to get inherited fields of given class
change type.getDeclaredFields() to FieldUtils.getAllFieldsList(type) on FieldQueryMapEncoder
* format
* remove apache common langs dependency
add logic for finding fields which comes via inheritance
In this pr the old `body()` method calls replaced with `requestBody().asBytes()` method which both exists in Request class. The intention is to remove deprecated code and keep source code clean.
Related to #857
* replaced old body with new Body.asBytes()
* add HeaderTemplate create tests for fail
* - added expand test
* - remove redundant public static identifier from Retryer inner class
* - remove redundant public static identifier from Default inner class
* add license to test
* mvn clean install to format test file
* Updated Expression Patterns to allow brackets
Fixes#928
Relaxed the regular expression that is used to determine if a given
value is an Expression per the URI Template Spec RFC 6570. We already
deviated by allowing dashes to exist without pct-encoding, this change
adds braces `[]` to this list.
Also included is the ability to set Collection Format per Query, overriding
the Template default. This allows for mixed Collection formats in the
same template and provides a way for Contract extensions to determine
which expansion type they want when parsing a contract.
* Fixing Formatting
Replaced comma with Constant Delimiter in Template
Fixes#924
Commas were used to identify iterable content, which conflicted when
a comma delimited literal was provided during expansion. This change
switches commas for semi-colons, which are considered reserved secondary
delimiters in RFC 6750 and should not be used without being pct-encoded.
Should be a safer choice.
Removed decoding from Body Template Expansion
Fixes#916
In certain cases, a Body Template will contain a JSON payload. To
support this we are asking users to pct-encode the beginning and the
end of the JSON object when providing it to the RequestLine so we don't
reject it as an expression. Doing this requires that the we decode those
markers before submitting the request.
This change updates that logic to only decode the first and last characters
only and not decode the entire payload, since Body values don't require
any type of encoding.
Fixes NullPointerException when accessing a FeignException's content
Fixes#912
If the content of a FeignException is null, `contentUTF8()` now returns an empty string rather than throwing a NullPointerException.
Fixes#872
Previously, all unresolved query template expressions resolved
to empty strings, which then indcate that the entire query parameter
should be removed. This violates RFC 6570 in that only undefined
values should be removed. This change updates Query Template to
check the provided `variables` map for an entry expression. If
no value is provided, the entry is explicitly marked `UNDEF` and
removed.
This brings us in line with the specification. The following is
now how parameters are resolved:
*Empty String*
```java
public void test() {
Map<String, Object> parameters = new LinkedHashMap<>();
parameters.put("param", "");
this.demoClient.test(parameters);
}
```
Result
```
http://localhost:8080/test?param=
```
*Missing*
```java
public void test() {
Map<String, Object> parameters = new LinkedHashMap<>();
this.demoClient.test(parameters);
}
```
Result
```
http://localhost:8080/test
```
*Undefined*
```java
public void test() {
Map<String, Object> parameters = new LinkedHashMap<>();
parameters.put("param", null);
this.demoClient.test(parameters);
}
```
Result
```
http://localhost:8080/test
```
* Adding additional test case for explicit null parameter value
* Additional Test case for the explict `null` case. Updates to the
documentation.
* No Longer prepend uri with slash if it is a query string
Fixes#887
Changes to target and uri parsing did not take into account
Empty Targets or URI provided methods. In these scenarios,
the target contains the entire path and the uri will be the
query string only. This change takes that into account and
no longer prepends a slash in these cases.
* Removed unnecessary import for Spring from Target Test
* Adding URI segment specific encoding
Fixes#879
URI encoding introduced in Feign 10.x was refactored to be more in line
with URI and URI Template specifications respectively. One change was to
ensure that certain reserved characters were not encoded incorrectly.
The result was that path segment specific reserved characters were being
preserved on the query string as well. This change updates the `UriTemplate`
and `Expression` classes to recognize the segment of the URI that is being processed
and apply the segment specific encoding correctly.
One important change regarding the `+` sign. Per the URI specification, a `+` sign
is allowed in both the path and query segments of a URI, however, handling of
the symbol on the query can be inconsistent. In some legacy systems, the `+` is
equivalent to the a space. Feign takes the approach of modern systems, where a
`+` symbol should not reprsent a space and is explicitly encoded as `%2B` when
found on a query string.
If you wish to use `+` as a space, then use the literal ` ` character or encode
the value directly as `%20`
Fixes#853
There are some scenarios reported where a server does
not provide headers with the response. While this is
not typically expected, it's simple enough for Feign to
be resilient to it. This change checks the headers provided
in the builder and if none are provided, an empty map is
used in it's place.
* Add support for java 8's Optional type to represent a HTTP 404 response.
* Delete x.patch
* Also dealing with Stream in case of empty responses
* Add support for java 8's Optional type to represent a HTTP 404 response.
* Delete x.patch
* Adding Support for Query Parameter Name Expansion
Fixes#838
`QueryTemplate` assumed that all query names were literals. This change
adds support for Expressions in Query Parameter names, providing better
adherence to RFC 6570.
RequestLines such as `@RequestLine("GET /uri?{parameter}={value}")` are
now fully expanded whereas before, only `{value}` would be.
* Adding Encoding and Resolution Enums for Template Control
These new enums replace the boolean values used to control
encoding and expression expansion options in Templates
* Allow unresolved expressions in Query Parameter Name and Body Template
Expressions in Query Parameter names and in a Body Template will
now no longer be removed if they are not resolved. For Query Template,
this change will prevent invalid query name/value pairs from being
generated.
For the Body Template, the documentation states that
unresolved should be preserved, yet the code did not match.
* NPE when resolving a template with binary body
* must cast to super class Buffer otherwise break when running with java 11
* Better error message for feign mock
* Recomend using Response.Builder on MockClient