Skip to content

Commit

Permalink
Add changelog entry and apply spotless fixes
Browse files Browse the repository at this point in the history
This commit adds a new entry to `CHANGELOG.md` detailing the fix
for the `ClassCastException` in `DebugMetrics`. Additionally,
`DebugMetricsTest.java` has been reformatted using `spotlessApply`
to ensure code style consistency.

These changes contribute to maintaining clear documentation and
code quality in the project.

Resolves: hyperledger#7383
Signed-off-by: Ade Lucas <ade.lucas@consensys.net>
  • Loading branch information
cloudspores committed Aug 20, 2024
1 parent ea63ce2 commit 5b11a84
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [Unreleased]

### Fixed
- **DebugMetrics**: Fixed a `ClassCastException` occurring in `DebugMetrics` when handling nested metric structures. Previously, `Double` values within these structures were incorrectly cast to `Map` objects, leading to errors. This update allows for proper handling of both direct values and nested structures at the same level. Issue# [#7383]

### Tests
- Added a comprehensive test case to reproduce the bug and verify the fix for the `ClassCastException` in `DebugMetrics`. This ensures that complex, dynamically nested metric structures can be handled without errors.

## Next release

### Upcoming Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,32 +90,30 @@ public void shouldNestObservationsByLabel() {
public void shouldHandleDoubleValuesInNestedStructureWithoutClassCastException() {
// Tests fix for issue# 7383: debug_metrics method error
when(metricsSystem.streamObservations())
.thenReturn(
Stream.of(
// This creates a double value for "a"
new Observation(BLOCKCHAIN, "nested_metric", 1.0, List.of("a")),
// This attempts to create a nested structure under "a", which was previously a double
new Observation(BLOCKCHAIN, "nested_metric", 2.0, asList("a", "b")),
// This adds another level of nesting
new Observation(BLOCKCHAIN, "nested_metric", 3.0, asList("a", "b", "c"))
));
.thenReturn(
Stream.of(
// This creates a double value for "a"
new Observation(BLOCKCHAIN, "nested_metric", 1.0, List.of("a")),
// This attempts to create a nested structure under "a", which was previously a
// double
new Observation(BLOCKCHAIN, "nested_metric", 2.0, asList("a", "b")),
// This adds another level of nesting
new Observation(BLOCKCHAIN, "nested_metric", 3.0, asList("a", "b", "c"))));

assertResponse(
ImmutableMap.of(
BLOCKCHAIN.getName(),
ImmutableMap.of(
BLOCKCHAIN.getName(),
"nested_metric",
ImmutableMap.of(
"a",
ImmutableMap.of(
"nested_metric", ImmutableMap.of(
"a", ImmutableMap.of(
"value", 1.0,
"b", ImmutableMap.of(
"value", 2.0,
"c", 3.0
)
)
)
)
)
);
"value",
1.0,
"b",
ImmutableMap.of(
"value", 2.0,
"c", 3.0))))));
}

private void assertResponse(final ImmutableMap<String, Object> expectedResponse) {
Expand Down

0 comments on commit 5b11a84

Please sign in to comment.