package com.webfluxclient.codec;

import lombok.AccessLevel;
import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.reactive.ClientHttpResponse;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * {@code HttpErrorReader} that wraps and delegates to a {@link ErrorDecoder}.
 *
 * @author Jérémy Brixhe
 */
public class DecoderHttpErrorReader implements HttpErrorReader {

    @Getter(AccessLevel.PACKAGE)
    private ErrorDecoder errorDecoder;

    /**
     * Create an instance wrapping the given {@link ErrorDecoder}.
     */
    public DecoderHttpErrorReader(ErrorDecoder errorDecoder) {
        this.errorDecoder = errorDecoder;
    }

    @Override
    public boolean canRead(HttpStatus httpStatus) {
        return errorDecoder.canDecode(httpStatus);
    }

    @Override
    public <T> Flux<T> read(ClientHttpResponse inputMessage) {
        return decodeInternal(inputMessage);
    }

    @Override
    public <T> Mono<T> readMono(ClientHttpResponse inputMessage) {
        return (Mono<T>) decodeInternal(inputMessage).singleOrEmpty();
    }

    private <T> Flux<T> decodeInternal(ClientHttpResponse inputMessage) {
        return Flux.from(inputMessage.getBody())
                .map(dataBuffer -> {
                    throw errorDecoder.decode(inputMessage.getStatusCode(), dataBuffer);
                });
    }
}

@@ -31,57 +31,8 @@
 c;%0A%0A
-import lombok.AccessLevel;%0Aimport lombok.Getter;%0A
 impo
@@ -397,41 +397,8 @@
  %7B%0A%0A
-    @Getter(AccessLevel.PACKAGE)%0A
     

Remove useless lombok annotation