#vulnerable code 
                              @Override
  public void run() {

    CodegenConfigurator configurator = new CodegenConfigurator();

    CodeGenerator codegenerator = GeneratorFactory.getGenerator(CodeGenerator.class, "default");

    // add additional property
    Optional.ofNullable(properties).ifPresent(properties ->
        Arrays.stream(properties.split(",")).forEach(property -> {
          String[] split = property.split("=");
          if (split != null && split.length == 2) {
            configurator.addAdditionalProperty(split[0], split[1]);
          }
        })
    );

    configurator.setOutputDir(output)
        .setGroupId(groupId)
        .setArtifactId(artifactId)
        .setArtifactVersion(artifactVersion)
        .setLibrary(programmingModel)
        .setGeneratorName(framework)
        .setApiPackage(apiPackage)
        .setModelPackage(modelPackage);

    configurator.addAdditionalProperty(ProjectMetaConstant.SERVICE_TYPE, serviceType);

    if (isNotEmpty(specFile)) {

      File contractFile = new File(specFile);

      if (contractFile.isDirectory()) {
        try {
          Files.walkFileTree(Paths.get(contractFile.toURI()), new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {

              configurator.setInputSpec(file.toFile().getCanonicalPath())
                  .addAdditionalProperty("apiName", file.toFile().getName().split("\\.")[0]);

              try {
                codegenerator.configure(Collections.singletonMap("configurator", configurator));
                codegenerator.generate();
              } catch (RuntimeException e) {
                throw new RuntimeException("Failed to generate code base on file " + file.toFile().getName());
              }

              return super.visitFile(file, attrs);
            }
          });
        } catch (RuntimeException | IOException e) {
          LOGGER.error(e.getMessage());
          return;
        }
      } else {
        configurator.setInputSpec(specFile);
        codegenerator.configure(Collections.singletonMap("configurator", configurator));
        codegenerator.generate();
      }

      LOGGER.info("Success to generate code, the directory is: {}", output);
    }
  } 
                            #location 43 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                              @Override
  public void run() {

    CodeGenerator codegenerator = GeneratorFactory.getGenerator(CodeGenerator.class, "default");

    if (codegenerator == null) {
      LOGGER.warn("Not CodeGenerator found");
      return;
    }

    CodegenConfigurator configurator = new CodegenConfigurator();

    // add additional property
    Optional.ofNullable(properties).ifPresent(properties ->
        Arrays.stream(properties.split(",")).forEach(property -> {
          String[] split = property.split("=");
          if (split != null && split.length == 2) {
            configurator.addAdditionalProperty(split[0], split[1]);
          }
        })
    );

    configurator.setOutputDir(output)
        .setGroupId(groupId)
        .setArtifactId(artifactId)
        .setArtifactVersion(artifactVersion)
        .setLibrary(programmingModel)
        .setGeneratorName(framework)
        .setApiPackage(apiPackage)
        .setModelPackage(modelPackage);

    configurator.addAdditionalProperty(ProjectMetaConstant.SERVICE_TYPE, serviceType);

    if (isNotEmpty(specFile)) {

      File contractFile = new File(specFile);

      if (contractFile.isDirectory()) {
        try {
          Files.walkFileTree(Paths.get(contractFile.toURI()), new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {

              configurator.setInputSpec(file.toFile().getCanonicalPath())
                  .addAdditionalProperty("apiName", file.toFile().getName().split("\\.")[0]);

              try {
                codegenerator.configure(Collections.singletonMap("configurator", configurator));
                codegenerator.generate();
              } catch (RuntimeException e) {
                throw new RuntimeException("Failed to generate code base on file " + file.toFile().getName());
              }

              return super.visitFile(file, attrs);
            }
          });
        } catch (RuntimeException | IOException e) {
          LOGGER.error(e.getMessage());
          return;
        }
      } else {
        configurator.setInputSpec(specFile).addAdditionalProperty("apiName", contractFile.getName().split("\\.")[0]);
        codegenerator.configure(Collections.singletonMap("configurator", configurator));
        codegenerator.generate();
      }

      LOGGER.info("Success to generate code, the directory is: {}", output);
    }
  }