Fix RestOperations extensions parameters nullability
Issue: SPR-16328
This commit is contained in:
		
							parent
							
								
									deac8e556e
								
							
						
					
					
						commit
						d2616b7996
					
				| 
						 | 
					@ -115,7 +115,8 @@ inline fun <reified T: Any> RestOperations.getForEntity(url: String, uriVariable
 | 
				
			||||||
 * @since 5.0.2
 | 
					 * @since 5.0.2
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.patchForObject(url: String, request: Any, vararg uriVariables: Any): T? =
 | 
					inline fun <reified T: Any> RestOperations.patchForObject(url: String, request: Any? = null,
 | 
				
			||||||
 | 
																			  vararg uriVariables: Any): T? =
 | 
				
			||||||
		patchForObject(url, request, T::class.java, *uriVariables)
 | 
							patchForObject(url, request, T::class.java, *uriVariables)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -128,7 +129,8 @@ inline fun <reified T: Any> RestOperations.patchForObject(url: String, request:
 | 
				
			||||||
 * @since 5.0.2
 | 
					 * @since 5.0.2
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.patchForObject(url: String, request: Any, uriVariables: Map<String, *>): T? =
 | 
					inline fun <reified T: Any> RestOperations.patchForObject(url: String, request: Any? = null,
 | 
				
			||||||
 | 
																			  uriVariables: Map<String, *>): T? =
 | 
				
			||||||
		patchForObject(url, request, T::class.java, uriVariables)
 | 
							patchForObject(url, request, T::class.java, uriVariables)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -141,7 +143,7 @@ inline fun <reified T: Any> RestOperations.patchForObject(url: String, request:
 | 
				
			||||||
 * @since 5.0.2
 | 
					 * @since 5.0.2
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.patchForObject(url: URI, request: Any): T? =
 | 
					inline fun <reified T: Any> RestOperations.patchForObject(url: URI, request: Any? = null): T? =
 | 
				
			||||||
		patchForObject(url, request, T::class.java)
 | 
							patchForObject(url, request, T::class.java)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -155,7 +157,8 @@ inline fun <reified T: Any> RestOperations.patchForObject(url: URI, request: Any
 | 
				
			||||||
 * @since 5.0
 | 
					 * @since 5.0
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any, vararg uriVariables: Any): T? =
 | 
					inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any? = null,
 | 
				
			||||||
 | 
																			 vararg uriVariables: Any): T? =
 | 
				
			||||||
		postForObject(url, request, T::class.java, *uriVariables)
 | 
							postForObject(url, request, T::class.java, *uriVariables)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -169,7 +172,8 @@ inline fun <reified T: Any> RestOperations.postForObject(url: String, request: A
 | 
				
			||||||
 * @since 5.0
 | 
					 * @since 5.0
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any, uriVariables: Map<String, *>): T? =
 | 
					inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any? = null,
 | 
				
			||||||
 | 
																			 uriVariables: Map<String, *>): T? =
 | 
				
			||||||
		postForObject(url, request, T::class.java, uriVariables)
 | 
							postForObject(url, request, T::class.java, uriVariables)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -183,7 +187,7 @@ inline fun <reified T: Any> RestOperations.postForObject(url: String, request: A
 | 
				
			||||||
 * @since 5.0
 | 
					 * @since 5.0
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.postForObject(url: URI, request: Any): T? =
 | 
					inline fun <reified T: Any> RestOperations.postForObject(url: URI, request: Any? = null): T? =
 | 
				
			||||||
		postForObject(url, request, T::class.java)
 | 
							postForObject(url, request, T::class.java)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -197,7 +201,7 @@ inline fun <reified T: Any> RestOperations.postForObject(url: URI, request: Any)
 | 
				
			||||||
 * @since 5.0
 | 
					 * @since 5.0
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any,
 | 
					inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any? = null,
 | 
				
			||||||
		vararg uriVariables: Any): ResponseEntity<T> =
 | 
							vararg uriVariables: Any): ResponseEntity<T> =
 | 
				
			||||||
		postForEntity(url, request, T::class.java, *uriVariables)
 | 
							postForEntity(url, request, T::class.java, *uriVariables)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -212,7 +216,7 @@ inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: A
 | 
				
			||||||
 * @since 5.0
 | 
					 * @since 5.0
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any,
 | 
					inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any? = null,
 | 
				
			||||||
		uriVariables: Map<String, *>): ResponseEntity<T> =
 | 
							uriVariables: Map<String, *>): ResponseEntity<T> =
 | 
				
			||||||
		postForEntity(url, request, T::class.java, uriVariables)
 | 
							postForEntity(url, request, T::class.java, uriVariables)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -227,7 +231,7 @@ inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: A
 | 
				
			||||||
 * @since 5.0
 | 
					 * @since 5.0
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.postForEntity(url: URI, request: Any): ResponseEntity<T> =
 | 
					inline fun <reified T: Any> RestOperations.postForEntity(url: URI, request: Any? = null): ResponseEntity<T> =
 | 
				
			||||||
		postForEntity(url, request, T::class.java)
 | 
							postForEntity(url, request, T::class.java)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -241,7 +245,7 @@ inline fun <reified T: Any> RestOperations.postForEntity(url: URI, request: Any)
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod,
 | 
					inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod,
 | 
				
			||||||
		requestEntity: HttpEntity<*>, vararg uriVariables: Any): ResponseEntity<T> =
 | 
							requestEntity: HttpEntity<*>? = null, vararg uriVariables: Any): ResponseEntity<T> =
 | 
				
			||||||
		exchange(url, method, requestEntity, object : ParameterizedTypeReference<T>() {}, *uriVariables)
 | 
							exchange(url, method, requestEntity, object : ParameterizedTypeReference<T>() {}, *uriVariables)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -255,7 +259,7 @@ inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMet
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod,
 | 
					inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod,
 | 
				
			||||||
		requestEntity: HttpEntity<*>, uriVariables: Map<String, *>): ResponseEntity<T> =
 | 
							requestEntity: HttpEntity<*>? = null, uriVariables: Map<String, *>): ResponseEntity<T> =
 | 
				
			||||||
		exchange(url, method, requestEntity, object : ParameterizedTypeReference<T>() {}, uriVariables)
 | 
							exchange(url, method, requestEntity, object : ParameterizedTypeReference<T>() {}, uriVariables)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -269,7 +273,7 @@ inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMet
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Throws(RestClientException::class)
 | 
					@Throws(RestClientException::class)
 | 
				
			||||||
inline fun <reified T: Any> RestOperations.exchange(url: URI, method: HttpMethod,
 | 
					inline fun <reified T: Any> RestOperations.exchange(url: URI, method: HttpMethod,
 | 
				
			||||||
		requestEntity: HttpEntity<*>): ResponseEntity<T> =
 | 
							requestEntity: HttpEntity<*>? = null): ResponseEntity<T> =
 | 
				
			||||||
		exchange(url, method, requestEntity, object : ParameterizedTypeReference<T>() {})
 | 
							exchange(url, method, requestEntity, object : ParameterizedTypeReference<T>() {})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -112,13 +112,20 @@ class RestOperationsExtensionsTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	fun `patchForObject with reified type parameters`() {
 | 
						fun `patchForObject with reified type parameters and String`() {
 | 
				
			||||||
		val url = "https://spring.io"
 | 
							val url = "https://spring.io"
 | 
				
			||||||
		val body: Any = "body"
 | 
							val body: Any = "body"
 | 
				
			||||||
		template.patchForObject<Foo>(url, body)
 | 
							template.patchForObject<Foo>(url, body)
 | 
				
			||||||
		verify(template, times(1)).patchForObject(url, body, Foo::class.java)
 | 
							verify(template, times(1)).patchForObject(url, body, Foo::class.java)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Test
 | 
				
			||||||
 | 
						fun `patchForObject with reified type parameters`() {
 | 
				
			||||||
 | 
							val url = "https://spring.io"
 | 
				
			||||||
 | 
							template.patchForObject<Foo>(url)
 | 
				
			||||||
 | 
							verify(template, times(1)).patchForObject(url, null, Foo::class.java)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	fun `postForObject with reified type parameters, String and varargs`() {
 | 
						fun `postForObject with reified type parameters, String and varargs`() {
 | 
				
			||||||
		val url = "https://spring.io"
 | 
							val url = "https://spring.io"
 | 
				
			||||||
| 
						 | 
					@ -139,13 +146,20 @@ class RestOperationsExtensionsTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	fun `postForObject with reified type parameters`() {
 | 
						fun `postForObject with reified type parameters and String`() {
 | 
				
			||||||
		val url = "https://spring.io"
 | 
							val url = "https://spring.io"
 | 
				
			||||||
		val body: Any = "body"
 | 
							val body: Any = "body"
 | 
				
			||||||
		template.postForObject<Foo>(url, body)
 | 
							template.postForObject<Foo>(url, body)
 | 
				
			||||||
		verify(template, times(1)).postForObject(url, body, Foo::class.java)
 | 
							verify(template, times(1)).postForObject(url, body, Foo::class.java)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Test
 | 
				
			||||||
 | 
						fun `postForObject with reified type parameters`() {
 | 
				
			||||||
 | 
							val url = "https://spring.io"
 | 
				
			||||||
 | 
							template.postForObject<Foo>(url)
 | 
				
			||||||
 | 
							verify(template, times(1)).postForObject(url, null, Foo::class.java)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	fun `postForEntity with reified type parameters, String and varargs`() {
 | 
						fun `postForEntity with reified type parameters, String and varargs`() {
 | 
				
			||||||
		val url = "https://spring.io"
 | 
							val url = "https://spring.io"
 | 
				
			||||||
| 
						 | 
					@ -166,13 +180,20 @@ class RestOperationsExtensionsTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	fun `postForEntity with reified type parameters`() {
 | 
						fun `postForEntity with reified type parameters and String`() {
 | 
				
			||||||
		val url = "https://spring.io"
 | 
							val url = "https://spring.io"
 | 
				
			||||||
		val body: Any = "body"
 | 
							val body: Any = "body"
 | 
				
			||||||
		template.postForEntity<Foo>(url, body)
 | 
							template.postForEntity<Foo>(url, body)
 | 
				
			||||||
		verify(template, times(1)).postForEntity(url, body, Foo::class.java)
 | 
							verify(template, times(1)).postForEntity(url, body, Foo::class.java)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Test
 | 
				
			||||||
 | 
						fun `postForEntity with reified type parameters`() {
 | 
				
			||||||
 | 
							val url = "https://spring.io"
 | 
				
			||||||
 | 
							template.postForEntity<Foo>(url)
 | 
				
			||||||
 | 
							verify(template, times(1)).postForEntity(url, null, Foo::class.java)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	fun `exchange with reified type parameters, String, HttpMethod, HttpEntity and varargs`() {
 | 
						fun `exchange with reified type parameters, String, HttpMethod, HttpEntity and varargs`() {
 | 
				
			||||||
		val url = "https://spring.io"
 | 
							val url = "https://spring.io"
 | 
				
			||||||
| 
						 | 
					@ -197,7 +218,7 @@ class RestOperationsExtensionsTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	fun `exchange with reified type parameters, String, HttpMethod, HttpEntity`() {
 | 
						fun `exchange with reified type parameters, String, HttpMethod and HttpEntity`() {
 | 
				
			||||||
		val url = "https://spring.io"
 | 
							val url = "https://spring.io"
 | 
				
			||||||
		val method = HttpMethod.GET
 | 
							val method = HttpMethod.GET
 | 
				
			||||||
		val entity = mock<HttpEntity<Foo>>()
 | 
							val entity = mock<HttpEntity<Foo>>()
 | 
				
			||||||
| 
						 | 
					@ -207,7 +228,16 @@ class RestOperationsExtensionsTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	fun `exchange with reified type parameters, String, HttpEntity`() {
 | 
						fun `exchange with reified type parameters, String and HttpMethod`() {
 | 
				
			||||||
 | 
							val url = "https://spring.io"
 | 
				
			||||||
 | 
							val method = HttpMethod.GET
 | 
				
			||||||
 | 
							template.exchange<List<Foo>>(url, method)
 | 
				
			||||||
 | 
							verify(template, times(1)).exchange(url, method, null,
 | 
				
			||||||
 | 
									object : ParameterizedTypeReference<List<Foo>>() {})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Test
 | 
				
			||||||
 | 
						fun `exchange with reified type parameters, String and HttpEntity`() {
 | 
				
			||||||
		val entity = mock<RequestEntity<Foo>>()
 | 
							val entity = mock<RequestEntity<Foo>>()
 | 
				
			||||||
		template.exchange<List<Foo>>(entity)
 | 
							template.exchange<List<Foo>>(entity)
 | 
				
			||||||
		verify(template, times(1)).exchange(entity,
 | 
							verify(template, times(1)).exchange(entity,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue