Skip to content

Commit

Permalink
fix: Clear the queue before adding new elements
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Kopysov <[email protected]>
  • Loading branch information
o-kopysov committed Feb 21, 2024
1 parent f40dc2b commit 91a4dbd
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/lpvs/LicensePreValidationSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void main(String[] args) {
public TaskExecutor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(corePoolSize);
executor.setThreadNamePrefix("LPVS-ASYNC::");
executor.setThreadNamePrefix("LPVS::");
return executor;
}
}
1 change: 1 addition & 0 deletions src/main/java/com/lpvs/service/LPVSQueueService.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public BlockingDeque<LPVSQueue> getQueue() {
* @throws InterruptedException If interrupted while processing the queue.
*/
public void checkForQueue() throws InterruptedException {
QUEUE.clear();
log.debug("Checking for previous queue");
List<LPVSQueue> webhookConfigList = queueRepository.getQueueList();
for (LPVSQueue webhook : webhookConfigList) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/lpvs/util/LPVSCommentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static String getMatchedLinesAsLink(
if (vcs != null && vcs.equals(LPVSVcs.GITHUB)) {
matchedLines =
matchedLines.concat(
"<a target=\"_blank\" href=\"" + link + "\">" + lineInfo + "</a>");
"<a target=\"_blank\" href=\"" + link + "\">" + lineInfo + "</a> ");
} else {
matchedLines = matchedLines.concat(lineInfo + " (" + link + ") ");
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/lpvs/LicensePreValidationSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void testGetAsyncExecutor() {
assertEquals(executor, mocked_constructed_executor);

verify(mocked_constructed_executor, times(1)).setCorePoolSize(testNumCores);
verify(mocked_constructed_executor, times(1)).setThreadNamePrefix("LPVS-ASYNC::");
verify(mocked_constructed_executor, times(1)).setThreadNamePrefix("LPVS::");
verifyNoMoreInteractions(mocked_constructed_executor);
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/com/lpvs/service/LPVSGitHubServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ class TestCommentResults__ProhibitedPresentConflictsPresent {
+ "**File:** src/main/java/com/lpvs/service/LPVSGitHubService.java\n"
+ "**License(s):** <a target=\"_blank\" href=\"https://opensource.org/licenses/MIT\">MIT</a> (prohibited)\n"
+ "**Component:** LPVS::Services (src/main/java/com/lpvs/service/LPVSGitHubService.java)\n"
+ "**Matched Lines:** <a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a>\n"
+ "**Matched Lines:** <a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a> \n"
+ "**Snippet Match:** /**\n"
+ " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n"
+ " *\n"
Expand Down Expand Up @@ -2499,7 +2499,7 @@ class TestCommentResults__EmptyPresentConflictsPresent {
+ "**File:** src/main/java/com/lpvs/service/LPVSGitHubService.java\n"
+ "**License(s):** <a target=\"_blank\" href=\"https://opensource.org/licenses/MIT\">MIT</a> ()\n"
+ "**Component:** LPVS::Services (src/main/java/com/lpvs/service/LPVSGitHubService.java)\n"
+ "**Matched Lines:** <a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a>\n"
+ "**Matched Lines:** <a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a> \n"
+ "**Snippet Match:** /**\n"
+ " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n"
+ " *\n"
Expand Down Expand Up @@ -2827,7 +2827,7 @@ class TestCommentResults__UnreviewedPresentConflictsPresent {
+ "**File:** src/main/java/com/lpvs/service/LPVSGitHubService.java\n"
+ "**License(s):** <a target=\"_blank\" href=\"https://opensource.org/licenses/MIT\">MIT</a> (unreviewed)\n"
+ "**Component:** LPVS::Services (src/main/java/com/lpvs/service/LPVSGitHubService.java)\n"
+ "**Matched Lines:** <a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a>\n"
+ "**Matched Lines:** <a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a> \n"
+ "**Snippet Match:** /**\n"
+ " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n"
+ " *\n"
Expand Down Expand Up @@ -3157,7 +3157,7 @@ class TestCommentResults__RestrictedPresentConflictsPresent {
+ "**File:** src/main/java/com/lpvs/service/LPVSGitHubService.java\n"
+ "**License(s):** <a target=\"_blank\" href=\"https://opensource.org/licenses/MIT\">MIT</a> (restricted)\n"
+ "**Component:** LPVS::Services (src/main/java/com/lpvs/service/LPVSGitHubService.java)\n"
+ "**Matched Lines:** <a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a>\n"
+ "**Matched Lines:** <a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a> \n"
+ "**Snippet Match:** /**\n"
+ " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n"
+ " *\n"
Expand Down Expand Up @@ -3472,7 +3472,7 @@ class TestCommentResults__ProhibitedAbsentConflictsAbsent {
+ "**File:** src/main/java/com/lpvs/service/LPVSGitHubService.java\n"
+ "**License(s):** <a target=\"_blank\" href=\"https://opensource.org/licenses/MIT\">MIT</a> (permitted)\n"
+ "**Component:** LPVS::Services (src/main/java/com/lpvs/service/LPVSGitHubService.java)\n"
+ "**Matched Lines:** <a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a>\n"
+ "**Matched Lines:** <a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a> \n"
+ "**Snippet Match:** /**\n"
+ " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n"
+ " *\n"
Expand Down Expand Up @@ -4105,7 +4105,7 @@ class TestGetMatchedLinesAsLink_NotAll {
final String matched_lines_1 = "1-6";

final String expected_result =
"<a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a>";
"<a target=\"_blank\" href=\"https://github.com/Samsung/LPVS/blob/895337e89ae103ff2d18c9e0d93709f743226afa/src/main/java/com/lpvs/service/LPVSGitHubService.java#L1L6\">1-6</a> ";

@BeforeEach
void setUp() {
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/lpvs/util/LPVSCommentUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public void testGetMatchedLinesAsLinkMultipleLines() {
Mockito.when(webhookConfig.getHeadCommitSHA()).thenReturn("headCommitSHA");
String result = LPVSCommentUtil.getMatchedLinesAsLink(webhookConfig, file, LPVSVcs.GITHUB);
assertEquals(
"<a target=\"_blank\" href=\"https://github.com/repo/blob/headCommitSHA/exampleFile.txt#L1L5\">1-5</a>"
+ "<a target=\"_blank\" href=\"https://github.com/repo/blob/headCommitSHA/exampleFile.txt#L7\">7</a>"
+ "<a target=\"_blank\" href=\"https://github.com/repo/blob/headCommitSHA/exampleFile.txt#L9L12\">9-12</a>",
"<a target=\"_blank\" href=\"https://github.com/repo/blob/headCommitSHA/exampleFile.txt#L1L5\">1-5</a> "
+ "<a target=\"_blank\" href=\"https://github.com/repo/blob/headCommitSHA/exampleFile.txt#L7\">7</a> "
+ "<a target=\"_blank\" href=\"https://github.com/repo/blob/headCommitSHA/exampleFile.txt#L9L12\">9-12</a> ",
result);
}

Expand Down

0 comments on commit 91a4dbd

Please sign in to comment.