I am currently working on NIFI-14340
<https://issues.apache.org/jira/browse/NIFI-14340> trying to replace the
overridden methods finalize in both AbstractCacheServer and
StandardProcessSession as
per the javadocs
<https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Object.html#finalize()>
finalize
is deprecated for removal.

So my first question is whether we would like a replacement for these
finalize methods or is the solution for this ticket is as simple as just
removing them?
If we would like to replace them based on the suggestions given in JEP 421
<https://openjdk.org/jeps/421> then I have a few other questions.
The first suggested solution is to make the class implement
java.lang.AutoCloseable and then instantiate and use it in a try with
resources statement within a single lexical scope.
It does not seem to me that is plausible for AbstractCacheServer which is a
controller service and from what I understand is not used within a single
lexical scope.
It also does not seem this would work for StandardProcessSession as there
are cases where instances of ProcessSession handle transferring flow
file(s) and commits in a catch block. If used
in a try resources it would be closed before the catch block code is called.
The second suggestion is to use Cleaners but that also seems difficult as
it seems from what I have read the right way to implement this would be
passing AbstractCacheServer and StandardProcessSession into a different
class to handle cleaning. I am not sure how that would be done for these
classes.

Can I please get guidance on how we should proceed regarding these finalize
methods? Thank you!

Reply via email to