Worker / slot / smart-proxy hardening pass
Follow-up to the worker, slot, download and smart-proxy audit. Six robustness fixes; no byte-level behavior change. Java 8 compatibility preserved.
- ChunkWriterManager: AES init failure now aborts the download cleanly instead of silently advancing the byte counter and deleting the chunk file (which previously punched a hole in the output and only got caught later by the CBC-MAC check, wasting the rest of the download).
- Download.getDownloadUrlForWorker: the worker-URL refetch loop now respects
_exit, restores the interrupt flag, and caps at 32 retries. Previously a permanent MEGA outage / dead link kept this synchronized block spinning forever, blocking every other worker on_dl_url_lockand leaving the user unable to cancel until process restart. - SmartMegaProxyManager.getProxy: recursive refresh replaced with a bounded iterative loop (max 5 attempts). The old version could in theory deepen the call stack indefinitely on a permanently-bad proxy list.
- SmartMegaProxyManager time arithmetic:
intwidened tolongin autorefresh / ban-time computations to avoid overflow on absurd-but-legal DB values. - ChunkDownloader.RESET_CURRENT_CHUNK: cache the input-stream reference to a local before the null-check + close to dodge a TOCTOU NPE that could short-circuit
forceResetAllChunks. - MegaProxyServer Handler: bounded 30s connect timeout + 30s SO_TIMEOUT on the forward socket to MEGA. The previous
new Socket(host, port)could pin handler threads on a stalled remote for minutes; with a 64-thread bounded pool, a few stalls would saturate the proxy.