id("org.springframework.boot") version "2.3.9.RELEASE"
I need to extend MappingJackson2HttpMessageConverter and override getContentLength
- If the return type is Long?, it will not compile override fun getContentLength(obj:Any, contentType:MediaType?) : Long?
Compile error: Return type of 'getContentLength' is not a subtype of the return type of the overridden member 'protected/protected and package/ open fun getContentLength(p0: Any, @Nullable p1: MediaType?): Long defined in org.springframework.http.converter.json.MappingJackson2HttpMessageConverter'
-
If the return type is Long, it will get NullPointException at runtime. override fun getContentLength(obj:Any, contentType:MediaType?) : Long
-
In AbstractJackson2HttpMessageConverter the return is not Nullable @Override protected Long getContentLength(Object object, @Nullable MediaType contentType)
-
In AbstractHttpMessageConverter the return is Nullable @Nullable protected Long getContentLength(T t, @Nullable MediaType contentType)
Comment From: sdeleuze
Looks like AbstractJackson2HttpMessageConverter#getContentLength
nullability needs to be refined indeed, as well as ResourceHttpMessageConverter#getContentLength
one.