Skip to content

Improvements in socket connect to server #962

@olivierayache

Description

@olivierayache

When you use a custom socketFactory this code can be buggy:

if (!socket.isBound()) {
  InetSocketAddress addr = new InetSocketAddress(dnsResolver.resolve(uri), this.getPort());
  socket.connect(addr, connectTimeout);
}

Indeed socket might already be bound by socketFactory and isBound() will return true. A better version could be

if (!socket.isConnected()) {
  InetSocketAddress addr = new InetSocketAddress(dnsResolver.resolve(uri), this.getPort());
  socket.connect(addr, connectTimeout);
}

This issue is linked to the solution I mentionned in issue #814

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions