private void initRestTemplate ( ) { boolean isContainsConverter = false ; for ( HttpMessageConverter < ? > httpMessageConverter : this . restTemplate . getMessageConverters ( ) ) { if ( MappingJacksonRPC2HttpMessageConverter . class . isAssignableFrom ( httpMessageConverter . getClass ( ) ) ) { isContainsConverter = true ; break ; } } if ( ! isContainsConverter ) { final MappingJacksonRPC2HttpMessageConverter messageConverter = new MappingJacksonRPC2HttpMessageConverter ( ) ; messageConverter . setObjectMapper ( this . getObjectMapper ( ) ) ; final List < HttpMessageConverter < ? > > restMessageConverters = new ArrayList <> ( ) ; restMessageConverters . addAll ( this . restTemplate . getMessageConverters ( ) ) ; // Place JSON-RPC converter on the first place! restMessageConverters . add ( 0 , messageConverter ) ; this . restTemplate . setMessageConverters ( restMessageConverters ) ; } // use specific JSON-RPC error handler if it has not been changed to custom if ( restTemplate . getErrorHandler ( ) instanceof org . springframework . web . client . DefaultResponseErrorHandler ) { restTemplate . setErrorHandler ( JsonRpcResponseErrorHandler . INSTANCE ) ; } }
Check RestTemplate contains required converters