Skip to content

Commit

Permalink
fix: interrupt processLogsAndUpload
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDombo committed Oct 5, 2023
1 parent 29d55ee commit 8b3e8d7
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,9 @@ private void updatelastComponentUploadedLogFile(Map<String, Instant> lastCompone
* It will then get all the log files which have not yet been uploaded to the cloud. This is done by checking
* the last uploaded log file time for that component.
*/
@SuppressWarnings("PMD.CollapsibleIfStatements")
@SuppressWarnings({"PMD.CollapsibleIfStatements", "PMD.PrematureDeclaration"})
private void processLogsAndUpload() throws InterruptedException {
while (true) {
while (!Thread.currentThread().isInterrupted()) {
//TODO: this is only done for passing the current text. But in practise, we don`t need to intentionally
// sleep here.
if (!isCurrentlyUploading.compareAndSet(false, true)) {
Expand All @@ -702,6 +702,9 @@ private void processLogsAndUpload() throws InterruptedException {
try {
LogFileGroup logFileGroup = LogFileGroup.create(componentLogConfiguration,
lastUploadedLogFileTimeMs, workDir);
if (Thread.currentThread().isInterrupted()) {
return;

Check warning on line 706 in src/main/java/com/aws/greengrass/logmanager/LogManagerService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/aws/greengrass/logmanager/LogManagerService.java#L706

Added line #L706 was not covered by tests
}

if (logFileGroup.getLogFiles().isEmpty()) {
continue;
Expand Down

0 comments on commit 8b3e8d7

Please sign in to comment.