You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@hertzbeat.apache.org by sh...@apache.org on 2026/07/11 14:52:04 UTC
(hertzbeat) 01/01: [fix] Prevent NPE when VictoriaMetrics compression is unset
This is an automated email from the ASF dual-hosted git repository.
yuluo-yx pushed a commit to branch 0711-yuluo/fix-cpu
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
commit 501e40de83ff0c6adf73d2c2deb03bffc78af67c
Author: yuluo-yx <yu...@gmail.com>
AuthorDate: Sat Jul 11 22:49:51 2026 +0800
[fix] Prevent NPE when VictoriaMetrics compression is unset
Default the nested compression configuration during property binding and cover both explicit and omitted values.
Fixes #4058
---
.../store/history/tsdb/vm/VictoriaMetricsProperties.java | 2 +-
.../history/tsdb/vm/VictoriaMetricsPropertiesTest.java | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsProperties.java b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsProperties.java
index dccb01ca03..8e3c6bd332 100644
--- a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsProperties.java
+++ b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsProperties.java
@@ -39,7 +39,7 @@ public record VictoriaMetricsProperties(@DefaultValue("false") boolean enabled,
record InsertConfig(@DefaultValue("100") int bufferSize,
@DefaultValue("3") int flushInterval,
- Compression compression) {
+ @DefaultValue Compression compression) {
}
record Compression(@DefaultValue("false") boolean enabled) {
diff --git a/hertzbeat-warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsPropertiesTest.java b/hertzbeat-warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsPropertiesTest.java
index 1ad1873966..c1c61d9049 100644
--- a/hertzbeat-warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsPropertiesTest.java
+++ b/hertzbeat-warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsPropertiesTest.java
@@ -18,9 +18,13 @@
package org.apache.hertzbeat.warehouse.store.history.tsdb.vm;
import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
import org.springframework.boot.test.context.SpringBootTest;
/**
@@ -58,4 +62,16 @@ class VictoriaMetricsPropertiesTest {
assertThat(properties.insert().compression().enabled()).isTrue();
}
+ @Test
+ void compressionShouldDefaultToDisabledWhenNotConfigured() {
+ var source = new MapConfigurationPropertySource(Map.of(
+ "warehouse.store.victoria-metrics.insert.buffer-size", "999"));
+ var defaultProperties = new Binder(source)
+ .bind("warehouse.store.victoria-metrics", VictoriaMetricsProperties.class)
+ .get();
+
+ assertThat(defaultProperties.insert().compression()).isNotNull();
+ assertThat(defaultProperties.insert().compression().enabled()).isFalse();
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: notifications-help@hertzbeat.apache.org