You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some classes have a close method but don't implement AutoCloseable or Closeable. For example, until version 3.1.0, the Jakarta REST Client has a close method but doesn't implement AutoCloseable. Similarly, java.util.concurrent.ExecutorService has shutdown and shutdownNow methods.
Sometimes, for example during an application shutdown process, it would be nice to be able to call these methods and ignore exceptions the way KiwiIO.closeQuietly does for Closeable objects.
This task adds new methods to KiwiIO that can "close" objects which do not implement AutoCloseable or Closeable, such as the Jakarta REST Client (before version 3.1.0) and the JDK's ExecutorService.
The methods that only accept Object will assume the method name is close. The other methods explicitly accept a method name to be used to "close" those objects. For example, shutdown or shutdownNow for an ExecutorService. The method name argument is first so that the varargs overload can be used naturally. Otherwise, you would not be able to use the varargs syntax and would need to explicitly create an Object[] array.
The proposed method names include the word "Object" to make it more clear they are doing something different from closing a Closeable, i.e., that they will attempt to "close" anyObject regardless of what interfaces it implements or doesn't.
The text was updated successfully, but these errors were encountered:
Some classes have a
close
method but don't implementAutoCloseable
orCloseable
. For example, until version 3.1.0, the Jakarta RESTClient
has aclose
method but doesn't implementAutoCloseable
. Similarly,java.util.concurrent.ExecutorService
hasshutdown
andshutdownNow
methods.Sometimes, for example during an application shutdown process, it would be nice to be able to call these methods and ignore exceptions the way
KiwiIO.closeQuietly
does forCloseable
objects.This task adds new methods to
KiwiIO
that can "close" objects which do not implementAutoCloseable
orCloseable
, such as the Jakarta RESTClient
(before version 3.1.0) and the JDK'sExecutorService
.Proposed methods:
closeObjectQuietly(Object object)
closeObjectsQuietly(Object... objects)
closeObjectQuietly(String closeMethodName, Object object)
closeObjectsQuietly(String closeMethodName, Object... objects)
The methods that only accept
Object
will assume the method name isclose
. The other methods explicitly accept a method name to be used to "close" those objects. For example,shutdown
orshutdownNow
for anExecutorService
. The method name argument is first so that the varargs overload can be used naturally. Otherwise, you would not be able to use the varargs syntax and would need to explicitly create anObject[]
array.The proposed method names include the word "Object" to make it more clear they are doing something different from closing a
Closeable
, i.e., that they will attempt to "close" anyObject
regardless of what interfaces it implements or doesn't.The text was updated successfully, but these errors were encountered: