{"record":{"id":"538362bb74a51958","repo":"testcontainers/testcontainers-java","slug":"unexpected-error-occurred-will-proceed-to-try-to-wait-anyway","errorCode":null,"errorMessage":"Unexpected error occurred - will proceed to try to wait anyway","messagePattern":"Unexpected error occurred - will proceed to try to wait anyway","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/testcontainers/containers/wait/strategy/HttpWaitStrategy.java","lineNumber":247,"sourceCode":"        try {\n            // Un-map the port for logging\n            int originalPort = waitStrategyTarget\n                .getExposedPorts()\n                .stream()\n                .filter(exposedPort -> rawUri.getPort() == waitStrategyTarget.getMappedPort(exposedPort))\n                .findFirst()\n                .orElseThrow(() -> new IllegalStateException(\"Target port \" + rawUri.getPort() + \" is not exposed\"));\n            log.info(\n                \"{}: Waiting for {} seconds for URL: {} (where port {} maps to container port {})\",\n                containerName,\n                startupTimeout.getSeconds(),\n                uri,\n                rawUri.getPort(),\n                originalPort\n            );\n        } catch (RuntimeException e) {\n            // do not allow a failure in logging to prevent progress, but log for diagnosis\n            log.warn(\"Unexpected error occurred - will proceed to try to wait anyway\", e);\n        }\n\n        // try to connect to the URL\n        try {\n            retryUntilSuccess(\n                (int) startupTimeout.getSeconds(),\n                TimeUnit.SECONDS,\n                () -> {\n                    getRateLimiter()\n                        .doWhenReady(() -> {\n                            try {\n                                final HttpURLConnection connection = openConnection(uri);\n                                connection.setReadTimeout(Math.toIntExact(readTimeout.toMillis()));\n\n                                // authenticate\n                                if (!Strings.isNullOrEmpty(username)) {\n                                    connection.setRequestProperty(\n                                        HEADER_AUTHORIZATION,","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/core/src/main/java/org/testcontainers/containers/wait/strategy/HttpWaitStrategy.java#L229-L265","documentation":"HttpWaitStrategy builds a formatted URI for logging and any RuntimeException thrown while doing so is caught and logged at WARN level. This is a non-fatal diagnostic: the strategy deliberately does not let a logging failure block the wait loop, so it proceeds to attempt the HTTP connection anyway. The underlying exception is attached to the warning for diagnosis.","triggerScenarios":"waitUntilReady catches any RuntimeException from constructing the log message (e.g. URI formatting/port extraction on a raw URI without a port). The message appears whenever that formatting code throws, regardless of whether the actual HTTP check succeeds.","commonSituations":"Containers exposing URIs with unusual formats (raw URIs without an explicit port, IPv6 literals, custom wait.forHttp paths); typically harmless noise during container startup with HttpWaitStrategy.","solutions":["Inspect the attached exception stack trace to see which URI formatting step failed","Set an explicit port via waitingFor(new HttpWaitStrategy().forPort(8080)) so the raw URI port fallback is not needed","Ignore it if the container still becomes ready — the wait proceeds normally after this warning"],"exampleFix":"// before\nnew HttpWaitStrategy().forStatusCode(200) // relies on raw URI port parsing\n// after\nnew HttpWaitStrategy().forPort(8080).forStatusCode(200)","handlingStrategy":"try-catch","validationCode":"// Ensure an explicit port is configured so raw URI parsing is not needed\nif (waitStrategy instanceof HttpWaitStrategy) {\n    ((HttpWaitStrategy) waitStrategy).forPort(8080);\n}","typeGuard":null,"tryCatchPattern":"// This warning is internal to the library; callers need no handling.\n// If wrapping waits yourself:\ntry {\n    waitUntilReady(container);\n} catch (RuntimeException e) {\n    // log and continue waiting, mirroring the strategy's own behavior\n    log.warn(\"wait failed, continuing\", e);\n}","preventionTips":["Always set forPort(...) explicitly on HttpWaitStrategy","Treat this warning as noise unless containers fail to become ready","Check the attached stack trace when diagnosing unusual URI schemes"],"tags":["wait-strategy","http","logging","non-fatal"],"backgroundTag":"unexpected-error-logged","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}