gnodet opened a new pull request, #29804:
URL: https://github.com/apache/camel/pull/29804

   ## Summary
   
   Fixes 4 of the top bugs from 
[CAMEL-26914](https://issues.apache.org/jira/browse/CAMEL-26914) — outbound 
network calls in camel-jbang that swallow errors, run without timeouts, or can 
hang the CLI permanently.
   
   ### Bug 1 — GitHub/Gist non-200 responses silently swallowed
   
   `GitHubHelper.resolveGithubAsRawFiles` and 
`GistHelper.resolveGistAsRawFiles` checked `statusCode == 200` but the `else` 
branch was empty, so a 403/404/429 caused `camel run <url>` to print "No routes 
found" and exit 0.
   
   **Fix:** throw `IOException` with the status code. For 403/429 (rate limit), 
the message hints `GITHUB_TOKEN`.
   
   ### Bug 2 — `URL.openStream()` without timeouts in 
`camel-resourceresolver-github`
   
   `GitHubResource.exists()` and `GistResource.exists()` called 
`URL.openStream()` with no connect or read timeout.
   
   **Fix:** replaced with `HttpURLConnection` with 10 s connect timeout and 20 
s read timeout.
   
   ### Bug 3 — `HttpRequest.timeout()` does not bound the response body read
   
   `HttpRequest.timeout()` only bounds the connection/header phase. A server 
that sends the headers and then stalls hangs `hc.send(BodyHandlers.ofString())` 
indefinitely past the timeout (confirmed: still blocked after 18 s with a 3 s 
timeout).
   
   **Fix:** switched `GitHubHelper` and `GistHelper` from `hc.send()` to 
`hc.sendAsync().get(timeout)`, which bounds the entire round-trip including the 
body.
   
   ### Bug 4 — `SelfUpdateCommand` hangs permanently
   
   `runInstaller` read stdout with `readAllBytes()` before calling `waitFor()`, 
which can deadlock if the subprocess fills its pipe buffer. And `waitFor()` had 
no timeout, so a stalled `curl`/`wget` in `install.sh` could hang the CLI 
forever.
   
   **Fix:** drain stdout in a background thread (avoids pipe-buffer deadlock), 
then `waitFor(5, MINUTES)`. The executor is shut down in a `finally` block.
   
   ## Files changed
   
   - 
`components/camel-resourceresolver-github/src/main/java/org/apache/camel/github/GitHubResource.java`
   - 
`components/camel-resourceresolver-github/src/main/java/org/apache/camel/github/GistResource.java`
   - 
`dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/common/GitHubHelper.java`
   - 
`dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/common/GistHelper.java`
   - 
`dsl/camel-jbang/camel-launcher/src/main/java/org/apache/camel/dsl/jbang/launcher/selfupdate/SelfUpdateCommand.java`
   - 
`dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/common/GitHubApiResponseTest.java`
 (3 new tests: 404 throws, 403 throws with GITHUB_TOKEN hint, Gist 404 throws)
   
   _This PR was opened by a coding agent on behalf of gnodet._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to