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)
id("org.springframework.boot") version "2.3.9.RELEASE"
I need to extend MappingJackson2HttpMessageConverter and override getContentLength
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)