diff --git a/core/src/main/java/io/grpc/internal/ManagedChannelOrphanWrapper.java b/core/src/main/java/io/grpc/internal/ManagedChannelOrphanWrapper.java index c7f722a9499..790d5bd297f 100644 --- a/core/src/main/java/io/grpc/internal/ManagedChannelOrphanWrapper.java +++ b/core/src/main/java/io/grpc/internal/ManagedChannelOrphanWrapper.java @@ -62,24 +62,22 @@ final class ManagedChannelOrphanWrapper extends ForwardingManagedChannel { @Override public ManagedChannel shutdown() { - ManagedChannel result = super.shutdown(); phantom.clearSafely(); // This dummy check prevents the JIT from collecting 'this' too early if (this.getClass() == null) { throw new AssertionError(); } - return result; + return super.shutdown(); } @Override public ManagedChannel shutdownNow() { - ManagedChannel result = super.shutdownNow(); phantom.clearSafely(); // This dummy check prevents the JIT from collecting 'this' too early if (this.getClass() == null) { throw new AssertionError(); } - return result; + return super.shutdownNow(); } @VisibleForTesting diff --git a/core/src/test/java/io/grpc/internal/ManagedChannelOrphanWrapperTest.java b/core/src/test/java/io/grpc/internal/ManagedChannelOrphanWrapperTest.java index cdd36fb8273..45fb3881722 100644 --- a/core/src/test/java/io/grpc/internal/ManagedChannelOrphanWrapperTest.java +++ b/core/src/test/java/io/grpc/internal/ManagedChannelOrphanWrapperTest.java @@ -140,31 +140,6 @@ public boolean isLoggable(LogRecord record) { } } - @Test - public void orphanedChannel_triggerWarningAndCoverage() { - ManagedChannel mc = new TestManagedChannel(); - final ReferenceQueue refqueue = new ReferenceQueue<>(); - ConcurrentMap refs = - new ConcurrentHashMap<>(); - - // Create the wrapper but NEVER call shutdown - @SuppressWarnings("UnusedVariable") - ManagedChannelOrphanWrapper wrapper = new ManagedChannelOrphanWrapper(mc, refqueue, refs); - wrapper = null; // Make it eligible for GC - - // Trigger GC and clean the queue to hit the !wasShutdown branch - final AtomicInteger numOrphans = new AtomicInteger(); - GcFinalization.awaitDone(new FinalizationPredicate() { - @Override - public boolean isDone() { - numOrphans.getAndAdd(ManagedChannelReference.cleanQueue(refqueue)); - return numOrphans.get() > 0; - } - }); - - assertEquals(1, numOrphans.get()); - } - @Test public void refCycleIsGCed() { ReferenceQueue refqueue =