ResourceLeakDetectorFactory Class — netty Architecture
Architecture documentation for the ResourceLeakDetectorFactory class in ResourceLeakDetectorFactory.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a846e09b_7e36_b931_6b1b_cdf8f259124a["ResourceLeakDetectorFactory"] 6494a4e8_0a39_e01c_c54c_4e3c3a1ea717["ResourceLeakDetectorFactory.java"] a846e09b_7e36_b931_6b1b_cdf8f259124a -->|defined in| 6494a4e8_0a39_e01c_c54c_4e3c3a1ea717 bc46f188_b81c_22ed_9b3f_667e4e886fb2["ResourceLeakDetectorFactory()"] a846e09b_7e36_b931_6b1b_cdf8f259124a -->|method| bc46f188_b81c_22ed_9b3f_667e4e886fb2 d1600afa_23bc_1a37_2bd0_7e44eeab2b8b["setResourceLeakDetectorFactory()"] a846e09b_7e36_b931_6b1b_cdf8f259124a -->|method| d1600afa_23bc_1a37_2bd0_7e44eeab2b8b 70ae2cba_4e67_6af8_ed29_8669c301e51f["newResourceLeakDetector()"] a846e09b_7e36_b931_6b1b_cdf8f259124a -->|method| 70ae2cba_4e67_6af8_ed29_8669c301e51f
Relationship Graph
Source Code
common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java lines 30–200
public abstract class ResourceLeakDetectorFactory {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(ResourceLeakDetectorFactory.class);
private static volatile ResourceLeakDetectorFactory factoryInstance = new DefaultResourceLeakDetectorFactory();
/**
* Get the singleton instance of this factory class.
*
* @return the current {@link ResourceLeakDetectorFactory}
*/
public static ResourceLeakDetectorFactory instance() {
return factoryInstance;
}
/**
* Set the factory's singleton instance. This has to be called before the static initializer of the
* {@link ResourceLeakDetector} is called by all the callers of this factory. That is, before initializing a
* Netty Bootstrap.
*
* @param factory the instance that will become the current {@link ResourceLeakDetectorFactory}'s singleton
*/
public static void setResourceLeakDetectorFactory(ResourceLeakDetectorFactory factory) {
factoryInstance = ObjectUtil.checkNotNull(factory, "factory");
}
/**
* Returns a new instance of a {@link ResourceLeakDetector} with the given resource class.
*
* @param resource the resource class used to initialize the {@link ResourceLeakDetector}
* @param <T> the type of the resource class
* @return a new instance of {@link ResourceLeakDetector}
*/
public final <T> ResourceLeakDetector<T> newResourceLeakDetector(Class<T> resource) {
return newResourceLeakDetector(resource, ResourceLeakDetector.SAMPLING_INTERVAL);
}
/**
* @deprecated Use {@link #newResourceLeakDetector(Class, int)} instead.
* <p>
* Returns a new instance of a {@link ResourceLeakDetector} with the given resource class.
*
* @param resource the resource class used to initialize the {@link ResourceLeakDetector}
* @param samplingInterval the interval on which sampling takes place
* @param maxActive This is deprecated and will be ignored.
* @param <T> the type of the resource class
* @return a new instance of {@link ResourceLeakDetector}
*/
@Deprecated
public abstract <T> ResourceLeakDetector<T> newResourceLeakDetector(
Class<T> resource, int samplingInterval, long maxActive);
/**
* Returns a new instance of a {@link ResourceLeakDetector} with the given resource class.
*
* @param resource the resource class used to initialize the {@link ResourceLeakDetector}
* @param samplingInterval the interval on which sampling takes place
* @param <T> the type of the resource class
* @return a new instance of {@link ResourceLeakDetector}
*/
@SuppressWarnings("deprecation")
public <T> ResourceLeakDetector<T> newResourceLeakDetector(Class<T> resource, int samplingInterval) {
ObjectUtil.checkPositive(samplingInterval, "samplingInterval");
return newResourceLeakDetector(resource, samplingInterval, Long.MAX_VALUE);
}
/**
* Default implementation that loads custom leak detector via system property
*/
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) {
Source
Frequently Asked Questions
What is the ResourceLeakDetectorFactory class?
ResourceLeakDetectorFactory is a class in the netty codebase, defined in common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java.
Where is ResourceLeakDetectorFactory defined?
ResourceLeakDetectorFactory is defined in common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java at line 30.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free