Skip to content

Commit b6d0514

Browse files
fix: better jdk detection (#235)
* fix: better jdk detection * add python sdk support * add log message * fix: in progress state map * chore: changed log message * chore: fix build (dep update) * fix: warnings * fix: python extraction for pydev
1 parent 5bff67c commit b6d0514

24 files changed

Lines changed: 418 additions & 301 deletions

plugin/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Bundle-ActivationPolicy: lazy
3131
Bundle-ClassPath: .,
3232
target/dependency/commons-codec-1.17.0.jar,
3333
target/dependency/commons-lang3-3.12.0.jar,
34-
target/dependency/commons-logging-1.2.jar,
34+
target/dependency/commons-logging-1.3.4.jar,
3535
target/dependency/httpclient-4.5.14.jar,
3636
target/dependency/httpcore-4.4.16.jar,
3737
target/dependency/jackson-annotations-2.16.2.jar,

plugin/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ bin.includes = plugin.xml,\
99
OSGI-INF/,\
1010
target/dependency/commons-codec-1.17.0.jar,\
1111
target/dependency/commons-lang3-3.12.0.jar,\
12-
target/dependency/commons-logging-1.2.jar,\
12+
target/dependency/commons-logging-1.3.4.jar,\
1313
target/dependency/httpclient-4.5.14.jar,\
1414
target/dependency/httpcore-4.4.16.jar,\
1515
target/dependency/jackson-annotations-2.16.2.jar,\

plugin/io.snyk.eclipse.plugin.eml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<lib name="commons-lang3-3.12.0.jar" scope="COMPILE">
1111
<relative-module-cls project-related="jar://$PROJECT_DIR$/plugin/target/dependency/commons-lang3-3.12.0.jar!/"/>
1212
</lib>
13-
<lib name="commons-logging-1.2.jar" scope="COMPILE">
14-
<relative-module-cls project-related="jar://$PROJECT_DIR$/plugin/target/dependency/commons-logging-1.2.jar!/"/>
13+
<lib name="commons-logging-1.3.4.jar" scope="COMPILE">
14+
<relative-module-cls project-related="jar://$PROJECT_DIR$/plugin/target/dependency/commons-logging-1.3.4.jar!/"/>
1515
</lib>
1616
<lib name="httpclient-4.5.14.jar" scope="COMPILE">
1717
<relative-module-cls project-related="jar://$PROJECT_DIR$/plugin/target/dependency/httpclient-4.5.14.jar!/"/>
Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.snyk.eclipse.plugin.analytics;
22

3-
import java.util.LinkedList;
3+
import java.util.ArrayList;
4+
import java.util.List;
45
import java.util.concurrent.CompletableFuture;
56
import java.util.concurrent.ConcurrentLinkedQueue;
67
import java.util.function.Consumer;
@@ -19,14 +20,16 @@ public class TaskProcessor {
1920
private final ConcurrentLinkedQueue<Pair<Consumer<SnykExtendedLanguageClient>, Consumer<Void>>> taskQueue = new ConcurrentLinkedQueue<>();
2021

2122
private TaskProcessor() {
22-
CompletableFuture.runAsync(() -> { start(); });
23+
CompletableFuture.runAsync(() -> {
24+
start();
25+
});
2326
}
2427

2528
private static TaskProcessor instance;
2629

2730
public static TaskProcessor getInstance() {
28-
if (instance == null) {
29-
synchronized (TaskProcessor.class) {
31+
synchronized (TaskProcessor.class) {
32+
if (instance == null) {
3033
if (instance == null) {
3134
instance = new TaskProcessor();
3235
}
@@ -36,39 +39,39 @@ public static TaskProcessor getInstance() {
3639
}
3740

3841
private void start() {
39-
while (true) {
40-
String authToken = Preferences.getInstance().getAuthToken();
41-
var lc = SnykExtendedLanguageClient.getInstance();
42-
if (taskQueue.isEmpty() || authToken == null || authToken.isBlank() || lc == null) {
43-
try {
44-
Thread.sleep(1000);
45-
} catch (InterruptedException e) {
46-
Thread.currentThread().interrupt();
47-
}
48-
continue;
49-
}
50-
LinkedList<Pair<Consumer<SnykExtendedLanguageClient>, Consumer<Void>>> copyForSending
51-
= new LinkedList<>(taskQueue);
52-
53-
for (Pair<Consumer<SnykExtendedLanguageClient>, Consumer<Void>> event : copyForSending) {
54-
try {
55-
// Execute the task with the language client
56-
event.getLeft().accept(lc);
57-
// Execute the callback
58-
if(event.getRight() != null) {
59-
event.getRight().accept(null);
60-
}
61-
} catch (Exception e) {
62-
SnykLogger.logError(e);
63-
} finally {
64-
taskQueue.remove(event);
65-
}
66-
}
67-
}
42+
while (true) {
43+
String authToken = Preferences.getInstance().getAuthToken();
44+
var lc = SnykExtendedLanguageClient.getInstance();
45+
if (taskQueue.isEmpty() || authToken == null || authToken.isBlank() || lc == null) {
46+
try {
47+
Thread.sleep(1000);
48+
} catch (InterruptedException e) {
49+
Thread.currentThread().interrupt();
50+
}
51+
continue;
52+
}
53+
List<Pair<Consumer<SnykExtendedLanguageClient>, Consumer<Void>>> copyForSending = new ArrayList<>(
54+
taskQueue);
55+
56+
for (Pair<Consumer<SnykExtendedLanguageClient>, Consumer<Void>> event : copyForSending) {
57+
try {
58+
// Execute the task with the language client
59+
event.getLeft().accept(lc);
60+
// Execute the callback
61+
if (event.getRight() != null) {
62+
event.getRight().accept(null);
63+
}
64+
} catch (Exception e) {
65+
SnykLogger.logError(e);
66+
} finally {
67+
taskQueue.remove(event);
68+
}
69+
}
70+
}
6871
}
6972

7073
public void registerTask(Consumer<SnykExtendedLanguageClient> task, Consumer<Void> callback) {
71-
var pair = Pair.of(task, callback);
72-
taskQueue.add(pair);
74+
var pair = Pair.of(task, callback);
75+
taskQueue.add(pair);
7376
}
7477
}

plugin/src/main/java/io/snyk/eclipse/plugin/html/BaseHtmlProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public String getColorAsHex(String colorKey, String defaultColor) {
8787

8888
public Boolean isDarkTheme() {
8989
var darkColor = getColorAsHex("org.eclipse.ui.workbench.DARK_BACKGROUND", "");
90-
return darkColor != "";
90+
return darkColor.equals("true");
9191
}
9292

9393
private ColorRegistry colorRegistry;

plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ public class CodeHtmlProvider extends BaseHtmlProvider {
66
private static CodeHtmlProvider instance = new CodeHtmlProvider();
77

88
public static CodeHtmlProvider getInstance() {
9-
if (instance == null) {
10-
synchronized (CodeHtmlProvider.class) {
9+
synchronized (CodeHtmlProvider.class) {
10+
if (instance == null) {
1111
if (instance == null) {
1212
instance = new CodeHtmlProvider();
1313
}

plugin/src/main/java/io/snyk/eclipse/plugin/html/IacHtmlProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
public class IacHtmlProvider extends BaseHtmlProvider {
44
private static IacHtmlProvider instance = new IacHtmlProvider();
55
public static IacHtmlProvider getInstance() {
6-
if (instance == null) {
7-
synchronized (IacHtmlProvider.class) {
6+
synchronized (IacHtmlProvider.class) {
7+
if (instance == null) {
88
if (instance == null) {
99
instance = new IacHtmlProvider();
1010
}
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
package io.snyk.eclipse.plugin.html;
22

33
public class OssHtmlProvider extends BaseHtmlProvider {
4-
private static OssHtmlProvider instance = new OssHtmlProvider();
4+
private static OssHtmlProvider instance = new OssHtmlProvider();
5+
56
public static OssHtmlProvider getInstance() {
6-
if (instance == null) {
7-
synchronized (OssHtmlProvider.class) {
7+
synchronized (OssHtmlProvider.class) {
8+
if (instance == null) {
89
if (instance == null) {
910
instance = new OssHtmlProvider();
1011
}
1112
}
1213
}
1314
return instance;
1415
}
15-
@Override
16-
public String replaceCssVariables(String html) {
17-
html = super.replaceCssVariables(html);
18-
html = html.replace("var(--container-background-color)", super.getColorAsHex("org.eclipse.ui.workbench.DARK_BACKGROUND", "#F0F0F0"));
19-
return html;
20-
}
16+
17+
@Override
18+
public String replaceCssVariables(String html) {
19+
html = super.replaceCssVariables(html);
20+
html = html.replace("var(--container-background-color)",
21+
super.getColorAsHex("org.eclipse.ui.workbench.DARK_BACKGROUND", "#F0F0F0"));
22+
return html;
23+
}
2124
}

plugin/src/main/java/io/snyk/eclipse/plugin/html/StaticPageHtmlProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public class StaticPageHtmlProvider extends BaseHtmlProvider {
99
private static StaticPageHtmlProvider instance = new StaticPageHtmlProvider();
1010

1111
public static StaticPageHtmlProvider getInstance() {
12-
if (instance == null) {
13-
synchronized (StaticPageHtmlProvider.class) {
12+
synchronized (StaticPageHtmlProvider.class) {
13+
if (instance == null) {
1414
if (instance == null) {
1515
instance = new StaticPageHtmlProvider();
1616
}

plugin/src/main/java/io/snyk/eclipse/plugin/properties/PreferencesPage.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ public boolean performOk() {
127127
snykView.disableRunAbortActions();
128128
snykView.toggleRunActionEnablement();
129129
disableSnykCodeIfOrgDisabled();
130-
new LsConfigurationUpdater().configurationChanged();
131-
SnykExtendedLanguageClient.getInstance().refreshFeatureFlags();
132-
130+
CompletableFuture.runAsync(() -> {
131+
new LsConfigurationUpdater().configurationChanged();
132+
SnykExtendedLanguageClient.getInstance().refreshFeatureFlags();
133+
});
133134
return superOK;
134135
}
135136

0 commit comments

Comments
 (0)