Skip to content

When use HttpServer and set maxSize parameter for upload file, i got error: IllegalReferenceCountException: refCnt: 0, decrement: 1 #3740

@kfyty

Description

@kfyty

when use HttpServer and set maxSize parameter for upload file, i got error: IllegalReferenceCountException: refCnt: 0, decrement: 1

Expected Behavior

when upload file exceed maxSize limit, should without causing IllegalReferenceCountException.
and only causing HttpPostRequestDecoder$ErrorDataDecoderException: java.io.IOException: Size exceed allowed maximum capacity.

Actual Behavior

when upload file exceed maxSize limit, definitely causing IllegalReferenceCountException.

Steps to Reproduce

public class Main {

    public static void main(String[] args) throws Exception {
        DisposableServer server =
                HttpServer.create()
                        .port(8080)
                        .httpFormDecoder(e -> e.maxSize(1024 * 1024 * 10))
                        .route(routes -> routes
                                .post("/upload", (request, response) -> {
                                    return request.receiveForm()
                                            .map(InterfaceHttpData::getName)
                                            .collectList()
                                            .map(e -> String.join(",", e))
                                            .flatMap((Function<String, Mono<Void>>) s -> response.sendString(Mono.just(s)).then());
                                })
                        )
                        .bindNow();
        System.in.read();
    }
}

run this java main class,and send request with multipart/form-data, and file size should exceed maxSize, then you will get IllegalReferenceCountException.

Possible Solution

Your Environment

  • Reactor version(s) used: 1.3.0-M2
  • JVM version (java -version): jdk17
  • OS and version (eg. uname -a): windows10

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions