From: Andrej Mak Date: Mon, 11 Apr 2016 11:17:54 +0000 (+0200) Subject: Bug 5444: Allow null value in config module list setter X-Git-Tag: release/boron~209 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=da52b6c3a78b931898fe24299a29c0db83e56b03 Bug 5444: Allow null value in config module list setter Change-Id: Ibdd8f93d7d8bf213892c1af8632f3ec0989cd617 Signed-off-by: Andrej Mak --- diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/TemplateFactory.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/TemplateFactory.java index 999b27fb91..4c67a67f42 100644 --- a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/TemplateFactory.java +++ b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/TemplateFactory.java @@ -690,8 +690,8 @@ public class TemplateFactory { String setterBody = "this." + varName + " = " + varName + ";"; if (isListOfDependencies) { - String nullCheck = String.format("if (%s == null) throw new IllegalArgumentException(\"Null not supported\");%n", - varName); + String nullCheck = String.format("if (%s == null) {\n%s = new java.util.ArrayList<>(); \n}%n", + varName, varName); setterBody = nullCheck + setterBody; } MethodDefinition setter = new MethodDefinition("void", diff --git a/opendaylight/config/yang-test/src/test/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleTest.java b/opendaylight/config/yang-test/src/test/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleTest.java index 680fe5048a..3e0a741076 100644 --- a/opendaylight/config/yang-test/src/test/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleTest.java +++ b/opendaylight/config/yang-test/src/test/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleTest.java @@ -8,9 +8,7 @@ package org.opendaylight.controller.config.yang.test.impl; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import static org.mockito.Mockito.doReturn; import com.google.common.collect.Lists; @@ -112,15 +110,8 @@ public class NetconfTestImplModuleTest extends AbstractConfigTest { ObjectName on = createInstance(transaction, instanceName, 4); NetconfTestImplModuleMXBean proxy = transaction.newMXBeanProxy(on, NetconfTestImplModuleMXBean.class); - try{ - proxy.setTestingDeps(null); - fail(); - }catch(RuntimeException e) { - Throwable cause = e.getCause(); - assertNotNull(cause); - assertTrue("Invalid type " + cause, cause instanceof IllegalArgumentException); - assertEquals("Null not supported", cause.getMessage()); - } + proxy.setTestingDeps(null); + assertTrue(proxy.getTestingDeps().isEmpty()); proxy.setTestingDeps(Collections.emptyList()); }