Don't try to add non Python interpreter as Python platform
authorJulien Enselme <jenselme@netbeans.org>
Mon, 19 Sep 2016 18:52:37 +0200
changeset 18380fd7fe8fd8729
parent 18379 91dd6de4e7c9
child 18381 289a7e019502
Don't try to add non Python interpreter as Python platform

In PythonPlatformManager, if the commands succeed but is not a Python interpreter
its name will be null (eg /usr/bin/ls). This will cause subsequent call to
"Manage" to fail due to a NullPtrException. We prevent this by returning a null
platform if the name is null.

This can happen if the user enters a wrong path when registering a new Python
platform.
python.core/src/org/netbeans/modules/python/api/PythonPlatformManager.java
     1.1 --- a/python.core/src/org/netbeans/modules/python/api/PythonPlatformManager.java	Mon Sep 19 17:04:00 2016 +0200
     1.2 +++ b/python.core/src/org/netbeans/modules/python/api/PythonPlatformManager.java	Mon Sep 19 18:52:37 2016 +0200
     1.3 @@ -396,6 +396,10 @@
     1.4                      command = cmd;
     1.5                  }
     1.6                  String name = prop.getProperty("platform.name");
     1.7 +                // If name is null, the command that succeeded is not a Python interpreter (eg /usr/bin/ls)
     1.8 +                if (name == null) {
     1.9 +                    return null;
    1.10 +                }
    1.11                  if (id == null) {
    1.12                      id = computeId(name);
    1.13                  }