Skip to content

fix: resolve SonarCloud issue in App.java #2865 #3236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions dirty-flag/src/main/java/com/iluwatar/dirtyflag/App.java
Original file line number Diff line number Diff line change
@@ -57,20 +57,30 @@ public class App {
/** Program execution point. */
public void run() {
final var executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleAtFixedRate(
new Runnable() {
final World world = new World();
try {
executorService.scheduleAtFixedRate(
new Runnable() {
final World world = new World();

@Override
public void run() {
var countries = world.fetch();
LOGGER.info("Our world currently has the following countries:-");
countries.stream().map(country -> "\t" + country).forEach(LOGGER::info);
}
},
0,
15,
TimeUnit.SECONDS); // Run at every 15 seconds.
@Override
public void run() {
var countries = world.fetch();
LOGGER.info("Our world currently has the following countries:-");
countries.stream().map(country -> "\t" + country).forEach(LOGGER::info);
}
},
0,
15,
TimeUnit.SECONDS);

// Keep running for 45 seconds before shutdown (for demo purpose)
TimeUnit.SECONDS.sleep(45);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOGGER.error("Thread was interrupted", e);
} finally {
executorService.shutdown();
}
}

/**