Skip to content

Commit 6a2028c

Browse files
Remove extraneous changes beyond avoiding the false positive warnings (#12731)
super.shutdown() is never expected to throw, so some of the changes were not required. Also removing the redundant unit test. Rework of PR #12705.
1 parent fbc3a16 commit 6a2028c

2 files changed

Lines changed: 2 additions & 29 deletions

File tree

core/src/main/java/io/grpc/internal/ManagedChannelOrphanWrapper.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,22 @@ final class ManagedChannelOrphanWrapper extends ForwardingManagedChannel {
6262

6363
@Override
6464
public ManagedChannel shutdown() {
65-
ManagedChannel result = super.shutdown();
6665
phantom.clearSafely();
6766
// This dummy check prevents the JIT from collecting 'this' too early
6867
if (this.getClass() == null) {
6968
throw new AssertionError();
7069
}
71-
return result;
70+
return super.shutdown();
7271
}
7372

7473
@Override
7574
public ManagedChannel shutdownNow() {
76-
ManagedChannel result = super.shutdownNow();
7775
phantom.clearSafely();
7876
// This dummy check prevents the JIT from collecting 'this' too early
7977
if (this.getClass() == null) {
8078
throw new AssertionError();
8179
}
82-
return result;
80+
return super.shutdownNow();
8381
}
8482

8583
@VisibleForTesting

core/src/test/java/io/grpc/internal/ManagedChannelOrphanWrapperTest.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -140,31 +140,6 @@ public boolean isLoggable(LogRecord record) {
140140
}
141141
}
142142

143-
@Test
144-
public void orphanedChannel_triggerWarningAndCoverage() {
145-
ManagedChannel mc = new TestManagedChannel();
146-
final ReferenceQueue<ManagedChannelOrphanWrapper> refqueue = new ReferenceQueue<>();
147-
ConcurrentMap<ManagedChannelReference, ManagedChannelReference> refs =
148-
new ConcurrentHashMap<>();
149-
150-
// Create the wrapper but NEVER call shutdown
151-
@SuppressWarnings("UnusedVariable")
152-
ManagedChannelOrphanWrapper wrapper = new ManagedChannelOrphanWrapper(mc, refqueue, refs);
153-
wrapper = null; // Make it eligible for GC
154-
155-
// Trigger GC and clean the queue to hit the !wasShutdown branch
156-
final AtomicInteger numOrphans = new AtomicInteger();
157-
GcFinalization.awaitDone(new FinalizationPredicate() {
158-
@Override
159-
public boolean isDone() {
160-
numOrphans.getAndAdd(ManagedChannelReference.cleanQueue(refqueue));
161-
return numOrphans.get() > 0;
162-
}
163-
});
164-
165-
assertEquals(1, numOrphans.get());
166-
}
167-
168143
@Test
169144
public void refCycleIsGCed() {
170145
ReferenceQueue<ManagedChannelOrphanWrapper> refqueue =

0 commit comments

Comments
 (0)