Allow for null values in ExtractingResponseErrorHandler.hasError
This commit fixes the implementation of ExtractingResponseErrorHandler.hasError to allow for null values, indicating an override of the behavior inherited from DefaultResponseErrorHandler. Issue: SPR-15544
This commit is contained in:
		
							parent
							
								
									d3e3365990
								
							
						
					
					
						commit
						7894efdd1e
					
				| 
						 | 
					@ -126,9 +126,15 @@ public class ExtractingResponseErrorHandler extends DefaultResponseErrorHandler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	protected boolean hasError(HttpStatus statusCode) {
 | 
						protected boolean hasError(HttpStatus statusCode) {
 | 
				
			||||||
		return this.statusMapping.containsKey(statusCode) ||
 | 
							if (this.statusMapping.containsKey(statusCode)) {
 | 
				
			||||||
				this.seriesMapping.containsKey(statusCode.series()) ||
 | 
								return this.statusMapping.get(statusCode) != null;
 | 
				
			||||||
						super.hasError(statusCode);
 | 
							}
 | 
				
			||||||
 | 
							else if (this.seriesMapping.containsKey(statusCode.series())) {
 | 
				
			||||||
 | 
								return this.seriesMapping.get(statusCode.series()) != null;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else {
 | 
				
			||||||
 | 
								return super.hasError(statusCode);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,6 +68,21 @@ public class ExtractingResponseErrorHandlerTests {
 | 
				
			||||||
		assertFalse(this.errorHandler.hasError(this.response));
 | 
							assertFalse(this.errorHandler.hasError(this.response));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Test
 | 
				
			||||||
 | 
						public void hasErrorOverride() throws Exception {
 | 
				
			||||||
 | 
							this.errorHandler.setSeriesMapping(Collections
 | 
				
			||||||
 | 
									.singletonMap(HttpStatus.Series.CLIENT_ERROR, null));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							given(this.response.getStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT);
 | 
				
			||||||
 | 
							assertTrue(this.errorHandler.hasError(this.response));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							given(this.response.getStatusCode()).willReturn(HttpStatus.NOT_FOUND);
 | 
				
			||||||
 | 
							assertFalse(this.errorHandler.hasError(this.response));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							given(this.response.getStatusCode()).willReturn(HttpStatus.OK);
 | 
				
			||||||
 | 
							assertFalse(this.errorHandler.hasError(this.response));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void handleErrorStatusMatch() throws Exception {
 | 
						public void handleErrorStatusMatch() throws Exception {
 | 
				
			||||||
		given(this.response.getStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT);
 | 
							given(this.response.getStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT);
 | 
				
			||||||
| 
						 | 
					@ -133,6 +148,7 @@ public class ExtractingResponseErrorHandlerTests {
 | 
				
			||||||
	public void handleNoMatchOverride() throws Exception {
 | 
						public void handleNoMatchOverride() throws Exception {
 | 
				
			||||||
		this.errorHandler.setSeriesMapping(Collections
 | 
							this.errorHandler.setSeriesMapping(Collections
 | 
				
			||||||
				.singletonMap(HttpStatus.Series.CLIENT_ERROR, null));
 | 
									.singletonMap(HttpStatus.Series.CLIENT_ERROR, null));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		given(this.response.getStatusCode()).willReturn(HttpStatus.NOT_FOUND);
 | 
							given(this.response.getStatusCode()).willReturn(HttpStatus.NOT_FOUND);
 | 
				
			||||||
		HttpHeaders responseHeaders = new HttpHeaders();
 | 
							HttpHeaders responseHeaders = new HttpHeaders();
 | 
				
			||||||
		responseHeaders.setContentType(MediaType.APPLICATION_JSON);
 | 
							responseHeaders.setContentType(MediaType.APPLICATION_JSON);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue