Skip to content

Commit 24d9b96

Browse files
committed
Remove extraneous changes beyond avoiding the false positive warnings, since super.shutdown() is never expected to throw.
Also remove redundant unit test. Rework of PR grpc#12705.
1 parent 37eb736 commit 24d9b96

File tree

2 files changed

+1
-27
lines changed

2 files changed

+1
-27
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,12 @@ public ManagedChannel shutdown() {
7373

7474
@Override
7575
public ManagedChannel shutdownNow() {
76-
ManagedChannel result = super.shutdownNow();
7776
phantom.clearSafely();
7877
// This dummy check prevents the JIT from collecting 'this' too early
7978
if (this.getClass() == null) {
8079
throw new AssertionError();
8180
}
82-
return result;
81+
return super.shutdownNow();
8382
}
8483

8584
@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)