Record Class CleanupReport

java.lang.Object
java.lang.Record
cloud.opencode.base.classloader.leak.CleanupReport
Record Components:
threadLocalsCleared - the number of ThreadLocal entries cleared | 已清除的 ThreadLocal 条目数
jdbcDriversRemoved - the number of JDBC drivers deregistered | 已注销的 JDBC 驱动数
shutdownHooksRemoved - the number of shutdown hooks removed | 已移除的关闭钩子数
timersCancelled - the number of timers cancelled | 已取消的计时器数
errors - error messages from failed cleanup attempts | 清理失败尝试的错误消息列表

public record CleanupReport(int threadLocalsCleared, int jdbcDriversRemoved, int shutdownHooksRemoved, int timersCancelled, List<String> errors) extends Record
Immutable report of ClassLoader cleanup operations ClassLoader 清理操作的不可变报告

Aggregates the results of all cleanup operations performed by LeakCleaner, including counts of cleaned resources and any errors encountered during cleanup.

汇总 LeakCleaner 执行的所有清理操作的结果, 包括已清理资源的计数以及清理过程中遇到的任何错误。

Features | 主要功能:

  • Counts of each type of resource cleaned - 每种已清理资源类型的计数
  • Error messages for failed cleanup attempts - 清理失败尝试的错误消息
  • Static factory for empty report - 空报告的静态工厂方法

Usage Examples | 使用示例:

CleanupReport report = LeakCleaner.cleanAll(myClassLoader);
System.out.println("JDBC drivers removed: " + report.jdbcDriversRemoved());
if (!report.errors().isEmpty()) {
    report.errors().forEach(System.err::println);
}

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是 (不可变记录)
Since:
JDK 25, opencode-base-classloader V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • CleanupReport

      public CleanupReport(int threadLocalsCleared, int jdbcDriversRemoved, int shutdownHooksRemoved, int timersCancelled, List<String> errors)
      Compact constructor with validation and defensive copy 带验证和防御性拷贝的紧凑构造器
      Throws:
      NullPointerException - if errors is null | 当 errors 为 null 时
      IllegalArgumentException - if any count is negative | 当任何计数为负数时
  • Method Details

    • empty

      public static CleanupReport empty()
      Create an empty cleanup report with all counts at zero and no errors 创建所有计数为零且无错误的空清理报告
      Returns:
      an empty CleanupReport | 一个空的 CleanupReport
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • threadLocalsCleared

      public int threadLocalsCleared()
      Returns the value of the threadLocalsCleared record component.
      Returns:
      the value of the threadLocalsCleared record component
    • jdbcDriversRemoved

      public int jdbcDriversRemoved()
      Returns the value of the jdbcDriversRemoved record component.
      Returns:
      the value of the jdbcDriversRemoved record component
    • shutdownHooksRemoved

      public int shutdownHooksRemoved()
      Returns the value of the shutdownHooksRemoved record component.
      Returns:
      the value of the shutdownHooksRemoved record component
    • timersCancelled

      public int timersCancelled()
      Returns the value of the timersCancelled record component.
      Returns:
      the value of the timersCancelled record component
    • errors

      public List<String> errors()
      Returns the value of the errors record component.
      Returns:
      the value of the errors record component