{"record":{"id":"24468ce0100c904c","repo":"SonarSource/sonarqube","slug":"dump-is-already-published","errorCode":null,"errorMessage":"Dump is already published","messagePattern":"Dump is already published","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/DumpWriterImpl.java","lineNumber":100,"sourceCode":"      throw new IllegalStateException(\"Metadata is missing\");\n    }\n    File zip = tempFolder.newFile();\n    FILES2.zipDir(rootDir, zip);\n\n    File targetZip = projectExportDumpFS.exportDumpOf(descriptor);\n    FILES2.deleteIfExists(targetZip);\n    FILES2.moveFile(zip, targetZip);\n    FILES2.deleteIfExists(rootDir);\n    LoggerFactory.getLogger(getClass()).atInfo()\n      .addArgument(humanReadableByteCountSI(sizeOf(targetZip)))\n      .addArgument(targetZip.getAbsolutePath())\n      .log(\"Dump file published | size={} | path={}\");\n    published.set(true);\n  }\n\n  private void checkNotPublished() {\n    if (published.get()) {\n      throw new IllegalStateException(\"Dump is already published\");\n    }\n  }\n}\n","sourceCodeStart":82,"sourceCodeEnd":104,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/DumpWriterImpl.java#L82-L104","documentation":"Once publish() has zipped and copied the dump to the export filesystem, published is set to true and no further writes, stream writers, or publish calls are allowed. checkNotPublished() throws IllegalStateException \"Dump is already published\" on any subsequent operation. This prevents mutating or re-publishing a finalized dump.","triggerScenarios":"Calling write(...), newStreamWriter(...), or publish() again after publish() completed successfully on the same DumpWriterImpl instance.","commonSituations":"A retry mechanism re-invoking publish() after success; an export step running twice in the pipeline after the dump was finalized; custom code writing extra elements after publish.","solutions":["Remove duplicate publish() calls — make the finalize step idempotent or guarded by a flag","Ensure all write steps complete before publish() is invoked","For a new export, instantiate a fresh DumpWriterImpl rather than reusing the published one"],"exampleFix":"// before\nwriter.publish();\nwriter.write(metadata); // fails: already published\n// after\nwriter.write(metadata);\nwriter.publish(); // publish last, exactly once","handlingStrategy":"try-catch","validationCode":"// guard retries with a completed flag\nif (exportCompleted.get()) { return; }","typeGuard":null,"tryCatchPattern":"try { writer.publish(); } catch (IllegalStateException e) { if (!e.getMessage().contains(\"already published\")) throw e; /* idempotent success */ }","preventionTips":["Make publish idempotent at the call site with an AtomicBoolean/once-guard","Ensure retry logic checks whether the export already completed successfully","Never write additional elements after finalize; order all steps before publish"],"tags":["sonarqube","project-export","state","lifecycle"],"backgroundTag":"invalid-state-transition","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}