Skip to content

fix(server): fix check_port port extraction for schemeless URLs#3005

Merged
imbajin merged 1 commit intoapache:masterfrom
bitflicker64:fix/check-port-url-parsing-clean
Apr 25, 2026
Merged

fix(server): fix check_port port extraction for schemeless URLs#3005
imbajin merged 1 commit intoapache:masterfrom
bitflicker64:fix/check-port-url-parsing-clean

Conversation

@bitflicker64
Copy link
Copy Markdown
Contributor

Purpose of the PR

check_port() in util.sh uses awk -F':' '{print $3}' to extract the port, which assumes a 3-part URL like http://host:port. Since #2944 changed the default restserver.url to host:port format (no scheme), field $3 is empty and lsof -i : fails with:

lsof: unacceptable port specification in: -i :

Main Changes

Replace awk with sed in check_port() across all three util.sh files:

# before
local port=$(echo "$1" | awk -F':' '{print $3}')

# after  
local port=$(echo "$1" | sed 's|.*:||' | sed 's|/.*||')

This handles all URL formats correctly — host:port, http://host:port, http://host:port/path, and IPv6. Also modernizes backtick syntax to $() in pd and store.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)

Does this PR potentially affect the following parts?

  • Nope

Documentation Status

  • Doc - No Need

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Apr 23, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 25, 2026
@imbajin imbajin merged commit bcaa5f1 into apache:master Apr 25, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] check_port in util.sh fails when restserver.url has no scheme prefix

2 participants