Skip to content

Commit

Permalink
Add noop implementation for ResponseErrorHandler
Browse files Browse the repository at this point in the history
Closes gh-32750
  • Loading branch information
snicoll committed May 2, 2024
1 parent f17527a commit f90bdbe
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.web.client;

import java.io.IOException;

import org.springframework.http.client.ClientHttpResponse;

/**
* A basic, no operation {@link ResponseErrorHandler} implementation suitable
* for ignoring any error.
*
* @author Stephane Nicoll
* @since 6.1.7
*/
public final class NoOpResponseErrorHandler implements ResponseErrorHandler {

@Override
public boolean hasError(ClientHttpResponse response) throws IOException {
return false;
}

@Override
public void handleError(ClientHttpResponse response) throws IOException {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.NoOpResponseErrorHandler;
import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests;
Expand All @@ -36,6 +36,8 @@
*/
class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {

private static final ResponseErrorHandler NO_OP_ERROR_HANDLER = new NoOpResponseErrorHandler();

private final ErrorHandler handler = new ErrorHandler();


Expand Down Expand Up @@ -110,17 +112,4 @@ else if (path.endsWith("handling-error")) {
}
}


private static final ResponseErrorHandler NO_OP_ERROR_HANDLER = new ResponseErrorHandler() {

@Override
public boolean hasError(ClientHttpResponse response) {
return false;
}

@Override
public void handleError(ClientHttpResponse response) {
}
};

}

0 comments on commit f90bdbe

Please sign in to comment.