Skip to content

Fix default port handling in Target class to prevent invalid URLs #2242

@coderabbitai

Description

@coderabbitai

Problem

The Target.getPort() method currently returns the raw field value (default -1), which causes invalid URLs when concatenated directly in methods like ShadowingInterceptor.buildTargetUrl(). This produces URLs like http://example.com:-1/path.

Proposed Solution

Modify getPort() to return sensible defaults:

  • Return 443 when sslParser != null (HTTPS)
  • Return 80 otherwise (HTTP)
  • Return the stored port value when it's explicitly set (> 0)

This ensures valid URLs while maintaining backward compatibility for code that checks if the port is unset.

Context

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions