tags: SpringCloud gateway
Today, modify the value of the ServerWeBexchange response header in Spring Cloud Gateway, and reported the following exception:
java.lang.UnsupportedOperationException: null
at org.springframework.http.ReadOnlyHttpHeaders.add(ReadOnlyHttpHeaders.java:67) ~[spring-web-5.1.3.RELEASE.jar:5.1.3.RELEASE]
Here is that we use ReadOnlyHttpHeaders, it is only read-only. But when I went to the getHeaders () method of ServerHttpResponse, I found that httpheaders, and httpheaders can be modified; after patient thinking: ServerHttpResponse is submitted to readonlyhttpheaders instead of httpheaders, so give it The following solution:
ServerHttpResponse response = erverWebExchange.getResponse();
response.beforeCommit(() -> {
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
return Mono.empty();
});
problem Add company to add companies to fail with NRM, errorthrow new ERR_INVALID_ARG_TYPE(name, 'string', value); solve 1, mouse movingTypeErrorFourth line,(C:\Users\zhanshiyu\AppData\Roaming\npm\nod...
https://www.pythonheidong.com/blog/article/549621/2c8b4a9c107d312c12c7/ https://blog.csdn.net/zhuikefeng/article/details/107224507...
When using the collection framework encoding, you will often encounter an UnsupportedOperationException. Throws the following exception when executing to list2.add("test"): In the above code...
1. What does Arrays.asList() return? Let's look at the source code asList() returns an ArrayList, but it is not the familiar ArrayList, but the internal class Arrays$ArrayList in the Arrays class. Let...
UnsupportedOperationException occurs when this code runs Look at the source code to find the reason: the asList() method in the Arrays class It can be seen that this is a fixed size list ArrayList<...
After using the Arrays.asList() method to convert the array to a list, and adding a piece of data to the list, an UnsupportedOperationException will be reported. The reason is:...
I want to be lazy in the development, and there will be problems in a slight accident, such as this Sao: Abnormal is as follows: Why is this this, look at the source code is very clear: Arrays.aslist ...
Because Method adds @Transactional (readonly = true), build MAP or LIST can't use map.of or list.of, otherwise it will be reported. This is because this way is generated in ImmutableMap or ImmutableLi...