Skip to content

Commit

Permalink
Avoid ClassNotFoundException yet again
Browse files Browse the repository at this point in the history
In some environments, the com.sun.management classes needed for GC metrics are not available. Even private method signatures containing them causes a ClassNotFoundException.

Fixes gh-2557
  • Loading branch information
shakuzen committed Apr 12, 2021
1 parent 588f74d commit b433283
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void bindTo(MeterRegistry registry) {
// Some GC implementations such as G1 can reduce the old gen size as part of a minor GC. To track the
// live data size we record the value if we see a reduction in the old gen heap size or
// after a major GC.
if (oldAfter < oldBefore || isMajorGc(notificationInfo)) {
if (oldAfter < oldBefore || isMajorGc(notificationInfo.getGcName())) {
liveDataSize.set(oldAfter);
final long oldMaxAfter = after.get(oldGenPoolName).getMax();
maxDataSize.set(oldMaxAfter);
Expand Down Expand Up @@ -193,8 +193,8 @@ public void bindTo(MeterRegistry registry) {
}
}

private boolean isMajorGc(GarbageCollectionNotificationInfo notificationInfo) {
return GcGenerationAge.fromGcName(notificationInfo.getGcName()) == GcGenerationAge.OLD;
private boolean isMajorGc(String gcName) {
return GcGenerationAge.fromGcName(gcName) == GcGenerationAge.OLD;
}

private static boolean isManagementExtensionsPresent() {
Expand Down

0 comments on commit b433283

Please sign in to comment.