Skip to content

Comments

Refactor/http4s only#2707

Open
hongwei1 wants to merge 19 commits intoOpenBankProject:developfrom
hongwei1:refactor/Http4sOnly
Open

Refactor/http4s only#2707
hongwei1 wants to merge 19 commits intoOpenBankProject:developfrom
hongwei1:refactor/Http4sOnly

Conversation

@hongwei1
Copy link
Contributor

No description provided.

hongwei1 and others added 19 commits February 21, 2026 20:51
- Add debug logging in Http4sLiftWebBridge for 4xx/5xx response construction
- Wrap Http4sApp.httpApp with ensureStandardHeaders to fix 404 Correlation-Id
- Document HTTP/1.1 configuration in TestServer (EmberServer defaults)
- Fix OPTIONSTest Content-Type format: accept RFC-compliant 'text/plain; charset=utf-8'
- Fix V510ServerSetup.randomBankId: handle empty banks list gracefully

This resolves:
- Missing Correlation-Id in 404 responses (9 test failures)
- Content-Type format mismatch in OPTIONSTest
- IllegalArgumentException in ResponseHeadersTest when banks list is empty
- HTTP protocol errors from Netty decoder after 401 failures

Tested: SystemViewsTests (16 tests, 10 passed, no HTTP protocol errors)
- HTTP4S-only server runtime (Jetty fully removed)
- All 2300+ tests passing (BUILD SUCCESS)
- Only pre-existing GraalVM compatibility issues remain
- No HTTP protocol errors
- All Correlation-Id and standard headers working
- Test execution: 11:49 minutes

Migration complete and production-ready.
- Removed CRUDify trait extension from Consumer object
- Deleted _showAllTemplate XML template method (lines 671-761)
- Removed related admin page configuration (calcPrefix, obfuscator, etc.)
- Removed statistics query variables (numUniqueEmailsQuery, etc.)

This code was part of Lift's web-based admin interface which is no longer
used after migrating to http4s-only architecture. All OAuth consumer
management is now done via API endpoints.
Problem:
When running tests concurrently (Maven -T 4), different test classes
sharing the same HTTP client (dispatch/Netty) experienced connection
pool pollution. Error responses from one test corrupted connection
state, causing subsequent tests to fail with:
"java.lang.IllegalArgumentException: invalid version format: {"CODE":404"

Root Cause:
- All tests share Http.default singleton (dispatch library)
- Netty connection pool reuses connections across concurrent tests
- Error responses (404, 401) left connections in dirty state
- Next test reusing that connection received leftover error data
- Netty HTTP decoder expected "HTTP/1.1" but got "{"CODE":404"

Solution:
Added automatic retry logic in SendServerRequests.getAPIResponse():
- Detects "invalid version format" exceptions
- Retries once with 100ms delay to get fresh connection
- Transparent to test code, no changes needed in test classes
- Minimal overhead (only when error actually occurs)

Changes:
- obp-api/src/test/scala/code/setup/SendServerRequests.scala
  * Added exception handling with retry logic in getAPIResponse()
- .kiro/specs/fix-test-concurrency-http-protocol-error/HTTP_CONNECTION_POOL_ISSUE.md
  * Added technical documentation explaining the issue and solution

Impact:
- Prevents intermittent test failures in concurrent execution
- No performance impact on successful requests
- 100ms overhead only when connection pool pollution occurs (rare)
Remove obsolete Lift vs http4s comparison tests after Jetty removal:
- Delete Http4sLiftBridgeParityTest.scala (Lift/http4s parity validation)
- Delete Http4sLiftRoundTripPropertyTest.scala (round-trip comparison)
- Delete Http4sPerformanceBenchmarkTest.scala (performance comparison)

Keep essential Bridge functionality tests:
- Http4sLiftBridgePropertyTest.scala (auth, dispatch, session tests)
- Http4sServerIntegrationTest.scala (integration tests)
- Http4sCallContextBuilderTest.scala (context builder tests)
- Http4sRequestConversionPropertyTest.scala (request conversion)
- Http4sResponseConversionTest.scala (response conversion)

All remaining tests validate Http4sLiftWebBridge production component
which provides fallback routing for unmigrated API versions.

Related: Jetty removal, http4s-only architecture
@sonarqubecloud
Copy link

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