Uploaded image for project: 'ONOS'
  1. ONOS
  2. ONOS-7342

Extending YANG model causes NullPointerException

    XMLWordPrintable

    Details

      Description

      When a YANG file from common models is extended with a custom RPC in a vendor specific models folder a Null Pointer Exception error is thrown.

      For instance using the latest master branch of ONOS, which in turn uses 2.3.1. of onos-yang-tools, I extend the file
      ietf-system-microsemi@2016-05-05.yang (which extends common/models/ietf-system@2014-08-06.yang)

      with the following small YANG snippet (just before the last bracket of the file)

          rpc test-rpc {
              input {
                  leaf input-leaf-1 {
                      type string;
                  }
              }
          }

      causes the error below to be thrown at build time.

      I find that if the base file is within the same folder as the extended this YANG works fine.
      I have also found a similar problem with YANG identities in a vendor specific folder extending those in a base folder. I suspect there is the same root cause.

      scondon@CORKLTC0006:~/onos$ onos-buck build onos
      Not using buckd because NO_BUCKD is set.
      [-] PROCESSING BUCK FILES...FINISHED 2.7s [100%] 🐳  New buck daemon
      [+] DOWNLOADING... (0.00 B/S, TOTAL: 0.00 B, 0 Artifacts)
      [+] BUILDING...9.8s [13%] (228/240 JOBS, 0 UPDATED, 0 [0.0%] CACHE MISS)
       |=> IDLE
       |=> IDLE
       |=> //models/microsemi:onos-models-microsemi-yang#srcs...  4.6s (running yang-compile[4.6s])
       |=> IDLE
      java.lang.NullPointerException
          at org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getCapitalCase(YangIoUtils.java:437)
          at org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGeneratorUtils.getAugmentSetterName(JavaFileGeneratorUtils.java:697)
          at org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGeneratorUtils.getSetOfNodeIdentifiers(JavaFileGeneratorUtils.java:671)
          at org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGeneratorUtils.addResolvedAugmentedDataNodeImports(JavaFileGeneratorUtils.java:727)
          at org.onosproject.yang.compiler.translator.tojava.TempJavaServiceFragmentFiles.generateJavaFile(TempJavaServiceFragmentFiles.java:116)
          at org.onosproject.yang.compiler.translator.tojava.TempJavaCodeFragmentFiles.generateJavaFile(TempJavaCodeFragmentFiles.java:204)
          at org.onosproject.yang.compiler.translator.tojava.javamodel.YangJavaModuleTranslator.generateCodeExit(YangJavaModuleTranslator.java:181)
          at org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil.generateCodeExit(JavaCodeGeneratorUtil.java:283)
          at org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil.translateToJava(JavaCodeGeneratorUtil.java:216)
          at org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil.translate(JavaCodeGeneratorUtil.java:71)
          at org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode(JavaCodeGeneratorUtil.java:240)
          at org.onosproject.yang.compiler.tool.YangCompilerManager.translateToJava(YangCompilerManager.java:327)
          at org.onosproject.yang.compiler.tool.YangCompilerManager.processYangFiles(YangCompilerManager.java:170)
          at org.onosproject.yang.compiler.tool.YangCompilerManager.compileYangFiles(YangCompilerManager.java:97)
          at org.onosproject.yang.compiler.plugin.buck.YangGenerator.execute(YangGenerator.java:98)
          at org.onosproject.yang.compiler.plugin.buck.YangStep.execute(YangStep.java:73)
          at com.facebook.buck.step.DefaultStepRunner.runStepForBuildTarget(DefaultStepRunner.java:62)
          at com.facebook.buck.rules.CachingBuildEngine.executeCommandsNowThatDepsAreBuilt(CachingBuildEngine.java:1240)
          at com.facebook.buck.rules.CachingBuildEngine.lambda$null$0(CachingBuildEngine.java:320)
          at com.facebook.buck.util.concurrent.WeightedListeningExecutorService.lambda$submitWithSemaphore$0(WeightedListeningExecutorService.java:77)
      BUILD FAILED: //models/microsemi:onos-models-microsemi-yang#srcs failed on step yang-compile with an exception:
      java.lang.NullPointerException
      org.onosproject.yang.compiler.translator.exception.TranslatorException: java.lang.NullPointerException
          at org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil.translateToJava(JavaCodeGeneratorUtil.java:222)
          at org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil.translate(JavaCodeGeneratorUtil.java:71)
          at org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode(JavaCodeGeneratorUtil.java:240)
          at org.onosproject.yang.compiler.tool.YangCompilerManager.translateToJava(YangCompilerManager.java:327)
          at org.onosproject.yang.compiler.tool.YangCompilerManager.processYangFiles(YangCompilerManager.java:170)
          at org.onosproject.yang.compiler.tool.YangCompilerManager.compileYangFiles(YangCompilerManager.java:97)
          at org.onosproject.yang.compiler.plugin.buck.YangGenerator.execute(YangGenerator.java:98)
          at org.onosproject.yang.compiler.plugin.buck.YangStep.execute(YangStep.java:73)
          at com.facebook.buck.step.DefaultStepRunner.runStepForBuildTarget(DefaultStepRunner.java:62)
          at com.facebook.buck.rules.CachingBuildEngine.executeCommandsNowThatDepsAreBuilt(CachingBuildEngine.java:1240)
          at com.facebook.buck.rules.CachingBuildEngine.lambda$null$0(CachingBuildEngine.java:320)
          at com.facebook.buck.util.concurrent.WeightedListeningExecutorService.lambda$submitWithSemaphore$0(WeightedListeningExecutorService.java:77)
          at com.google.common.util.concurrent.Futures$AsyncChainingFuture.doTransform(Futures.java:1442)
          at com.google.common.util.concurrent.Futures$AsyncChainingFuture.doTransform(Futures.java:1433)
          at com.google.common.util.concurrent.Futures$AbstractChainingFuture.run(Futures.java:1408)
          at com.google.common.util.concurrent.Futures$2$1.run(Futures.java:1177)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.NullPointerException
          at org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getCapitalCase(YangIoUtils.java:437)
          at org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGeneratorUtils.getAugmentSetterName(JavaFileGeneratorUtils.java:697)
          at org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGeneratorUtils.getSetOfNodeIdentifiers(JavaFileGeneratorUtils.java:671)
          at org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGeneratorUtils.addResolvedAugmentedDataNodeImports(JavaFileGeneratorUtils.java:727)
          at org.onosproject.yang.compiler.translator.tojava.TempJavaServiceFragmentFiles.generateJavaFile(TempJavaServiceFragmentFiles.java:116)
          at org.onosproject.yang.compiler.translator.tojava.TempJavaCodeFragmentFiles.generateJavaFile(TempJavaCodeFragmentFiles.java:204)
          at org.onosproject.yang.compiler.translator.tojava.javamodel.YangJavaModuleTranslator.generateCodeExit(YangJavaModuleTranslator.java:181)
          at org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil.generateCodeExit(JavaCodeGeneratorUtil.java:283)
          at org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil.translateToJava(JavaCodeGeneratorUtil.java:216)
          ... 18 more

      [-] PROCESSING BUCK FILES...FINISHED 2.7s [100%] 🐳  New buck daemon
      [-] DOWNLOADING... (0.00 B/S AVG, TOTAL: 0.00 B, 0 Artifacts)
      [-] BUILDING...FINISHED 9.9s [100%] (229/240 JOBS, 0 UPDATED, 0 [0.0%] CACHE MISS)
      scondon@CORKLTC0006:~/onos$

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            gauravagrawal Gaurav Agrawal
            Reporter:
            scondon Sean Condon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: