Skip to content

Incorrect builder pattern implementation #238

Closed
@ash2k

Description

@ash2k

RequestBuilder (RequestBuilderBase) implements builder pattern to build instances of Request object. Some issues with it:

  • RequestBuilder instance cannot be reused because it holds state for Request object instance - this is not even documented;
  • Traditionally an object built by a builder is immutable and is not connected to it's builder in any way. Built Request object is not immutable - can be mutated by the builder even after construction;
  • Because of the above Request object is not threadsafe. It's good to fix that too.

The obvious way to fix that issue is to construct new Request instances on each build() and make all it's fields final.

AsyncHttpClientConfig have the same problem with threadsafety - it have mutable fields. Should be final.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions