Skip to content

NullPointerException in DockerClientConfig.DockerClientConfigBuilder.build() #150

Description

@wzheng2310

DockerClientConfig.DockerClientConfigBuilder.build() is defined as:

    public DockerClientConfig build() {
        return new DockerClientConfig(
                uri,
                version,
                username,
                password,
                email,
                serverAddress,
                dockerCfgPath,
                readTimeout,
                loggingFilterEnabled,
                sslConfig,
                maxTotalConnections,
                maxPerRouteConnections
        );
    }

The last two parameters are of type Integer, and they can be NULL, no where in the API says they can't be NULL, and no where says DockerClientConfigBuilder.withMaxTotalConnections() or DockerClientConfigBuilder.withMaxPerRouteConnections() has to be called.

There are no default values set for these two parameters either.

If the caller never set these two fields, when DockerClientConfig is created inside of this build function, because DockerClientConfig() expects maxTotalConnections and maxPerRouteConnections to be passed in as primitive int type, it will cause NullPointerException.

Either a meaningful error message or exception should be thrown here, or the code here should use some reasonable default values

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions