Refine search
/** * Get the singleton testing allocator. * @return the singleton allocator, creating it if one does not exist. */ public static TestByteBufAllocator getInstance() { TestByteBufAllocator result = INSTANCE.get(); if (result == null) { ResourceLeakDetector.Level oldLevel = ResourceLeakDetector.getLevel(); ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID); INSTANCE.compareAndSet(null, new TestByteBufAllocator(oldLevel)); result = INSTANCE.get(); } return result; }
private void reportLeak() { if (!logger.isErrorEnabled()) { clearRefQueue(); return; } // Detect and report previous leaks. for (;;) { @SuppressWarnings("unchecked") DefaultResourceLeak ref = (DefaultResourceLeak) refQueue.poll(); if (ref == null) { break; } if (!ref.dispose()) { continue; } String records = ref.toString(); if (reportedLeaks.putIfAbsent(records, Boolean.TRUE) == null) { if (records.isEmpty()) { reportUntracedLeak(resourceType); } else { reportTracedLeak(resourceType, records); } } } }
protected static CompositeByteBuf toLeakAwareBuffer(CompositeByteBuf buf) { ResourceLeakTracker<ByteBuf> leak; switch (ResourceLeakDetector.getLevel()) { case SIMPLE: leak = AbstractByteBuf.leakDetector.track(buf); if (leak != null) { buf = new SimpleLeakAwareCompositeByteBuf(buf, leak); } break; case ADVANCED: case PARANOID: leak = AbstractByteBuf.leakDetector.track(buf); if (leak != null) { buf = new AdvancedLeakAwareCompositeByteBuf(buf, leak); } break; default: break; } return buf; }
/** * @deprecated Use {@link #setLevel(Level)} instead. */ @Deprecated public static void setEnabled(boolean enabled) { setLevel(enabled? Level.SIMPLE : Level.DISABLED); }
@Override public boolean handle(CommandSender sender, String[] args) { if (ResourceLeakDetector.isEnabled()) { ResourceLeakDetector.setLevel(Level.DISABLED); sender.sendMessage(ChatColor.YELLOW + "Disabled leak detector"); } else { ResourceLeakDetector.setLevel(Level.PARANOID); sender.sendMessage(ChatColor.YELLOW + "Enabled leak detector"); } return true; }
DefaultOpenSslKeyMaterial(long chain, long privateKey, X509Certificate[] x509CertificateChain) { this.chain = chain; this.privateKey = privateKey; this.x509CertificateChain = x509CertificateChain; leak = leakDetector.track(this); }
@Override public <T> ResourceLeakDetector<T> newResourceLeakDetector(Class<T> resource, int samplingInterval) { if (customClassConstructor != null) { try { @SuppressWarnings("unchecked") ResourceLeakDetector<T> leakDetector = (ResourceLeakDetector<T>) customClassConstructor.newInstance(resource, samplingInterval); logger.debug("Loaded custom ResourceLeakDetector: {}", customClassConstructor.getDeclaringClass().getName()); return leakDetector; } catch (Throwable t) { logger.error( "Could not load custom resource leak detector provided: {} with the given resource: {}", customClassConstructor.getDeclaringClass().getName(), resource, t); } } ResourceLeakDetector<T> resourceLeakDetector = new ResourceLeakDetector<T>(resource, samplingInterval); logger.debug("Loaded default ResourceLeakDetector: {}", resourceLeakDetector); return resourceLeakDetector; } }
@Override protected void reportUntracedLeak(String resourceType) { super.reportUntracedLeak(resourceType); leakCounter.incrementAndGet(); resetReportedLeaks(); }
@Override protected void reportTracedLeak(String resourceType, String records) { super.reportTracedLeak(resourceType, records); leakCounter.incrementAndGet(); resetReportedLeaks(); }
/** * @deprecated Use {@link #setLevel(Level)} instead. */ @Deprecated public static void setEnabled(boolean enabled) { setLevel(enabled? Level.SIMPLE : Level.DISABLED); }
DefaultOpenSslKeyMaterial(long chain, long privateKey) { this.chain = chain; this.privateKey = privateKey; leak = leakDetector.track(this); }
@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 protected void reportUntracedLeak(String resourceType) { super.reportUntracedLeak(resourceType); leakCounter.incrementAndGet(); resetReportedLeaks(); }
@Override protected void reportTracedLeak(String resourceType, String records) { super.reportTracedLeak(resourceType, records); leakCounter.incrementAndGet(); resetReportedLeaks(); }
/** * @deprecated Use {@link #setLevel(Level)} instead. */ @Deprecated public static void setEnabled(boolean enabled) { setLevel(enabled? Level.SIMPLE : Level.DISABLED); }
protected static ByteBuf toLeakAwareBuffer(ByteBuf buf) { ResourceLeakTracker<ByteBuf> leak; switch (ResourceLeakDetector.getLevel()) { case SIMPLE: leak = AbstractByteBuf.leakDetector.track(buf); if (leak != null) { buf = new SimpleLeakAwareByteBuf(buf, leak); } break; case ADVANCED: case PARANOID: leak = AbstractByteBuf.leakDetector.track(buf); if (leak != null) { buf = new AdvancedLeakAwareByteBuf(buf, leak); } break; default: break; } return buf; }
private void reportLeak() { if (!logger.isErrorEnabled()) { clearRefQueue(); return; } // Detect and report previous leaks. for (;;) { @SuppressWarnings("unchecked") DefaultResourceLeak ref = (DefaultResourceLeak) refQueue.poll(); if (ref == null) { break; } if (!ref.dispose()) { continue; } String records = ref.toString(); if (reportedLeaks.putIfAbsent(records, Boolean.TRUE) == null) { if (records.isEmpty()) { reportUntracedLeak(resourceType); } else { reportTracedLeak(resourceType, records); } } } }