Skip to content

Instantly share code, notes, and snippets.

@epaga
Created September 12, 2019 07:34
Show Gist options
  • Save epaga/1e9527d9fcf81170f466eb4309a26357 to your computer and use it in GitHub Desktop.
Save epaga/1e9527d9fcf81170f466eb4309a26357 to your computer and use it in GitHub Desktop.
Connection nonCloseableConnection = (Connection)Proxy.newProxyInstance( Connection.class.getClassLoader(),
new Class[] { Connection.class },
(proxy, method, methodArgs) -> {
if (method.getName().equals("close")) {
return null;
} else {
return method.invoke( alreadyExistingConnection, methodArgs );
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment