[Bug] HAProxyMessageForwarder should tolerate malformed port values
- Dominant language
- Java
- Stars
- 22.6k
- Forks
- 12k
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 27
Description
### Bug description
`HAProxyMessageForwarder.buildHAProxyMessage` parses source and destination ports with `Integer.parseInt` from either proxy protocol channel attributes or the channel remote/local address strings.
If a port value is malformed, for example a non-numeric proxy protocol port attribute or a malformed channel address, `buildHAProxyMessage` can throw `NumberFormatException`. This makes HAProxy message forwarding fail with a runtime parsing exception instead of simply skipping an invalid proxy protocol message.
### Expected behavior
Invalid or malformed proxy protocol port values should not throw from HAProxy message construction. The forwarder should treat the HAProxy message as unavailable and return `null`, consistent with existing behavior when required attributes are missing.
### Affected area
`proxy` module, remoting HTTP/2 proxy HAProxy protocol forwarding.
### Suggested fix
- Parse proxy protocol ports through a safe helper.
- Return `null` when source or destination ports cannot be parsed.
- Keep existing behavior for valid port values.
- Add unit tests for valid channel address parsing and malformed port values.
Contributor guide
Research direction
Start in the proxy module at HAProxyMessageForwarder.buildHAProxyMessage and trace parsing of proxy protocol channel attributes and remote/local address strings. Add unit-test coverage for valid channel addresses and malformed source or destination ports. Done means malformed values return null without NumberFormatException while valid values retain their current behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100