DefaultResourceLeakDetectorFactory Class — netty Architecture
Architecture documentation for the DefaultResourceLeakDetectorFactory class in ResourceLeakDetectorFactory.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a2baa9f7_c2e2_a3ea_bda8_069d2223e0f6["DefaultResourceLeakDetectorFactory"] 6494a4e8_0a39_e01c_c54c_4e3c3a1ea717["ResourceLeakDetectorFactory.java"] a2baa9f7_c2e2_a3ea_bda8_069d2223e0f6 -->|defined in| 6494a4e8_0a39_e01c_c54c_4e3c3a1ea717 c60c5afd_0eec_4cc2_2360_bd27a5bf6351["DefaultResourceLeakDetectorFactory()"] a2baa9f7_c2e2_a3ea_bda8_069d2223e0f6 -->|method| c60c5afd_0eec_4cc2_2360_bd27a5bf6351 eaf52ecb_4534_3352_92bb_972a9a81bad9["obsoleteCustomClassConstructor()"] a2baa9f7_c2e2_a3ea_bda8_069d2223e0f6 -->|method| eaf52ecb_4534_3352_92bb_972a9a81bad9 c4d6577f_c030_0f22_6a7c_461c9154c24a["customClassConstructor()"] a2baa9f7_c2e2_a3ea_bda8_069d2223e0f6 -->|method| c4d6577f_c030_0f22_6a7c_461c9154c24a 6253fca3_3624_5884_5f7d_7404ebd9a3e8["newResourceLeakDetector()"] a2baa9f7_c2e2_a3ea_bda8_069d2223e0f6 -->|method| 6253fca3_3624_5884_5f7d_7404ebd9a3e8
Relationship Graph
Source Code
common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java lines 98–199
private static final class DefaultResourceLeakDetectorFactory extends ResourceLeakDetectorFactory {
private final Constructor<?> obsoleteCustomClassConstructor;
private final Constructor<?> customClassConstructor;
DefaultResourceLeakDetectorFactory() {
String customLeakDetector;
try {
customLeakDetector = SystemPropertyUtil.get("io.netty.customResourceLeakDetector");
} catch (Throwable cause) {
logger.error("Could not access System property: io.netty.customResourceLeakDetector", cause);
customLeakDetector = null;
}
if (customLeakDetector == null) {
obsoleteCustomClassConstructor = customClassConstructor = null;
} else {
obsoleteCustomClassConstructor = obsoleteCustomClassConstructor(customLeakDetector);
customClassConstructor = customClassConstructor(customLeakDetector);
}
}
private static Constructor<?> obsoleteCustomClassConstructor(String customLeakDetector) {
try {
final Class<?> detectorClass = Class.forName(customLeakDetector, true,
PlatformDependent.getSystemClassLoader());
if (ResourceLeakDetector.class.isAssignableFrom(detectorClass)) {
return detectorClass.getConstructor(Class.class, int.class, long.class);
} else {
logger.error("Class {} does not inherit from ResourceLeakDetector.", customLeakDetector);
}
} catch (Throwable t) {
logger.error("Could not load custom resource leak detector class provided: {}",
customLeakDetector, t);
}
return null;
}
private static Constructor<?> customClassConstructor(String customLeakDetector) {
try {
final Class<?> detectorClass = Class.forName(customLeakDetector, true,
PlatformDependent.getSystemClassLoader());
if (ResourceLeakDetector.class.isAssignableFrom(detectorClass)) {
return detectorClass.getConstructor(Class.class, int.class);
} else {
logger.error("Class {} does not inherit from ResourceLeakDetector.", customLeakDetector);
}
} catch (Throwable t) {
logger.error("Could not load custom resource leak detector class provided: {}",
customLeakDetector, t);
}
return null;
}
@SuppressWarnings("deprecation")
@Override
public <T> ResourceLeakDetector<T> newResourceLeakDetector(Class<T> resource, int samplingInterval,
long maxActive) {
if (obsoleteCustomClassConstructor != null) {
try {
@SuppressWarnings("unchecked")
ResourceLeakDetector<T> leakDetector =
(ResourceLeakDetector<T>) obsoleteCustomClassConstructor.newInstance(
resource, samplingInterval, maxActive);
logger.debug("Loaded custom ResourceLeakDetector: {}",
obsoleteCustomClassConstructor.getDeclaringClass().getName());
return leakDetector;
} catch (Throwable t) {
logger.error(
"Could not load custom resource leak detector provided: {} with the given resource: {}",
obsoleteCustomClassConstructor.getDeclaringClass().getName(), resource, t);
}
}
ResourceLeakDetector<T> resourceLeakDetector = new ResourceLeakDetector<T>(resource, samplingInterval,
maxActive);
logger.debug("Loaded default ResourceLeakDetector: {}", resourceLeakDetector);
return resourceLeakDetector;
}
@Override
Source
Frequently Asked Questions
What is the DefaultResourceLeakDetectorFactory class?
DefaultResourceLeakDetectorFactory is a class in the netty codebase, defined in common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java.
Where is DefaultResourceLeakDetectorFactory defined?
DefaultResourceLeakDetectorFactory is defined in common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java at line 98.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free