Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd5cc7bc

Browse files
Luis Garzarueiyhuang
Luis Garza
authored andcommitted
Fixed Java 11+ compatibility issue by improving exception handling in StreamWrapper.finalize()
1 parent90ee03c commitd5cc7bc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎src/main/java/com/amazon/redshift/util/StreamWrapper.java‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,21 @@ public void close() throws IOException {
113113
}
114114
}
115115

116+
// Suppress deprecation warning: finalize() is deprecated in Java 9+ but needed
117+
// for Java 8 compatibility and reliable resource cleanup in this specific case
118+
@SuppressWarnings("deprecation")
119+
@Override
116120
protectedvoidfinalize()throwsIOException {
117121
// forcibly close it because super.finalize() may keep the FD open, which may prevent
118122
// file deletion
119123
close();
120-
super.finalize();
124+
try {
125+
super.finalize();
126+
}catch (Throwablet) {
127+
// Ignore exceptions during finalization - object is being garbage collected
128+
// and no recovery is possible. This also handles Java 11+ compatibility where
129+
// super.finalize() throws Throwable instead of just IOException
130+
}
121131
}
122132
};
123133
}else {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp