Example usage for org.springframework.core.codec CodecException CodecException

List of usage examples for org.springframework.core.codec CodecException CodecException

Introduction

In this page you can find the example usage for org.springframework.core.codec CodecException CodecException.

Prototype

public CodecException(String msg) 

Source Link

Document

Create a new CodecException.

Usage

From source file:org.springframework.http.codec.multipart.DefaultMultipartMessageReader.java

@Override
public Flux<Part> read(ResolvableType elementType, ReactiveHttpInputMessage message,
        Map<String, Object> hints) {
    byte[] boundary = boundary(message);
    if (boundary == null) {
        return Flux.error(new CodecException("No multipart boundary found in Content-Type: \""
                + message.getHeaders().getContentType() + "\""));
    }//  www.  jav  a  2 s . com
    if (logger.isTraceEnabled()) {
        logger.trace("Boundary: " + toString(boundary));
    }

    byte[] boundaryNeedle = concat(BOUNDARY_PREFIX, boundary);
    Flux<DataBuffer> body = skipUntilFirstBoundary(message.getBody(), boundary);

    return DataBufferUtils.split(body, boundaryNeedle).takeWhile(DefaultMultipartMessageReader::notLastBoundary)
            .map(DefaultMultipartMessageReader::toPart)
            .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release)
            .doOnDiscard(DefaultPart.class, part -> DataBufferUtils.release(part.body));
}