SonarSource/sonarqube · error · IllegalStateException

Dump is already published

Error message

Dump is already published

What it means

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.

Source

Thrown at server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/DumpWriterImpl.java:100

      throw new IllegalStateException("Metadata is missing");
    }
    File zip = tempFolder.newFile();
    FILES2.zipDir(rootDir, zip);

    File targetZip = projectExportDumpFS.exportDumpOf(descriptor);
    FILES2.deleteIfExists(targetZip);
    FILES2.moveFile(zip, targetZip);
    FILES2.deleteIfExists(rootDir);
    LoggerFactory.getLogger(getClass()).atInfo()
      .addArgument(humanReadableByteCountSI(sizeOf(targetZip)))
      .addArgument(targetZip.getAbsolutePath())
      .log("Dump file published | size={} | path={}");
    published.set(true);
  }

  private void checkNotPublished() {
    if (published.get()) {
      throw new IllegalStateException("Dump is already published");
    }
  }
}

View on GitHub (pinned to 184c821202)

Solutions

  1. Remove duplicate publish() calls — make the finalize step idempotent or guarded by a flag
  2. Ensure all write steps complete before publish() is invoked
  3. For a new export, instantiate a fresh DumpWriterImpl rather than reusing the published one

Example fix

// before
writer.publish();
writer.write(metadata); // fails: already published
// after
writer.write(metadata);
writer.publish(); // publish last, exactly once
Defensive patterns

Strategy: try-catch

Validate before calling

// guard retries with a completed flag
if (exportCompleted.get()) { return; }

Try / catch

try { writer.publish(); } catch (IllegalStateException e) { if (!e.getMessage().contains("already published")) throw e; /* idempotent success */ }

Prevention

When it happens

Trigger: Calling write(...), newStreamWriter(...), or publish() again after publish() completed successfully on the same DumpWriterImpl instance.

Common situations: 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.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/24468ce0100c904c. Report an issue: GitHub.