{"record":{"id":"e267335ed8d688b6","repo":"apache/druid","slug":"failed-to-close-openlineage-http-client","errorCode":null,"errorMessage":"Failed to close OpenLineage HTTP client","messagePattern":"Failed to close OpenLineage HTTP client","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"extensions-contrib/openlineage-emitter/src/main/java/org/apache/druid/extensions/openlineage/OpenLineageRequestLogger.java","lineNumber":199,"sourceCode":"  @Override\n  public void stop()\n  {\n    if (emitExecutor != null) {\n      emitExecutor.shutdown();\n      try {\n        if (!emitExecutor.awaitTermination(5, TimeUnit.SECONDS)) {\n          emitExecutor.shutdownNow();\n        }\n      }\n      catch (InterruptedException e) {\n        emitExecutor.shutdownNow();\n        Thread.currentThread().interrupt();\n      }\n    }\n    if (httpClient instanceof Closeable) {\n      CloseableUtils.closeAndSuppressExceptions(\n          (Closeable) httpClient,\n          e -> log.warn(e, \"Failed to close OpenLineage HTTP client\")\n      );\n    }\n    log.info(\"Stopped OpenLineage request logger\");\n  }\n\n  @Override\n  public void logNativeQuery(RequestLogLine requestLogLine) throws IOException\n  {\n    if (requestLogLine.getQuery() == null) {\n      return;\n    }\n\n    String queryType = requestLogLine.getQuery().getType();\n\n    if (excludedNativeQueryTypes.contains(queryType)) {\n      return;\n    }\n","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/openlineage-emitter/src/main/java/org/apache/druid/extensions/openlineage/OpenLineageRequestLogger.java#L181-L217","documentation":"When the OpenLineage request logger stops, it shuts down its worker executor and then closes the underlying HTTP client. If closing the client throws, the warning 'Failed to close OpenLineage HTTP client' is logged (exception suppressed) so shutdown still completes.","triggerScenarios":"Calling stop() while the OkHttp/Closeable HTTP client's connection pool or dispatcher cannot shut down cleanly — typically leaked connections, in-flight requests, or an already-closed client being closed twice.","commonSituations":"Stopping Druid during shutdown while OpenLineage POSTs are still in flight; calling stop() twice on the same logger; network stack issues keeping sockets open during close.","solutions":["Check for double-stop: ensure stop() is called only once in the service lifecycle","Make sure emit workers are drained/interrupted before close (executor shutdown + awaitTermination) precedes the client close","If persistent, upgrade the HTTP client library; this is usually benign and suppressed anyway","Verify no custom httpClient is shared with other components that close it first"],"exampleFix":"// before\nopenLineageRequestLogger.stop();\nopenLineageRequestLogger.stop(); // second close fails\n// after\nif (!stopped) {\n  openLineageRequestLogger.stop();\n  stopped = true;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { logger.stop(); } catch (RuntimeException e) { log.warn(\"Suppress during shutdown\", e); }","preventionTips":["Call stop() exactly once per lifecycle","Avoid sharing the httpClient with other components","Drain in-flight emits before shutdown"],"tags":["http-client","shutdown","openlineage","resource-cleanup"],"backgroundTag":"connection-refused","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}