diff --git a/core/src/main/java/hudson/security/AuthorizationMatrixProperty.java b/core/src/main/java/hudson/security/AuthorizationMatrixProperty.java index c5b063a6633280b93748cd92f7684ee962b1277a..5fdc6d5543548d6f6c6aa5b4e35a46f76bf3cf87 100644 --- a/core/src/main/java/hudson/security/AuthorizationMatrixProperty.java +++ b/core/src/main/java/hudson/security/AuthorizationMatrixProperty.java @@ -121,22 +121,24 @@ public class AuthorizationMatrixProperty extends JobProperty> { @Override public JobProperty newInstance(StaplerRequest req, JSONObject formData) throws FormException { - boolean useProjectSecurity = formData.has("useProjectSecurity"); - AuthorizationMatrixProperty amp = new AuthorizationMatrixProperty(); - amp.setUseProjectSecurity(useProjectSecurity); - for (Map.Entry r : (Set>) formData - .getJSONObject("data").entrySet()) { - String sid = r.getKey(); - if (r.getValue() instanceof JSONObject) { - for (Map.Entry e : (Set>) ((JSONObject) r - .getValue()).entrySet()) { - if (e.getValue()) { - Permission p = Permission.fromId(e.getKey()); - amp.add(p, sid); - } - } - } - } + AuthorizationMatrixProperty amp = new AuthorizationMatrixProperty(); + formData = formData.getJSONObject("useProjectSecurity"); + + if(!formData.isNullObject()) { + amp.setUseProjectSecurity(true); + for (Map.Entry r : (Set>) formData.getJSONObject("data").entrySet()) { + String sid = r.getKey(); + if (r.getValue() instanceof JSONObject) { + for (Map.Entry e : (Set>) ((JSONObject) r + .getValue()).entrySet()) { + if (e.getValue()) { + Permission p = Permission.fromId(e.getKey()); + amp.add(p, sid); + } + } + } + } + } return amp; }