Skip to content

Commit 034f20f

Browse files
committed
8212136: Remove finalizer implementation in SSLSocketImpl
Reviewed-by: wetmore
1 parent 36e4df9 commit 034f20f

File tree

1 file changed

+8
-32
lines changed

1 file changed

+8
-32
lines changed

src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,13 @@
4141
* Methods are defined final to ensure that they are not accidentally
4242
* overridden in SSLSocketImpl.
4343
*
44+
* There used to be a finalize() implementation that sent close_notify's, but
45+
* decided that was not needed. Not closing properly is more properly an
46+
* error condition that should be avoided. Applications should close sockets
47+
* and not rely on garbage collection.
48+
*
49+
* The underlying native resources are handled by the Socket Cleaner.
50+
*
4451
* @see javax.net.ssl.SSLSocket
4552
* @see SSLSocketImpl
4653
*/
@@ -262,37 +269,6 @@ public boolean isOutputShutdown() {
262269
}
263270
}
264271

265-
/**
266-
* Ensures that the SSL connection is closed down as cleanly
267-
* as possible, in case the application forgets to do so.
268-
* This allows SSL connections to be implicitly reclaimed,
269-
* rather than forcing them to be explicitly reclaimed at
270-
* the penalty of prematurly killing SSL sessions.
271-
*/
272-
@Override
273-
@SuppressWarnings("removal")
274-
protected final void finalize() throws Throwable {
275-
try {
276-
close();
277-
} catch (IOException e1) {
278-
try {
279-
if (self == this) {
280-
super.close();
281-
}
282-
} catch (IOException e2) {
283-
// ignore
284-
}
285-
} finally {
286-
// We called close on the underlying socket above to
287-
// make doubly sure all resources got released. We
288-
// don't finalize self in the case of overlain sockets,
289-
// that's a different object which the GC will finalize
290-
// separately.
291-
292-
super.finalize();
293-
}
294-
}
295-
296272
//
297273
// GET ADDRESS METHODS
298274
//

0 commit comments

Comments
 (0)