Skip to content

fix: bug bash — FlexRadio crashes, TCP hang, dead audio pad, charset#97

Closed
patrickrb wants to merge 1 commit into
mainfrom
fix/bug-bash
Closed

fix: bug bash — FlexRadio crashes, TCP hang, dead audio pad, charset#97
patrickrb wants to merge 1 commit into
mainfrom
fix/bug-bash

Conversation

@patrickrb
Copy link
Copy Markdown
Owner

Summary

Four independent latent bugs surfaced during a bug-bash sweep across FlexRadio, the Flex TCP client, the FT8 TX path, and the QRZ/Cloudlog HTTP client. None are regressions from a recent change.

  • FlexRadio.getHeadAndContent (`FlexRadio.java:1170`) — guarded `temp[1]` with `line.length() > 1`, which is unrelated to the split-array length. A no-delimiter response crashes the CAT parser thread with `ArrayIndexOutOfBoundsException`. Now checks `temp.length >= 2`.
  • FlexRadio command dispatch (`FlexRadio.java:1077`) — `FlexCommand.values()[seq_number % 1000]` assumed the enum had ≥1000 entries; an out-of-range sequence number crashed with AIOOBE. Now bounds-checked, unknown commands are logged and skipped.
  • RadioTcpClient TCP connect (`RadioTcpClient.java:99`) — `new Socket(addr, port)` used the OS default connect timeout (~75 s on Linux), so an unreachable Flex hangs the connect thread that long with no UI feedback. Replaced with the two-step `connect(InetSocketAddress, 5000)` + `setSoTimeout(15000)` pattern.
  • FT8TransmitSignal.float2Short (`FT8TransmitSignal.java:341`) — allocated `short[buffer.length + 8]` "for QP-7C RP2040 audio detection compatibility", but the 16-bit `AudioTrack.write` uses `playLength = buffer.length - skipSamples` and never includes those 8 trailing samples. The 32-bit float path doesn't add the pad at all. Dropped the dead allocation and the misleading comment.
  • ThirdPartyService.sendGetRequest (`ThirdPartyService.java:553`) — `InputStreamReader` without an explicit charset reads QRZ/Cloudlog responses with the platform default. The sibling reader near line 443 already uses UTF-8; this one-line divergence corrupts non-ASCII responses on non-UTF-8 default locales.

Test plan

  • Builds clean on `fix/bug-bash` (verified during full `gradlew installDebug` from the parent branch with the same edits)
  • FlexRadio bounds fixes — synthetic test feeding a no-delimiter line and a high-`seq` response to the parser (no Flex on hand to exercise live)
  • TCP timeout — point Flex IP at `192.0.2.1` (TEST-NET-1), confirm connect attempt fails in ~5 s with visible error
  • `float2Short` change is a no-op for non-QP-7C TX — confirm TX'd FT8 still decodes on a second receiver
  • UTF-8 charset on QRZ reader — code-review parity with line-443 reader; full validation needs a non-UTF-8 locale device

Related

Companion fixes that touch POTA-only files (DatabaseOpr migration repair, POTA self-spot frequency, POTA ADIF exporter UTF-8 length) were pushed to PR #96 since they only apply where the POTA branch's files exist.

🤖 Generated with Claude Code

Four independent fixes found during a sweep of FlexRadio, the Flex TCP
client, the FT8 TX path, and the QRZ/Cloudlog HTTP client. None are
regressions from a recent change; all are latent bugs.

- FlexRadio.getHeadAndContent: the old guard checked line.length()
  before accessing temp[1], but a no-delimiter response produces a
  length-1 split[]. Crashed the CAT parser thread with AIOOBE.
- FlexRadio command dispatch: FlexCommand.values()[seq_number % 1000]
  assumed the enum had >=1000 entries; an out-of-range sequence
  number crashed with AIOOBE. Now bounds-checked, unknown commands
  are logged and skipped.
- RadioTcpClient: replaced new Socket(addr, port) with timeout-bounded
  connect(InetSocketAddress, 5000) + setSoTimeout(15000). An
  unreachable Flex used to hang the connect thread up to ~75 s with
  no UI feedback.
- FT8TransmitSignal.float2Short: dropped the +8 zero-pad that the
  16-bit AudioTrack.write never actually included (playLength caps
  at buffer.length - skipSamples), and that the 32-bit path didn't
  have at all. The comment claiming QP-7C RP2040 compatibility was
  misleading on both paths.
- ThirdPartyService.sendGetRequest: pass StandardCharsets.UTF_8 to
  the InputStreamReader for parity with the sibling reader near
  line 443. Prevents QRZ/Cloudlog responses with non-ASCII content
  from decoding wrong on non-UTF-8 default locales.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@patrickrb patrickrb closed this Jun 4, 2026
@patrickrb patrickrb deleted the fix/bug-bash branch June 4, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants