Is it possible to set RetryPolicy in spring-retry based on HttpStatus status 200 or 207? - spring-retry

I am doing a batch call where overall response is success from batch API but some calls of batch might be failure so event if rest-Template provide successful response i want to parse the response and if i find an error status Code while parsing i want to retry whole batch call again. The problem is spring retry is not detecting any exception from rest-Template so its not doing retry.
ResponseEntity response = restTemplate.exchange(requestEntity, String.class);
here response is 200 so no retry by spring but what i want is to parse this String response and check if i have any 500 in my response if yes i want to retry this call.

You would need to implement a custom RetryPolicy.

Related

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.

How to log Spring WebClient response

I'm new to Spring WebClient. Can someone advise the best way to log REST request and response from another webservice?
I've already seen an example of logging request within the question but also have to log a response and a request for a POST call.
how to log Spring 5 WebClient call
Thank you.
One option is to use the onStatus function. The advantage is that you can react differently on different status codes:
.onStatus(HttpStatus::is4xxClientError, res -> {
res.toEntity(String.class).subscribe(
entity -> log.warn("Client error {}", entity)
);
return Mono.error(new HttpClientErrorException(res.statusCode()));}
)
But be aware that this will log asynchronously, that means it might log after you already logged something different. I'm using this way right now but I know it is not perfect, so I will be happy to see better suggestions.

One way request, no response

Normally JMeter sends a HTTP request and waits for a response to measure the response time and then to send a next request.
I have a situation where they have created a HTTP endpoint to an embedded software device. But it is one way traffic only, which means I send a HTTP request, but the embedded device doesn't send a response. This is the intention and how it should work.
Is it possible that JMeter doesn't wait for the response and just sends a next request?
A way to do it is to set a Response timeout on the HTTP Request and add an assertion to ignore response timeout.
1 second for response timeout in HTTP Request:
And adding a Response Assertion that ignores status and expects a Timeout:
But this is not very clean.

If Loadtime in HTTP request is longer than 10000, what's throws an exception automatically?

If Loadtime in HTTP request is longer than 10000 ms, what's throws an exception automatically? using JMeter.
Response code: Non HTTP response code: org.apache.http.NoHttpResponseException
Response message: Non HTTP response message: failed to respond
But all requests are executed correctly in the application, only, their responses are above 10000 ms.
I modify the "Timeouts" into the HTTP request sampler.
Actually I test with 3.0 version, but also I've tested with 2.13 version
Could I do disable this automate check? Or modify the threshold with a major value (i.e: 500000)?

How to filter Request Response before reaching to Web Api controller

Hi I am working with Web Api 2, is their any way I can handle request and response before reaching to the API controller.
You may be looking for a DelegatingHandler. These are HTTP Message Handlers that can process the request before it reaches the Controller and can also process the response on the way out of the pipeline. Delegating Handlers can also return the response themselves without calling the rest of the pipeline. You can read about Delegating Handlers here.

Resources