{"record":{"id":"40212fa00da3e1fd","repo":"apache/druid","slug":"can-t-stop-40212f","errorCode":null,"errorMessage":"can't stop.","messagePattern":"can't stop\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/client/HttpServerInventoryView.java","lineNumber":261,"sourceCode":"            this::emitServerStatusMetrics\n        );\n\n        lifecycleLock.started();\n      }\n      finally {\n        lifecycleLock.exitStart();\n      }\n\n      log.info(\"Started executor[%s].\", execNamePrefix);\n    }\n  }\n\n  @LifecycleStop\n  public void stop()\n  {\n    synchronized (lifecycleLock) {\n      if (!lifecycleLock.canStop()) {\n        throw new ISE(\"can't stop.\");\n      }\n\n      log.info(\"Stopping executor[%s].\", execNamePrefix);\n\n      if (inventorySyncExecutor != null) {\n        inventorySyncExecutor.shutdownNow();\n      }\n      if (monitoringExecutor != null) {\n        monitoringExecutor.shutdownNow();\n      }\n\n      log.info(\"Stopped executor[%s].\", execNamePrefix);\n    }\n  }\n\n  @Override\n  public void registerSegmentCallback(\n      Executor exec,","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/client/HttpServerInventoryView.java#L243-L279","documentation":"HttpServerInventoryView.stop() throws ISE when lifecycleLock.canStop() is false, meaning the lifecycle was never started or has already been stopped. It prevents stopping a component that is not in a running state.","triggerScenarios":"Calling stop() before start(); calling stop() twice; stopping an instance whose lifecycle was never advanced (e.g. construction failed before start).","commonSituations":"Shutdown hooks registered multiple times; test teardown calling stop() when setup failed before start(); idempotent-shutdown attempts on an already-stopped coordinator component.","solutions":["Track whether start() succeeded and only call stop() in that case","Wrap stop() in a check or catch ISE for idempotent teardown paths","In tests, use a try/finally that tolerates a never-started instance","Create a fresh instance if the lifecycle must be restarted after stop"],"exampleFix":"// before\nview.stop(); // may throw ISE if never started\n// after\ntry {\n  view.stop();\n} catch (IllegalStateException e) {\n  // already stopped or never started\n}","handlingStrategy":"try-catch","validationCode":"if (viewStarted) view.stop();","typeGuard":null,"tryCatchPattern":"try { view.stop(); } catch (IllegalStateException e) { /* never started or already stopped */ }","preventionTips":["Pair start/stop in try/finally from a single owner","Never call stop() on a never-started instance","Make teardown idempotent"],"tags":["lifecycle","illegal-state","druid"],"backgroundTag":"invalid-state-transition","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"}