Source:
public ProcessConfigModule getProcessConfig(String path) throws IOException { ProcessConfigModule processConfig = new ProcessConfigModule(); KModuleContentHandler kModuleContentHandler = new KModuleContentHandler(); try (InputStream in = IOUtils.toInputStream(guvnorM2Repository.getKieDeploymentDescriptorText(path), "UTF-8");) { RuntimeStrategy runtimeStrategy = DeploymentDescriptorIO.fromXml(in).getRuntimeStrategy(); switch (runtimeStrategy) { case SINGLETON: processConfig.setRuntimeStrategy(SINGLETON); break; case PER_CASE: processConfig.setRuntimeStrategy(PER_CASE); break; case PER_PROCESS_INSTANCE: processConfig.setRuntimeStrategy(PER_PROCESS_INSTANCE); break; case PER_REQUEST: processConfig.setRuntimeStrategy(PER_REQUEST); break; } } catch (Exception e) { LOGGER.warn(e.getMessage()); } Map<String, KBaseModel> kBaseModelHashMap = kModuleContentHandler.toModel(guvnorM2Repository.getKModuleText(path)).getKBases(); AtomicReference<KBaseModel> kBaseModelAtomicReference = new AtomicReference<>(); kBaseModelHashMap.forEach((s, kBaseModel) -> { if (kBaseModel.isDefault()) { kBaseModelAtomicReference.set(kBaseModel); } }); KBaseModel defaultKBaseModel = kBaseModelAtomicReference.get(); if (defaultKBaseModel != null) { processConfig.setkBase(defaultKBaseModel.getName()); AtomicReference<KSessionModel> kSessionModelAtomicReference = new AtomicReference<>(); defaultKBaseModel.getKSessions().forEach(kSessionModel -> { if (kSessionModel.isDefault()) { kSessionModelAtomicReference.set(kSessionModel); } }); KSessionModel defaultKSessionModel = kSessionModelAtomicReference.get(); if (defaultKSessionModel != null) { processConfig.setkSession(defaultKSessionModel.getName()); } } return processConfig; }

Target:
public ProcessConfigModule getProcessConfig(String path) throws IOException { ProcessConfigModule processConfig = new ProcessConfigModule(); KModuleContentHandler kModuleContentHandler = new KModuleContentHandler(); try (InputStream in = IOUtils.toInputStream(guvnorM2Repository.getKieDeploymentDescriptorText(path), StandardCharsets.UTF_8)) { RuntimeStrategy runtimeStrategy = DeploymentDescriptorIO.fromXml(in).getRuntimeStrategy(); switch (runtimeStrategy) { case SINGLETON: processConfig.setRuntimeStrategy(SINGLETON); break; case PER_CASE: processConfig.setRuntimeStrategy(PER_CASE); break; case PER_PROCESS_INSTANCE: processConfig.setRuntimeStrategy(PER_PROCESS_INSTANCE); break; case PER_REQUEST: processConfig.setRuntimeStrategy(PER_REQUEST); break; } } Map<String, KBaseModel> kBaseModelHashMap = kModuleContentHandler.toModel(guvnorM2Repository.getKModuleText(path)).getKBases(); KBaseModel defaultKBaseModel = null; Optional<KBaseModel> optionalKBaseModel = kBaseModelHashMap.values().stream().filter(KBaseModel::isDefault).findFirst(); if (optionalKBaseModel.isPresent()) { defaultKBaseModel = optionalKBaseModel.get(); } if (defaultKBaseModel != null) { processConfig.setKBase(defaultKBaseModel.getName()); Optional<KSessionModel> optionalKSessionModel = defaultKBaseModel.getKSessions().stream().filter(KSessionModel::isDefault).findFirst(); KSessionModel defaultKSessionModel = null; if (optionalKSessionModel.isPresent()) { defaultKSessionModel = optionalKSessionModel.get(); processConfig.setKSession(defaultKSessionModel.getName()); } } return processConfig; }