Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Jiayang/gdpr #289

Merged
merged 4 commits into from
Nov 6, 2018
Merged

Jiayang/gdpr #289

merged 4 commits into from
Nov 6, 2018

Conversation

jiayangODC
Copy link
Contributor

No description provided.

@tedpearson
Copy link
Contributor

Some recommendations here:

  • You're creating a 5-thread pool for something that will only happen one-at-a-time.
  • I think a scheduled executor with fixed delay would be better suited to this use case, instead of using Thread.sleep to enforce the wait period. MoreExecutors even has a method that returns an exiting one.
  • It might make sense to name the refreshInterval something that makes it obvious what the time units are, such as refreshIntervalMin or something.

ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
// upon JVM termination, wait for the tasks for up to 100ms before exiting the executor service
ScheduledExecutorService executorService = MoreExecutors.getExitingScheduledExecutorService(executor, 100, TimeUnit.MILLISECONDS);
executorService.scheduleWithFixedDelay(() -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intellij inspections recommend using a method reference instead of a lambda here: this::postDecodeHelper

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Override public void postDecode() {
if (refreshMinutes == 0) {
postDecodeHelper();
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a pretty serious issue here - in the case where refresh is enabled, we only call postDecodeHelper in the scheduled executor service. While it's true that we call it immediately, it's called asynchronously without blocking. We need to block here so that this value filter can't be used until the post decode step has occured at least once. Therefore, we should always call postDecodeHelper in this method, and change the scheduled executor to not refresh immediately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jiayangODC jiayangODC changed the title WIP: Jiayang/gdpr Jiayang/gdpr Nov 6, 2018
@jiayangODC jiayangODC merged commit 6b1c2a4 into master Nov 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants