Anton Kalashnikov created FLINK-24294:
-----------------------------------------

             Summary: Resources leak in the StreamTask constructor
                 Key: FLINK-24294
                 URL: https://issues.apache.org/jira/browse/FLINK-24294
             Project: Flink
          Issue Type: Bug
          Components: Runtime / Task
    Affects Versions: 1.14.0
            Reporter: Anton Kalashnikov


Since we are initializing a lot of resources in the StreamTask constructor like 
RecordWriter, timerServices, etc. it is possible that some of these resources 
remain open if the exception happens below the initialization in the same 
constructor.
So in my opinion, we have two choices here: 
* Avoiding allocation of resources in the constructor which allows us to do 
something like:
{noformat}
StreamTask task = new StreamTask(); //no leaks if it fails
try { 
  task.init();
  ....
} finally {
  task.cleanUp();
}
{noformat}
*  or we can rewrite a code in such a way that exception in any constructor(ex. 
StreamTask) guarantee releasing the earlier allocated resources in this 
constructor. But it is not so easy to implement(see. initialization of 
recordWriter in StreamTask constructor)

So perhaps it makes sense to separate creating object from 
initialization(allocation resources)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to