Debug logging of REST response body in case of error.
Removed some irrelevant logs.
Issue-ID: CCSDK-3766
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Change-Id: I3c7b62acd1736f9447e3494c655d85372a4c521f
import org.springframework.web.reactive.function.client.ExchangeStrategies;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec;
+import org.springframework.web.reactive.function.client.WebClientResponseException;
import reactor.core.publisher.Mono;
import reactor.netty.http.client.HttpClient;
request.headers(h -> h.setBearerAuth(securityContext.getBearerAuthToken()));
}
return request.retrieve() //
- .toEntity(String.class);
+ .toEntity(String.class) //
+ .doOnError(this::onError);
+
+ }
+
+ private void onError(Throwable t) {
+ if (t instanceof WebClientResponseException) {
+ WebClientResponseException e = (WebClientResponseException) t;
+ logger.debug("Response error: {}", e.getResponseBodyAsString());
+ }
}
private static Object createTraceTag() {
import io.swagger.v3.oas.annotations.media.Schema;
+import java.lang.invoke.MethodHandles;
+
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
public class ErrorResponse {
private static Gson gson = new GsonBuilder() //
.create(); //
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
// Returned as body for all failed REST calls
@Schema(name = "error_information", description = "Problem as defined in https://tools.ietf.org/html/rfc7807")
}
static ResponseEntity<Object> create(String text, HttpStatus code) {
+ logger.debug("Error response: {}, {}", code, text);
ErrorInfo p = new ErrorInfo(text, code.value());
String json = gson.toJson(p);
HttpHeaders headers = new HttpHeaders();
}
void onRequest(long no) {
- logger.debug("InfiniteFlux.onRequest {}", no);
for (long i = 0; i < no; ++i) {
sink.next(counter++);
}
}
void next(FluxSink<Integer> sink) {
- logger.debug("InfiniteFlux.next");
this.sink = sink;
sink.next(counter++);
}
private Mono<String> fetchFromDmaap() {
if (!this.isDmaapConfigured()) {
- logger.debug("fetchFromDmaap, no action DMAAP not configured");
return delay().flatMap(o -> Mono.empty());
}
logger.debug("fetchFromDmaap");
@AfterEach
void verifyNoRicLocks() {
for (Ric ric : this.rics.getRics()) {
- Lock.Grant grant = ric.getLock().lockBlocking(LockType.EXCLUSIVE, "");
+ Lock.Grant grant = ric.getLock().lockBlocking(LockType.EXCLUSIVE, "verifyNoRicLocks");
grant.unlockBlocking();
assertThat(ric.getLock().getLockCounter()).isZero();
assertThat(ric.getState()).isEqualTo(Ric.RicState.AVAILABLE);
for (int i = 0; i < 10; ++i) {
AsyncRestClient restClient = restClient();
- ConcurrencyTestRunnable test = new ConcurrencyTestRunnable(restClient, supervision, a1ClientFactory, rics,
- policyTypes);
+ ConcurrencyTestRunnable test =
+ new ConcurrencyTestRunnable(restClient, supervision, a1ClientFactory, rics, policyTypes);
Thread thread = new Thread(test, "TestThread_" + i);
thread.start();
threads.add(thread);