Skip to content

Commit 186adc9

Browse files
committed
Return Platform.OS_UNKNOWN in case of null
In some cases the return value of Platform.getOS() can be return null but its API doc states it return Platform.OS_UNKNOWN is the OS can not be found. Fix eclipse-platform/eclipse.platform.ui#3604
1 parent 2f623a3 commit 186adc9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,11 @@ public String getOption(String option) {
471471
}
472472

473473
public String getOS() {
474-
return getContextProperty(PROP_OS);
474+
String property = getContextProperty(PROP_OS);
475+
if (property == null) {
476+
return Platform.OS_UNKNOWN;
477+
}
478+
return property;
475479
}
476480

477481
public String getWS() {

runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.LinkedHashMap;
2323
import java.util.Map;
2424
import java.util.MissingResourceException;
25+
import java.util.Objects;
2526
import java.util.ResourceBundle;
2627
import org.eclipse.core.internal.runtime.AuthorizationHandler;
2728
import org.eclipse.core.internal.runtime.InternalPlatform;
@@ -79,7 +80,7 @@ private OS() {
7980
* @since 3.30
8081
*/
8182
public static boolean is(String osString) {
82-
return Platform.getOS().equals(osString);
83+
return Objects.equals(Platform.getOS(), osString);
8384
}
8485

8586
/**

0 commit comments

Comments
 (0)