fix: address SonarQube reliability issues
Some checks failed
CI / cleanup-branch (push) Has been skipped
CI / build (push) Failing after 39s
CI / docker (push) Has been skipped
CI / deploy (push) Has been skipped
CI / deploy-feature (push) Has been skipped

- ElkDiagramRenderer.getElkRoot(): add null guard to prevent NPE
  when node is null (SQ java:S2259)
- WriteBuffer: add offerOrWarn() that logs when buffer is full instead
  of silently dropping data. ChunkAccumulator now uses this method
  so ingestion backpressure is visible in logs (SQ java:S899)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-01 10:55:31 +02:00
parent d4dbfa7ae6
commit e50c9fa60d
3 changed files with 13 additions and 2 deletions

View File

@@ -110,8 +110,8 @@ public class StorageBeanConfig {
WriteBuffer<ChunkAccumulator.ProcessorBatch> processorBatchBuffer,
DiagramStore diagramStore) {
return new ChunkAccumulator(
executionBuffer::offer,
processorBatchBuffer::offer,
executionBuffer::offerOrWarn,
processorBatchBuffer::offerOrWarn,
diagramStore,
java.time.Duration.ofMinutes(5));
}

View File

@@ -884,6 +884,7 @@ public class ElkDiagramRenderer implements DiagramRenderer {
}
private ElkNode getElkRoot(ElkNode node) {
if (node == null) return null;
ElkNode current = node;
while (current.getParent() != null) {
current = current.getParent();

View File

@@ -38,6 +38,16 @@ public class WriteBuffer<T> {
return queue.offer(item);
}
/**
* Offer an item, logging a warning if the buffer is full.
* Use this as a {@code Consumer<T>} when the caller cannot handle backpressure.
*/
public void offerOrWarn(T item) {
if (!queue.offer(item)) {
log.warn("WriteBuffer full (capacity={}), item dropped", capacity);
}
}
/**
* Offer a batch of items with all-or-nothing semantics.
* If the buffer does not have enough remaining capacity for the entire batch,