GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use recommanded finalize chain pattern when override finalize() metho… · netty/netty@a5837cb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • buffer/src/main/java/io/netty/buffer
    • AdaptivePoolingAllocator.java
    • PoolArena.java
    • PoolThreadCache.java
  • common/src
    • main/java/io/netty/util
      • HashedWheelTimer.java
    • test/java/io/netty/util
      • RecyclerFastThreadLocalTest.java
      • RecyclerTest.java
  • handler/src/main/java/io/netty/handler/ssl
    • OpenSslContext.java
    • OpenSslEngine.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java‎

Copy file name to clipboardExpand all lines: buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ long usedMemory() {
345345
@Override
346346
protected void finalize() throws Throwable {
347347
try {
348-
super.finalize();
349-
} finally {
350348
free();
349+
} finally {
350+
super.finalize();
351351
}
352352
}
353353

Collapse file

‎buffer/src/main/java/io/netty/buffer/PoolArena.java‎

Copy file name to clipboardExpand all lines: buffer/src/main/java/io/netty/buffer/PoolArena.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,10 @@ private static void appendPoolSubPages(StringBuilder buf, PoolSubpage<?>[] subpa
640640
@Override
641641
protected final void finalize() throws Throwable {
642642
try {
643-
super.finalize();
644-
} finally {
645643
destroyPoolSubPages(smallSubpagePools);
646644
destroyPoolChunkLists(qInit, q000, q025, q050, q075, q100);
645+
} finally {
646+
super.finalize();
647647
}
648648
}
649649

Collapse file

‎buffer/src/main/java/io/netty/buffer/PoolThreadCache.java‎

Copy file name to clipboardExpand all lines: buffer/src/main/java/io/netty/buffer/PoolThreadCache.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,15 +484,15 @@ private FreeOnFinalize(PoolThreadCache cache) {
484484
@Override
485485
protected void finalize() throws Throwable {
486486
try {
487-
super.finalize();
488-
} finally {
489487
PoolThreadCache cache = this.cache;
490488
// this can race with a non-finalizer thread calling free: regardless who wins, the cache will be
491489
// null out
492490
this.cache = null;
493491
if (cache != null) {
494492
cache.free(true);
495493
}
494+
} finally {
495+
super.finalize();
496496
}
497497
}
498498
}
Collapse file

‎common/src/main/java/io/netty/util/HashedWheelTimer.java‎

Copy file name to clipboardExpand all lines: common/src/main/java/io/netty/util/HashedWheelTimer.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,13 @@ public HashedWheelTimer(
322322
@Override
323323
protected void finalize() throws Throwable {
324324
try {
325-
super.finalize();
326-
} finally {
327325
// This object is going to be GCed and it is assumed the ship has sailed to do a proper shutdown. If
328326
// we have not yet shutdown then we want to make sure we decrement the active instance count.
329327
if (WORKER_STATE_UPDATER.getAndSet(this, WORKER_STATE_SHUTDOWN) != WORKER_STATE_SHUTDOWN) {
330328
INSTANCE_COUNTER.decrementAndGet();
331329
}
330+
} finally {
331+
super.finalize();
332332
}
333333
}
334334

Collapse file

‎common/src/test/java/io/netty/util/RecyclerFastThreadLocalTest.java‎

Copy file name to clipboardExpand all lines: common/src/test/java/io/netty/util/RecyclerFastThreadLocalTest.java
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ public void run() {
5656
}) {
5757
@Override
5858
protected void finalize() throws Throwable {
59-
super.finalize();
60-
collected.set(true);
59+
try {
60+
collected.set(true);
61+
} finally {
62+
super.finalize();
63+
}
6164
}
6265
};
6366
assertFalse(collected.get());
Collapse file

‎common/src/test/java/io/netty/util/RecyclerTest.java‎

Copy file name to clipboardExpand all lines: common/src/test/java/io/netty/util/RecyclerTest.java
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,11 @@ public void run() {
185185
}) {
186186
@Override
187187
protected void finalize() throws Throwable {
188-
super.finalize();
189-
collected.set(true);
188+
try {
189+
collected.set(true);
190+
} finally {
191+
super.finalize();
192+
}
190193
}
191194
};
192195
assertFalse(collected.get());
Collapse file

‎handler/src/main/java/io/netty/handler/ssl/OpenSslContext.java‎

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/OpenSslContext.java
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ final SSLEngine newEngine0(ByteBufAllocator alloc, String peerHost, int peerPort
6060
@Override
6161
@SuppressWarnings("FinalizeDeclaration")
6262
protected final void finalize() throws Throwable {
63-
super.finalize();
64-
OpenSsl.releaseIfNeeded(this);
63+
try {
64+
OpenSsl.releaseIfNeeded(this);
65+
} finally {
66+
super.finalize();
67+
}
6568
}
6669
}
Collapse file

‎handler/src/main/java/io/netty/handler/ssl/OpenSslEngine.java‎

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/OpenSslEngine.java
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ public final class OpenSslEngine extends ReferenceCountedOpenSslEngine {
3939
@Override
4040
@SuppressWarnings("FinalizeDeclaration")
4141
protected void finalize() throws Throwable {
42-
super.finalize();
43-
OpenSsl.releaseIfNeeded(this);
42+
try {
43+
OpenSsl.releaseIfNeeded(this);
44+
} finally {
45+
super.finalize();
46+
}
4447
}
4548
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.