fix: address SonarQube reliability issues
- 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:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user