lamber-ken has an open PR (https://github.com/apache/flink/pull/6247) that touches AsyncIOExample.java
Do we need a new JIRA for the code cleanup that Chesnay recommends, or it can be done as part of the open PR and [FLINK-9730]?
From: Chesnay Schepler [mailto:chesnay@xxxxxxxxxx]
Sent: Friday, July 06, 2018 9:48 AM
To: dev@xxxxxxxxxxxxxxxx; NEKRASSOV, ALEXEI <an4828@xxxxxxx>
Subject: Re: AsyncIOExample.SampleAsyncFunction
Correct, either counter must be made static, or both the executorService and random non-static (which makes the counter unnecessary).
For an example I would regard the latter as preferable to ensure that instances don't interfere with each other.
As for your question, for a given instance open() is only called once.
On 06.07.2018 15:33, NEKRASSOV, ALEXEI wrote:
I'm confused by lines 119-122 in
Why is counter non-static, but executorService and random - static?
It's not clear to me whether open() can be called more than once on a given object, and thus it's not clear whether the intent is to count the number of open's for every object (the current code). Or we really need to make counter static - to count the number of objects that share executorService and random?..
Having executorService and random as static, but counter as instance-specific will not work when someone creates a second instance of SampleAsyncFunction. In second SampleAsyncFunction the counter will be 0 and we will re-intialize static executorService and random, thus interfering with the first SampleAsyncFunction object.