Commit e40df36
fix: Allow -1 as sentinel value for heapUsedBytes in ResourceSnapshot
Problem:
- ResourceSnapshot constructor rejected ALL negative values for heapUsedBytes
- ApplicationResourceMonitor.estimateHeapUsage() returns -1 to indicate "not available"
(per-application heap tracking requires JVMTI instrumentation)
- This caused constructor to throw IllegalArgumentException when creating snapshots
- CRITICAL bug preventing resource monitoring from working
Solution:
- Modified validation to allow -1 as special sentinel value
- Changed: if (heapUsedBytes < 0) to if (heapUsedBytes < -1)
- Updated error message to clarify -1 is allowed for N/A
- Follows standard monitoring convention where -1 = "not available"
Benefits:
- Fixes crash in ApplicationResourceMonitor.collectMetrics()
- Allows resource monitoring to work without heap tracking instrumentation
- Follows common monitoring conventions (-1 for unavailable metrics)
- Still validates against invalid negative values (< -1)
Location: jplatform-api/src/main/java/org/flossware/jplatform/api/ResourceSnapshot.java:57-60
Closes #126
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent b5554c1 commit e40df36
1 file changed
Lines changed: 3 additions & 2 deletions
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
0 commit comments