This is an automated email from the ASF dual-hosted git repository.
yuluo-yx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
The following commit(s) were added to refs/heads/master by this push:
new 6ec4958997 [fix] Prevent NPE when VictoriaMetrics compression is unset
(#4199)
6ec4958997 is described below
commit 6ec4958997206dee86ffea335354e744558bf407
Author: shown <[email protected]>
AuthorDate: Sun Jul 12 17:25:02 2026 +0800
[fix] Prevent NPE when VictoriaMetrics compression is unset (#4199)
---
.../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: [email protected]
For additional commands, e-mail: [email protected]