Skip to content

Commit

Permalink
BCJSSE: Add finalizers to socket classes
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdettman committed May 7, 2019
1 parent f68ad61 commit 002bd0a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,30 @@ public void connect(SocketAddress endpoint, int timeout) throws IOException
notifyConnected();
}

@Override
protected void finalize() throws Throwable
{
try
{
close();
}
catch (IOException e1)
{
try
{
super.close();
}
catch (IOException e2)
{
// Ignore
}
}
finally
{
super.finalize();
}
}

// An SSLSocket method from JDK 9, but also a BCSSLSocket method
public synchronized String getApplicationProtocol()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,23 @@ public void connect(SocketAddress endpoint, int timeout) throws IOException
throw new SocketException("Wrapped socket should already be connected");
}

@Override
protected void finalize() throws Throwable
{
try
{
close();
}
catch (IOException e)
{
// Ignore
}
finally
{
super.finalize();
}
}

// An SSLSocket method from JDK 9, but also a BCSSLSocket method
public synchronized String getApplicationProtocol()
{
Expand Down

0 comments on commit 002bd0a

Please sign in to comment.