Skip to content

Stabilize external-DTD dictionary loading in MessageTest with short timeouts and bounded retries#1220

Merged
chrjohn merged 11 commits into
masterfrom
copilot/fix-timeout-issue-when-connecting
May 10, 2026
Merged

Stabilize external-DTD dictionary loading in MessageTest with short timeouts and bounded retries#1220
chrjohn merged 11 commits into
masterfrom
copilot/fix-timeout-issue-when-connecting

Conversation

Copilot AI commented May 9, 2026

Copy link
Copy Markdown
Contributor

MessageTest.shouldConvertToXmlWhenDataDictionaryLoadedWithExternalDTD was intermittently failing because parsing FIX_External_DTD.xml can block on w3.org network latency (default ~30s timeout). This updates the test path to fail faster per attempt and retry a small number of times before surfacing an error.

  • Problem focus

    • The flaky path is external DTD resolution during DataDictionary construction in the XML conversion test.
    • Failures are transient network-bound, not deterministic parsing failures.
  • Change set

    • Added a dedicated helper in quickfix.MessageTest to load FIX_External_DTD.xml with:
      • reduced JVM URL timeouts (sun.net.client.defaultConnectTimeout, sun.net.client.defaultReadTimeout) set to 5000ms
      • bounded retries (3 attempts)
      • short exponential backoff between attempts (250ms, 500ms)
    • Ensured system properties are always restored in finally to avoid timeout leakage into other tests.
    • Preserved root cause on final failure and wrapped with an aggregate message including attempt count.
  • Test update usage

    • shouldConvertToXmlWhenDataDictionaryLoadedWithExternalDTD now uses the retrying loader instead of directly instantiating DataDictionary.
for (int attempt = 1; attempt <= EXTERNAL_DTD_LOAD_RETRIES; attempt++) {
    try {
        return new DataDictionary("FIX_External_DTD.xml", DocumentBuilderFactory::newInstance);
    } catch (ConfigError e) {
        lastError = e;
        if (attempt < EXTERNAL_DTD_LOAD_RETRIES) {
            Thread.sleep((1L << (attempt - 1)) * EXTERNAL_DTD_RETRY_DELAY_MILLIS);
        }
    }
}
throw new ConfigError("Failed to load FIX_External_DTD.xml after "
        + EXTERNAL_DTD_LOAD_RETRIES + " attempts", lastError);

Copilot AI and others added 11 commits May 9, 2026 08:29
Agent-Logs-Url: https://github.com/quickfix-j/quickfixj/sessions/bfbc9252-140b-44b9-a936-c3af5d32355e

Co-authored-by: chrjohn <6644028+chrjohn@users.noreply.github.com>
@chrjohn chrjohn added this to the QFJ 3.0.1 milestone May 10, 2026
@chrjohn chrjohn marked this pull request as ready for review May 10, 2026 10:43
@chrjohn chrjohn merged commit 735b6f2 into master May 10, 2026
39 checks passed
@chrjohn chrjohn deleted the copilot/fix-timeout-issue-when-connecting branch May 10, 2026 10:47
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