Skip to content

Commit 098cf37

Browse files
fix: bug in snyk code enablement check in preferences [IDE-55] (#161)
1 parent 37c87a9 commit 098cf37

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## [2.1.0] - Unreleased
44

5+
### Fixes
6+
7+
- fix an exception when checking for Snyk Code enablement in the preference page
8+
9+
10+
## [2.1.0] - v20240115.153911
11+
512
### Changes
613

714
- add preference for scan mode selection (automatic/manual)

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,18 @@ public void run() {
120120
isSastEnabled = SnykExtendedLanguageClient.getInstance().getSastEnabled();
121121
} catch (Exception e) {
122122
SnykLogger.logError(e);
123+
return;
123124
}
124125
String message = "Snyk Code disabled, because it is not enabled for your organization. After you close this preference page, it will stay disabled.";
125126
boolean showMessage = false;
126-
if (snykCodeSecurityCheckbox != null && snykCodeSecurityCheckbox.getBooleanValue() && !isSastEnabled) {
127+
boolean checkBoxValue;
128+
try {
129+
checkBoxValue = snykCodeSecurityCheckbox != null && snykCodeSecurityCheckbox.getBooleanValue();
130+
} catch (NullPointerException e) {
131+
// this can happen, if the UI checkbox is not initialized fully, we return then
132+
return;
133+
}
134+
if (checkBoxValue && !isSastEnabled) {
127135
snykCodeSecurityCheckbox.setLabelText(snykCodeSecurityCheckbox.getLabelText() + " (" + message + ")");
128136
showMessage = true;
129137
}

0 commit comments

Comments
 (0)