Skip to content

Commit f90bdbe

Browse files
committed
Add noop implementation for ResponseErrorHandler
Closes gh-32750
1 parent f17527a commit f90bdbe

File tree

2 files changed

+45
-14
lines changed

2 files changed

+45
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.web.client;
18+
19+
import java.io.IOException;
20+
21+
import org.springframework.http.client.ClientHttpResponse;
22+
23+
/**
24+
* A basic, no operation {@link ResponseErrorHandler} implementation suitable
25+
* for ignoring any error.
26+
*
27+
* @author Stephane Nicoll
28+
* @since 6.1.7
29+
*/
30+
public final class NoOpResponseErrorHandler implements ResponseErrorHandler {
31+
32+
@Override
33+
public boolean hasError(ClientHttpResponse response) throws IOException {
34+
return false;
35+
}
36+
37+
@Override
38+
public void handleError(ClientHttpResponse response) throws IOException {
39+
40+
}
41+
42+
}

spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java

+3-14
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import org.springframework.http.HttpStatus;
2424
import org.springframework.http.ResponseEntity;
25-
import org.springframework.http.client.ClientHttpResponse;
25+
import org.springframework.web.client.NoOpResponseErrorHandler;
2626
import org.springframework.web.client.ResponseErrorHandler;
2727
import org.springframework.web.client.RestTemplate;
2828
import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests;
@@ -36,6 +36,8 @@
3636
*/
3737
class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
3838

39+
private static final ResponseErrorHandler NO_OP_ERROR_HANDLER = new NoOpResponseErrorHandler();
40+
3941
private final ErrorHandler handler = new ErrorHandler();
4042

4143

@@ -110,17 +112,4 @@ else if (path.endsWith("handling-error")) {
110112
}
111113
}
112114

113-
114-
private static final ResponseErrorHandler NO_OP_ERROR_HANDLER = new ResponseErrorHandler() {
115-
116-
@Override
117-
public boolean hasError(ClientHttpResponse response) {
118-
return false;
119-
}
120-
121-
@Override
122-
public void handleError(ClientHttpResponse response) {
123-
}
124-
};
125-
126115
}

0 commit comments

Comments
 (0)