Commit 0918a3c
fix: Add null handling to PrometheusFormatter.escapeLabelValue()
Fixes #205
Added null check to escapeLabelValue() method to prevent NullPointerException
when label maps contain null values. Returns empty string for null values
as Prometheus doesn't support null label values.
Changes:
- escapeLabelValue(): Check if value is null before calling replace() methods
- Return empty string for null values (Prometheus compatible)
- Updated javadoc to document null handling behavior
- Added test testLabelValueNull() to verify null labels are handled correctly
- Test confirms null values are converted to empty strings without errors
This prevents metrics export failures when applications have null metadata
and ensures all metrics are successfully formatted.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 62de314 commit 0918a3c
2 files changed
Lines changed: 21 additions & 2 deletions
File tree
- jplatform-metrics-prometheus/src
- main/java/org/flossware/jplatform/metrics/prometheus
- test/java/org/flossware/jplatform/metrics/prometheus
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
| 124 | + | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
146 | 162 | | |
0 commit comments