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 Summary
ConstructorsConstructorDescriptionCleanupReport(int threadLocalsCleared, int jdbcDriversRemoved, int shutdownHooksRemoved, int timersCancelled, List<String> errors) Compact constructor with validation and defensive copy 带验证和防御性拷贝的紧凑构造器 -
Method Summary
Modifier and TypeMethodDescriptionstatic CleanupReportempty()Create an empty cleanup report with all counts at zero and no errors 创建所有计数为零且无错误的空清理报告final booleanIndicates whether some other object is "equal to" this one.errors()Returns the value of theerrorsrecord component.final inthashCode()Returns a hash code value for this object.intReturns the value of thejdbcDriversRemovedrecord component.intReturns the value of theshutdownHooksRemovedrecord component.intReturns the value of thethreadLocalsClearedrecord component.intReturns the value of thetimersCancelledrecord component.final StringtoString()Returns a string representation of this record class.
-
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
Create an empty cleanup report with all counts at zero and no errors 创建所有计数为零且无错误的空清理报告- Returns:
- an empty CleanupReport | 一个空的 CleanupReport
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
threadLocalsCleared
public int threadLocalsCleared()Returns the value of thethreadLocalsClearedrecord component.- Returns:
- the value of the
threadLocalsClearedrecord component
-
jdbcDriversRemoved
public int jdbcDriversRemoved()Returns the value of thejdbcDriversRemovedrecord component.- Returns:
- the value of the
jdbcDriversRemovedrecord component
-
shutdownHooksRemoved
public int shutdownHooksRemoved()Returns the value of theshutdownHooksRemovedrecord component.- Returns:
- the value of the
shutdownHooksRemovedrecord component
-
timersCancelled
public int timersCancelled()Returns the value of thetimersCancelledrecord component.- Returns:
- the value of the
timersCancelledrecord component
-
errors
-