Skip to content

Commit

Permalink
HDDS-10027. NPE in VolumeInfoMetrics.getCommitted() (apache#5885)
Browse files Browse the repository at this point in the history
(cherry picked from commit ec2634d)
  • Loading branch information
adoroszlai authored and xichen01 committed Jul 17, 2024
1 parent d4125c4 commit 9928ab9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class HddsVolume extends StorageVolume {
private final VolumeIOStats volumeIOStats;
private final VolumeInfoMetrics volumeInfoMetrics;

private final AtomicLong committedBytes; // till Open containers become full
private final AtomicLong committedBytes = new AtomicLong(); // till Open containers become full

// Mentions the type of volume
private final VolumeType type = VolumeType.DATA_VOLUME;
Expand Down Expand Up @@ -121,7 +121,6 @@ private HddsVolume(Builder b) throws IOException {
this.getStorageDir().toString());
this.volumeInfoMetrics =
new VolumeInfoMetrics(b.getVolumeRootStr(), this);
this.committedBytes = new AtomicLong(0);

LOG.info("Creating HddsVolume: {} of storage type : {} capacity : {}",
getStorageDir(), b.getStorageType(),
Expand All @@ -134,7 +133,6 @@ private HddsVolume(Builder b) throws IOException {
this.setState(VolumeState.FAILED);
volumeIOStats = null;
volumeInfoMetrics = new VolumeInfoMetrics(b.getVolumeRootStr(), this);
committedBytes = null;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ public void testFailedVolumeSpace() throws IOException {
assertEquals(0, volumeInfoMetrics.getCapacity());
assertEquals(0, volumeInfoMetrics.getReserved());
assertEquals(0, volumeInfoMetrics.getTotalCapacity());
assertEquals(0, volumeInfoMetrics.getCommitted());
} finally {
// Shutdown the volume.
volume.shutdown();
Expand Down

0 comments on commit 9928ab9

Please sign in to comment.