How to handle "Pooled connection observed an error" in Spring Webflux? - spring

I am using Webflux to make a Flux of concurrent requests via proxy to a web server. Depending on the proxy, sometimes the connection fails. I would like to catch these errors and handle them (ideally by returning an empty Mono object)
2019-02-17 16:48:19.947 ERROR 32265 --- [or-http-epoll-8] r.n.resources.PooledConnectionProvider : [id: 0xf7c8834b, L:/192.168.2.247:45536 - R:101.248.64.72/101.248.64.72:80] Pooled connection observed an error
io.netty.handler.proxy.ProxyConnectException: http, none, /101.248.64.72:80 => domain.com:443, io.netty.channel.unix.Errors$NativeIoException: syscall:read(..) failed: Connection reset by peer
at io.netty.handler.proxy.ProxyHandler.setConnectFailure(ProxyHandler.java:344) [netty-handler-proxy-4.1.31.Final.jar:4.1.31.Final]
at io.netty.handler.proxy.ProxyHandler.exceptionCaught(ProxyHandler.java:246) [netty-handler-proxy-4.1.31.Final.jar:4.1.31.Final]
These messages are very long and make the log unreadable later on if debugging is required. I've tried catching it in line with the request code by using .onErrorResume(err -> Mono.empty()) but it doesn't seem to prevent the error logs.
Below is my code:
return proxiedWebClient
.get()
.uri(uri)
.exchange()
.flatMap(clientResponse -> clientResponse.toEntity(String.class))
.onErrorResume(error -> Mono.empty());
The expected result is that connection errors are simply dropped and not added into the Flux when Flux.merge is subsequently called.

Related

Reading HTTP Response When Request Isn't Fully Sent

If I send a large POST request using OkHttp, but the server responds quickly with an error (e.g. permission denied) I get a
java.net.SocketException: Broken pipe (Write failed)( status = 272 )
exception.
Command line tools like curl seem to handle this case just fine and are able to return the HTTP Response instead of aborting because the write failed.
Is there a way to configure OkHttp to do the same?

Error during WebSocket handshake: Incorrect 'Sec-WebSocket-Accept' header value

I have a spring-boot websocket connection which sits behind spring-security-kerberos to achieve SSO. This works as expected but if I restart the server I see clients fail to re-connect with the error Error during WebSocket handshake: Incorrect 'Sec-WebSocket-Accept' header value.
I am using #stomp/stompjs 4.0.8 and setting stompClient.reconnect_delay = 5000
Is there any way to solve this? I am concerned that running this behind a load balancer would cause this error to occur all the time.
This is based on the messaging-stomp-websocket example + spring-security websocket-authentication
It appears that spring-security-web RequestCacheAwareFilter extracts a cached request which results in the actual Sec-WebSocket-Key header value being replaced with an invalid one.
The sequence of events is that each time the client attempts a re-connect the client makes two websocket requests, the first is rejected with a WWW-Authenticate: Negotiate header and the second which contains a Authorization header has a different Sec-WebSocket-Key value.
I was able to resolve this by disabling caching completely, e.g. within a WebSecurityConfigurerAdapter
#Override
protected void configure(final HttpSecurity http) throws Exception {
http.requestCache().requestCache(new NullRequestCache())
}

Spring Exception Handler returns partial response - maybe bug?

I am using spring boot 2.0.4 to build a REST interface.
Iam using ExceptionHandler to handle errors.
Problem:
When an Exception was raised while serialization a JsonMappingException is thrown by jackson. This exception I handle with a default exception Handler (catching all Exceptions).
#ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
#ResponseBody
#ExceptionHandler(Throwable.class)
public String handleThrowable(final Throwable throwable) {
return "SERVER ERROR";
}
Now I the have the strange behavior when I returning a large list of Objects, and one fails because of an RuntimeException, I do not get a 500 back. But I get a 200 with the first serialized objects and then the error message.
Example:
I have prepared a fully working example of the problem:
https://github.com/stefan0001/spring-exception-test/tree/master/src/main/java/test
When calling:
GET http://localhost:8080/test
Expected Result:
Status: 500
Body: SERVER ERROR
Actual Result:
Status: 200
Body:
[{"name":"0","throwException":false,"foo":"bar"},{"name":"1","throwException":false,"foo":"bar"},{"name":"2","throwException":false,"foo":"bar"},{"name":"3","throwException":false,"foo":"bar"},{"name":"4","throwException":false,"foo":"bar"},{"name":"5","throwException":false,"foo":"bar"},{"name":"6","throwException":false,"foo":"bar"},{"name":"7","throwException":false,"foo":"bar"},{"name":"8","throwException":false,"foo":"bar"},{"name":"9","throwException":false,"foo":"bar"},{"name":"10","throwException":false,"foo":"bar"},{"name":"11","throwException":false,"foo":"bar"},{"name":"12","throwException":false,"foo":"bar"},{"name":"13","throwException":false,"foo":"bar"},{"name":"14","throwException":false,"foo":"bar"},{"name":"15","throwException":false,"foo":"bar"},{"name":"16","throwException":false,"foo":"bar"},{"name":"17","throwException":false,"foo":"bar"},{"name":"18","throwException":false,"foo":"bar"},{"name":"19","throwException":false,"foo":"bar"},{"name":"20","throwException":false,"foo":"bar"},{"name":"21","throwException":false,"foo":"bar"},{"name":"22","throwException":false,"foo":"bar"},{"name":"23","throwException":false,"foo":"bar"},{"name":"24","throwException":false,"foo":"bar"},{"name":"25","throwException":false,"foo":"bar"},{"name":"26","throwException":false,"foo":"bar"},{"name":"27","throwException":false,"foo":"bar"},{"name":"28","throwException":false,"foo":"bar"},{"name":"29","throwException":false,"foo":"bar"},{"name":"30","throwException":false,"foo":"bar"},{"name":"31","throwException":false,"foo":"bar"},{"name":"32","throwException":false,"foo":"bar"},{"name":"33","throwException":false,"foo":"bar"},{"name":"34","throwException":false,"foo":"bar"},{"name":"35","throwException":false,"foo":"bar"},{"name":"36","throwException":false,"foo":"bar"},{"name":"37","throwException":false,"foo":"bar"},{"name":"38","throwException":false,"foo":"bar"},{"name":"39","throwException":false,"foo":"bar"},{"name":"40","throwException":false,"foo":"bar"},{"name":"41","throwException":false,"foo":"bar"},{"name":"42","throwException":false,"foo":"bar"},{"name":"43","throwException":false,"foo":"bar"},{"name":"44","throwException":false,"foo":"bar"},{"name":"45","throwException":false,"foo":"bar"},{"name":"46","throwException":false,"foo":"bar"},{"name":"47","throwException":false,"foo":"bar"},{"name":"48","throwException":false,"foo":"bar"},{"name":"49","throwException":false,"foo":"bar"},{"name":"50","throwException":false,"foo":"bar"},{"name":"51","throwException":false,"foo":"bar"},{"name":"52","throwException":false,"foo":"bar"},{"name":"53","throwException":false,"foo":"bar"},{"name":"54","throwException":false,"foo":"bar"},{"name":"55","throwException":false,"foo":"bar"},{"name":"56","throwException":false,"foo":"bar"},{"name":"57","throwException":false,"foo":"bar"},{"name":"58","throwException":false,"foo":"bar"},{"name":"59","throwException":false,"foo":"bar"},{"name":"60","throwException":false,"foo":"bar"},{"name":"61","throwException":false,"foo":"bar"},{"name":"62","throwException":false,"foo":"bar"},{"name":"63","throwException":false,"foo":"bar"},{"name":"64","throwException":false,"foo":"bar"},{"name":"65","throwException":false,"foo":"bar"},{"name":"66","throwException":false,"foo":"bar"},{"name":"67","throwException":false,"foo":"bar"},{"name":"68","throwException":false,"foo":"bar"},{"name":"69","throwException":false,"foo":"bar"},{"name":"70","throwException":false,"foo":"bar"},{"name":"71","throwException":false,"foo":"bar"},{"name":"72","throwException":false,"foo":"bar"},{"name":"73","throwException":false,"foo":"bar"},{"name":"74","throwException":false,"foo":"bar"},{"name":"75","throwException":false,"foo":"bar"},{"name":"76","throwException":false,"foo":"bar"},{"name":"77","throwException":false,"foo":"bar"},{"name":"78","throwException":false,"foo":"bar"},{"name":"79","throwException":false,"foo":"bar"},{"name":"80","throwException":false,"foo":"bar"},{"name":"81","throwException":false,"foo":"bar"},{"name":"82","throwException":false,"foo":"bar"},{"name":"83","throwException":false,"foo":"bar"},{"name":"84","throwException":false,"foo":"bar"},{"name":"85","throwException":false,"foo":"bar"},{"name":"86","throwException":false,"foo":"bar"},{"name":"87","throwException":false,"foo":"bar"},{"name":"88","throwException":false,"foo":"bar"},{"name":"89","throwException":false,"foo":"bar"},{"name":"90","throwException":false,"foo":"bar"},{"name":"91","throwException":false,"foo":"bar"},{"name":"92","throwException":false,"foo":"bar"},{"name":"93","throwException":false,"foo":"bar"},{"name":"94","throwException":false,"foo":"bar"},{"name":"95","throwException":false,"foo":"bar"},{"name":"96","throwException":false,"foo":"bar"},{"name":"97","throwException":false,"foo":"bar"},{"name":"98","throwException":false,"foo":"bar"},{"name":"99","throwException":false,"foo":"bar"},{"name":"100","throwException":false,"foo":"bar"},{"name":"101","throwException":false,"foo":"bar"},{"name":"102","throwException":false,"foo":"bar"},{"name":"103","throwException":false,"foo":"bar"},{"name":"104","throwException":false,"foo":"bar"},{"name":"105","throwException":false,"foo":"bar"},{"name":"106","throwException":false,"foo":"bar"},{"name":"107","throwException":false,"foo":"bar"},{"name":"108","throwException":false,"foo":"bar"},{"name":"109","throwException":false,"foo":"bar"},{"name":"110","throwException":false,"foo":"bar"},{"name":"111","throwException":false,"foo":"bar"},{"name":"112","throwException":false,"foo":"bar"},{"name":"113","throwException":false,"foo":"bar"},{"name":"114","throwException":false,"foo":"bar"},{"name":"115","throwException":false,"foo":"bar"},{"name":"116","throwException":false,"foo":"bar"},{"name":"117","throwException":false,"foo":"bar"},{"name":"118","throwException":false,"foo":"bar"},{"name":"119","throwException":false,"foo":"bar"},{"name":"120","throwException":false,"foo":"bar"},{"name":"121","throwException":false,"foo":"bar"},{"name":"122","throwException":false,"foo":"bar"},{"name":"123","throwException":false,"foo":"bar"},{"name":"124","throwException":false,"foo":"bar"},{"name":"125","throwException":false,"foo":"bar"},{"name":"126","throwException":false,"foo":"bar"},{"name":"127","throwException":false,"foo":"bar"},{"name":"128","throwException":false,"foo":"bar"},{"name":"129","throwException":false,"foo":"bar"},{"name":"130","throwException":false,"foo":"bar"},{"name":"131","throwException":false,"foo":"bar"},{"name":"132","throwException":false,"foo":"bar"},{"name":"133","throwException":false,"foo":"bar"},{"name":"134","throwException":false,"foo":"bar"},{"name":"135","throwException":false,"foo":"bar"},{"name":"136","throwException":false,"foo":"bar"},{"name":"137","throwException":false,"foo":"bar"},{"name":"138","throwException":false,"foo":"bar"},{"name":"139","throwException":false,"foo":"bar"},{"name":"140","throwException":false,"foo":"bar"},{"name":"141","throwException":false,"foo":"bar"},{"name":"142","throwException":false,"foo":"bar"},{"name":"143","throwException":false,"foo":"bar"},{"name":"144","throwException":false,"foo":"bar"},{"name":"145","throwException":false,"foo":"bar"},{"name":"146","throwException":false,"foo":"bar"},{"name":"147","throwException":false,"foo":"bar"},{"name":"148","throwException":false,"foo":"bar"},{"name":"149","throwException":false,"foo":"bar"},{"name":"150","throwException":false,"foo":"bar"},{"name":"151","throwException":false,"foo":"bar"},{"name":"152","throwException":false,"foo":"bar"},{"name":"153","throwException":false,"foo":"bar"},{"name":"154","throwException":false,"foo":"bar"},{"name":"155","throwException":false,"foo":"bar"},{"name":"156","throwException":false,"foo":"bar"},{"name":"157","throwException":false,"foo":"bar"},{"name":"158","throwException":false,"foo":"bar"},{"name":"159","throwException":false,"foo":"bar"},{"name":"160","throwException":false,"foo":"bar"},{"name":"161","throwException":false,"foo":"bar"},{"name":"162","throwException":false,"foo":"bar"},{"name":"163","throwException":false,"foo":"bar"},{"name":"164","throwException":false,"foo":"bar"},{"name":"165","throwException":false,"foo":"bar"},{"name":"166","throwException":false,"foo":"bar"},{"name":"167","throwException":false,"foo":"bar"},{"name":"168","throwException":false,"foo":"bar"},{"name":"169","throwException":false,"foo":"bar"},{"name":"170","throwException":false,"foo":"bar"},{"name":"171","throwException":false,"foo":"bar"},{"name":"172","throwException":false,"foo":"bar"},{"name":"173","throwException":false,"foo":"bar"},{"name":"174","throwException":false,"foo":"bar"},{"name":"175","throwException":false,"foo":"bar"},{"name":"176","throwException":false,"foo":"bar"},{"name":"177","throwException":false,"foo":"bar"},{"name":"178","throwException":false,"foo":"bar"},{"name":"179","throwException":false,"foo":"bar"},{"name":"180","throwException":false,"foo":"bar"},{"name":"181","throwException":false,"foo":"bar"},{"name":"182","throwException":false,"foo":"bar"},{"name":"183","throwException":false,"foo":"bar"},{"name":"184","throwException":false,"foo":"bar"},{"name":"185","throwException":false,"foo":"bar"},{"name":"186","throwException":false,"foo":"bar"},{"name":"187","throwException":false,"foo":"bar"},{"name":"188","throwException":false,"foo":"bar"},{"name":"189","throwException":false,"foo":"bar"},{"name":"190","throwException":false,"foo":"bar"},{"name":"191","throwException":false,"foo":"bar"},{"name":"192","throwException":false,"foo":"bar"},{"name":"193","throwException":false,"foo":"bar"},{"name":"194","throwException":false,"foo":"bar"},{"name":"195","throwException":false,"foo":"bar"},{"name":"196","throwException":false,"foo":"bar"},{"name":"197","throwException":false,"foo":"bar"},{"name":"198","throwException":false,"foo":"bar"},{"name":"199","throwException":false,"foo":"bar"},{"name":"200","throwException":false,"foo":"bar"},{"name":"201","throwException":false,"foo":"bar"},{"name":"202","throwException":false,"foo":"bar"},{"name":"203","throwException":false,"foo":"bar"},{"name":"204","throwException":false,"foo":"bar"},{"name":"205","throwException":false,"foo":"bar"},{"name":"206","throwException":false,"foo":"bar"},{"name":"207","throwException":false,"foo":"bar"},{"name":"208","throwException":false,"foo":"bar"},{"name":"209","throwException":false,"foo":"bar"},{"name":"210","throwException":false,"foo":"bar"},{"name":"211","throwException":false,"foo":"bar"},{"name":"212","throwException":false,"foo":"bar"},{"name":"213","throwException":false,"foo":"bar"},{"name":"214","throwException":false,"foo":"bar"},{"name":"215","throwException":false,"foo":"bar"},{"name":"216","throwException":false,"foo":"bar"},{"name":"217","throwException":false,"foo":"bar"},{"name":"218","throwException":false,"foo":"bar"},{"name":"219","throwException":false,"foo":"bar"},{"name":"220","throwException":false,"foo":"bar"},{"name":"221","throwException":false,"foo":"bar"},{"name":"222","throwException":false,"foo":"bar"},{"name":"223","throwException":false,"foo":"bar"},{"name":"224","throwException":false,"foo":"bar"},{"name":"225","throwException":false,"foo":"bar"},{"name":"226","throwException":false,"foo":"bar"},{"name":"227","throwException":false,"foo":"bar"},{"name":"228","throwException":false,"foo":"bar"},{"name":"229","throwException":false,"foo":"bar"},{"name":"230","throwException":false,"foo":"bar"},{"name":"231","throwException":false,"foo":"bar"},{"name":"232","throwException":false,"foo":"bar"},{"name":"233","throwException":false,"foo":"bar"},{"name":"234","throwException":false,"foo":"bar"},{"name":"235","throwException":false,"foo":"bar"},{"name":"236","throwException":false,"foo":"bar"},{"name":"237","throwException":false,"foo":"bar"},{"name":"238","throwException":false,"foo":"bar"},{"name":"239","throwException":false,"foo":"bar"},{"name":"240","throwException":false,"foo":"bar"},{"name":"241","throwException":false,"foo":"bar"},{"name":"242","throwException":false,"foo":"bar"},{"name":"243","throwException":false,"foo":"bar"},{"name":"244","throwException":false,"foo":"bar"},{"name":"245","throwException":false,"foo":"bar"},{"name":"246","throwException":false,"foo":"bar"},{"name":"247","throwException":false,"foo":"bar"},{"name":"248","throwException":false,"foo":"bar"},{"name":"249","throwException":false,"foo":"bar"},{"name":"250","throwException":false,"foo":"bar"},{"name":"251","throwException":false,"foo":"bar"},{"name":"252","throwException":false,"foo":"bar"},{"name":"253","throwException":false,"foo":"bar"},{"name":"254","throwException":false,"foo":"bar"},{"name":"255","throwException":false,"foo":"bar"},{"name":"256","throwException":false,"foo":"bar"},{"name":"257","throwException":false,"foo":"bar"},{"name":"258","throwException":false,"foo":"bar"},{"name":"259","throwException":false,"foo":"bar"},{"name":"260","throwException":false,"foo":"bar"},{"name":"261","throwException":false,"foo":"bar"},{"name":"262","throwException":false,"foo":"bar"},{"name":"263","throwException":false,"foo":"bar"},{"name":"264","throwException":false,"foo":"bar"},{"name":"265","throwException":false,"foo":"bar"},{"name":"266","throwException":false,"foo":"bar"},{"name":"267","throwException":false,"foo":"bar"},{"name":"268","throwException":false,"foo":"bar"},{"name":"269","throwException":false,"foo":"bar"},{"name":"270","throwException":false,"foo":"bar"},{"name":"271","throwException":false,"foo":"bar"},{"name":"272","throwException":false,"foo":"bar"},{"name":"273","throwException":false,"foo":"bar"},{"name":"274","throwException":false,"foo":"bar"},{"name":"275","throwException":false,"foo":"bar"},{"name":"276","throwException":false,"foo":"bar"},{"name":"277","throwException":false,"foo":"bar"},{"name":"278","throwException":false,"foo":"bar"},{"name":"279","throwException":false,"foo":"bar"},{"name":"280","throwException":false,"foo":"bar"},{"name":"281","throwException":false,"foo":"bar"},{"name":"282","throwException":false,"foo":"bar"},{"name":"283","throwException":false,"foo":"bar"},{"name":"284","throwException":false,"foo":"bar"},{"name":"285","throwException":false,"foo":"bar"},{"name":"286","throwException":false,"foo":"bar"},{"name":"287","throwException":false,"foo":"bar"},{"name":"288","throwException":false,"foo":"bar"},{"name":"289","throwException":false,"foo":"bar"},{"name":"290","throwException":false,"foo":"bar"},{"name":"291","throwException":false,"foo":"bar"},{"name":"292","throwException":false,"foo":"bar"},{"name":"293","throwException":false,"foo":"bar"},{"name":"294","throwException":false,"foo":"bar"},{"name":"295","throwException":false,"foo":"bar"},{"name":"296","throwException":false,"foo":"bar"},{"name":"297","throwException":false,"foo":"bar"},{"name":"298","throwException":false,"foo":"bar"},{"name":"299","throwException":false,"foo":"bar"},{"name":"300","throwException":false,"foo":"bar"},{"name":"301","throwException":false,"foo":"bar"},{"name":"302","throwException":false,"foo":"bar"},{"name":"303","throwException":false,"foo":"bar"},{"name":"304","throwException":false,"foo":"bar"},{"name":"305","throwException":false,"foo":"bar"},{"name":"306","throwException":false,"foo":"bar"},{"name":"307","throwException":false,"foo":"bar"},{"name":"308","throwException":false,"foo":"bar"},{"name":"309","throwException":false,"foo":"bar"},{"name":"310","throwException":false,"foo":"bar"},{"name":"311","throwException":false,"foo":"bar"},{"name":"312","throwException":false,"foo":"bar"},{"name":"313","throwException":false,"foo":"bar"},{"name":"314","throwException":false,"foo":"bar"},{"name":"315","throwException":false,"foo":"bar"},{"name":"316","throwException":false,"foo":"bar"},{"name":"317","throwException":false,"foo":"bar"},{"name":"318","throwException":false,"foo":"bar"},{"name":"319","throwException":false,"foo":"bar"},{"name":"320","throwException":false,"foo":"bar"},{"name":"321","throwException":false,"foo":"bar"},{"name":"322","throwException":false,"foo":"bar"},{"name":"323","throwException":false,"foo":"bar"},{"name":"324","throwException":false,"foo":"bar"},{"name":"325","throwException":false,"foo":"bar"},{"name":"326","throwException":false,"foo":"bar"},{"name":"327","throwException":false,"foo":"bar"},{"name":"328","throwException":false,"foo":"bar"},{"name":"329","throwException":false,"foo":"bar"},{"name":"330","throwException":false,"foo":"bar"},{"name":"331","throwException":false,"foo":"bar"},{"name":"332","throwException":false,"foo":"bar"},{"name":"333","throwException":false,"foo":"bar"},{"name":"334","throwException":false,"foo":"bar"},{"name":"335","throwException":false,"foo":"bar"},{"name":"336","throwException":false,"foo":"bar"},{"name":"337","throwException":false,"foo":"bar"},{"name":"338","throwException":false,"foo":"bar"},{"name":"339","throwException":false,"foo":"bar"},{"name":"340","throwException":false,"foo":"bar"},{"name":"341","throwException":false,"foo":"bar"},{"name":"342","throwException":false,"foo":"bar"},{"name":"343","throwException":false,"foo":"bar"},{"name":"344","throwException":false,"foo":"bar"},{"name":"345","throwException":false,"foo":"bar"},{"name":"346","throwException":false,"foo":"bar"},{"name":"347","throwException":false,"foo":"bar"},{"name":"348","throwException":false,"foo":"bar"},{"name":"349","throwException":false,"foo":"bar"},{"name":"350","throwException":false,"foo":"bar"},{"name":"351","throwException":false,"foo":"bar"},{"name":"352","throwException":false,"foo":"bar"},{"name":"353","throwException":false,"foo":"bar"},{"name":"354","throwException":false,"foo":"bar"},{"name":"355","throwException":false,"foo":"bar"},{"name":"356","throwException":false,"foo":"bar"},{"name":"357","throwException":false,"foo":"bar"},{"name":"358","throwException":false,"foo":"bar"},{"name":"359","throwException":false,"foo":"bar"},{"name":"360","throwException":false,"foo":"bar"},{"name":"361","throwException":false,"foo":"bar"},{"name":"362","throwException":false,"foo":"bar"},{"name":"363","throwException":false,"foo":"bar"},{"name":"364","throwException":false,"foo":"bar"},{"name":"365","throwException":false,"foo":"bar"},{"name":"366","throwException":false,"foo":"bar"},{"name":"367","throwException":false,"foo":"bar"},{"name":"368","throwException":false,"foo":"bar"},{"name":"369","throwException":false,"foo":"bar"},{"name":"370","throwException":false,"foo":"bar"},{"name":"371","throwException":false,"foo":"bar"},{"name":"372","throwException":false,"foo":"bar"},{"name":"373","throwException":false,"foo":"bar"},{"name":"374","throwException":false,"foo":"bar"},{"name":"375","throwException":false,"foo":"bar"},{"name":"376","throwException":false,"foo":"bar"},{"name":"377","throwException":false,"foo":"bar"},{"name":"378","throwException":false,"foo":"bar"},{"name":"379","throwException":false,"foo":"bar"},{"name":"380","throwException":false,"foo":"bar"},{"name":"381","throwException":false,"foo":"bar"},{"name":"382","throwException":false,"foo":"bar"},{"name":"383","throwException":false,"foo":"bar"},{"name":"384","throwException":false,"foo":"bar"},{"name":"385","throwException":false,"foo":"bar"},{"name":"386","throwException":false,"foo":"bar"},{"name":"387","throwException":false,"foo":"bar"},{"name":"388","throwException":false,"foo":"bar"},{"name":"389","throwException":false,"foo":"bar"},{"name":"390","throwException":false,"foo":"bar"},{"name":"391","throwException":false,"foo":"bar"},{"name":"392","throwException":false,"foo":"bar"},{"name":"393","throwException":false,"foo":"bar"},{"name":"394","throwException":false,"foo":"bar"},{"name":"395","throwException":false,"foo":"bar"},{"name":"396","throwException":false,"foo":"bar"},{"name":"397","throwException":false,"foo":"bar"},{"name":"398","throwException":false,"foo":"bar"},{"name":"399","throwException":false,"foo":"bar"},{"name":"400","throwException":false,"foo":"bar"},{"name":"401","throwException":false,"foo":"bar"},{"name":"402","throwException":false,"foo":"bar"},{"name":"403","throwException":false,"foo":"bar"},{"name":"404","throwException":false,"foo":"bar"},{"name":"405","throwException":false,"foo":"bar"},{"name":"406","throwException":false,"foo":"bar"},{"name":"407","throwException":false,"foo":"bar"},{"name":"408","throwException":false,"foo":"bar"},{"name":"409","throwException":false,"foo":"bar"},{"name":"410","throwException":false,"foo":"bar"},{"name":"411","throwException":false,"foo":"bar"},{"name":"412","throwException":false,"foo":"bar"},{"name":"413","throwException":false,"foo":"bar"},{"name":"414","throwException":false,"foo":"bar"},{"name":"415","throwException":false,"foo":"bar"},{"name":"416","throwException":false,"foo":"bar"},{"name":"417","throwException":false,"foo":"bar"},{"name":"418","throwException":false,"foo":"bar"},{"name":"419","throwException":false,"foo":"bar"},{"name":"420","throwException":false,"foo":"bar"},{"name":"421","throwException":false,"foo":"bar"},{"name":"422","throwException":false,"foo":"bar"},{"name":"423","throwException":false,"foo":"bar"},{"name":"424","throwException":false,"foo":"bar"},{"name":"425","throwException":false,"foo":"bar"},{"name":"426","throwException":false,"foo":"bar"},{"name":"427","throwException":false,"foo":"bar"},{"name":"428","throwException":false,"foo":"bar"},{"name":"429","throwException":false,"foo":"bar"},{"name":"430","throwException":false,"foo":"bar"},{"name":"431","throwException":false,"foo":"bar"},{"name":"432","throwException":false,"foo":"bar"},{"name":"433","throwException":false,"foo":"bar"},{"name":"434","throwException":false,"foo":"bar"},{"name":"435","throwException":false,"foo":"bar"},{"name":"436","throwException":false,"foo":"bar"},{"name":"437","throwException":false,"foo":"bar"},{"name":"438","throwException":false,"foo":"bar"},{"name":"439","throwException":false,"foo":"bar"},{"name":"440","throwException":false,"foo":"bar"},{"name":"441","throwException":false,"foo":"bar"},{"name":"442","throwException":false,"foo":"bar"},{"name":"443","throwException":false,"foo":"bar"},{"name":"444","throwException":false,"foo":"bar"},{"name":"445","throwException":false,"foo":"bar"},{"name":"446","throwException":false,"foo":"bar"},{"name":"447","throwException":false,"foo":"bar"},{"name":"448","throwException":false,"foo":"bar"},{"name":"449","throwException":false,"foo":"bar"},{"name":"450","throwException":false,"foo":"bar"},{"name":"451","throwException":false,"foo":"bar"},{"name":"452","throwException":false,"foo":"bar"},{"name":"453","throwException":false,"foo":"bar"},{"name":"454","throwException":false,"foo":"bar"},{"name":"455","throwException":false,"foo":"bar"},{"name":"456","throwException":false,"foo":"bar"},{"name":"457","throwException":false,"foo":"bar"},{"name":"458","throwException":false,"foo":"bar"},{"name":"459","throwException":false,"foo":"bar"},{"name":"460","throwException":false,"foo":"bar"},{"name":"461","throwException":false,"foo":"bar"},{"name":"462","throwException":false,"foo":"bar"},{"name":"463","throwException":false,"foo":"bar"},{"name":"464","throwException":false,"foo":"bar"},{"name":"465","throwException":false,"foo":"bar"},{"name":"466","throwException":false,"foo":"bar"},{"name":"467","throwException":false,"foo":"bar"},{"name":"468","throwException":false,"foo":"bar"},{"name":"469","throwException":false,"foo":"bar"},{"name":"470","throwException":false,"foo":"bar"},{"name":"471","throwException":false,"foo":"bar"},{"name":"472","throwException":false,"foo":"bar"},{"name":"473","throwException":false,"foo":"bar"},{"name":"474","throwException":false,"foo":"bar"},{"name":"475","throwException":false,"foo":"bar"},{"name":"476","throwException":false,"foo":"bar"},{"name":"477","throwException":false,"foo":"bar"},{"name":"478","throwException":false,"foo":"bar"},{"name":"479","throwException":false,"foo":"bar"},{"name":"480","throwException":false,"foo":"bar"},{"name":"481","throwException":false,"foo":"bar"},{"name":SERVER ERROR
Look at the SERVER ERROR at the end of the response body.
I don't know if it is bug or intentionally.
Looks like the response was allready written or something like that...
References:
SPRING JIRA ISSUE
GITHUB EXAMPLE
Once the HTTP response has been committed, there's no way to change the HTTP status or headers. At that point, that response might be sitting in network buffers or even been sent already to the client. At that point, there's no way to take it back.
So in this case, Spring cannot change the response.
From the client's point of view, if the response is not complete (its length reflects the Content-Length header, for example), then the RFC says the client should close the connection and consider the response incomplete.

Spring what is between Controller and Interceptor

I have a controller that is doing something, everything seems fine, it logs a success, and then it does this
return new ResponseEntity<>(resp, HttpStatus.OK);
Seems like it should send a 200 OK.
Well, I also have a HandlerInterceptorAdapter with an "afterCompletion" that logs the status:
logger.debug("Response status: {}, URI: {}", response.getStatus(), request.getRequestURI());
This is showing a 500 where there was a success from the controller.
In the stdout logs I see an error
2018-01-12 12:33:59.035 ERROR 18952 --- [pr-8080-exec-14] o.s.boot.web.support.ErrorPageFilter : Cannot forward to error page for request [/ws/path] as the response has already been committed.
As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
and
org.apache.catalina.connector.ClientAbortException: java.io.IOException: APR error: -32
I can't find any doc on what that APR error is and I have no idea why the status code would be wrong. I am using tomcat 8.5.
So. APR -32 is a "Client Abort" error. The client was timing out in waiting. It looks like what was happening was the client made a request and was sitting in queue for a few seconds. It has a short hard timeout limit. The client timed out before the server got to the request. Then the server picked up the request and did everything fine but when trying to write back to the client, it found the socket closed. So it set a 500 and threw that exception.

Opa session error

I've got the following error with my opa application :
[SESSION] Uncaught exception: "{OpaRPC_Server: {timeout: {client: {client: $"s2jtpj3tbyztpfbrm3gf8bd2k7kcnxg1"$; page: $
896774575$}; fun_id: $"_v0_get_value_stdlib.core.xhtml"$}}}"
The following message is skipped.:
If you want (msg, st, ctx) debug printing set debug variable session_debug >= 200C
What does it mean ?
That means two things you have a server sessions which calls a client function, but the client doesn't reply to the server.
1 - When a client doesn't reply to the server, the client calls raise an Opa exception "OpaRPC_Server" after a timeout.
That can happen in several cases (client runtime error, client leaves the application, etc.).
In your case the server try to call the client function identified by "_v0_get_value_stdlib.core.xhtml" (Dom.get_value?)
2 - When an exception is not catch on a session handler, the session catch the exception, throw the current message and the session is released to process future messages.
Be aware that when you make (a standard) session, the message handler is a critical section.

Resources