Affects: 5.0.16.RELEASE
Hi, We're occasionally getting an NPE when using RestTemplate.postForEntity method.
• java.lang.NullPointerException: while trying to invoke the method org.springframework.http.converter.HttpMessageConverter.canRead(java.lang.Class, org.springframework.http.MediaType) of a null object loaded from local variable 'converter'
• at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.canReadResponse(RestTemplate.java:816)
• at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.lambda$doWithRequest$0(RestTemplate.java:801)
• at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
• at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
• at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
• at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
• at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
• at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
• at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
• at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.doWithRequest(RestTemplate.java:805)
• at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:865)
• at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:687)
• at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:646)
• at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:432)
We have not been able to reproduce this issue voluntarily until now. From the looks of it, one of the message converters in the list is null. We are NOT manually editing the list. And we're relying on spring framework's default list of converters.
Whenever this issue happens, we need to restart the server and the issue goes away. And then randomly comes back a few days/weeks down the line.
Anyone else faced such an issue?
Comment From: bclozel
Given this issue did not get much traction, we'll close it for now and reopen it if we get a sample reproducing this problem.