Source:
<code>public List<KiePMMLModel> getModelsFromPlugin(String factoryClassName, String packageName, InputStream inputStream, Object kbuilder) { <START> logger.trace("getModels {}", inputStream, kbuilder); <END> try { PMML commonPMMLModel = KiePMMLUtil.load(inputStream); Set<String> expectedClasses = commonPMMLModel.getModels() .stream() .map(model -> packageName + "." + getSanitizedClassName(model.getModelName())) .collect(Collectors.toSet()); List<KiePMMLModel> toReturn = getModelsFromPlugin(packageName, commonPMMLModel, kbuilder); Set<String> generatedClasses = new HashSet<>(); toReturn.forEach(kiePMMLModel -> { if (kiePMMLModel instanceof HasSourcesMap) { generatedClasses.addAll(((HasSourcesMap) kiePMMLModel).getSourcesMap().keySet()); } else { generatedClasses.add(kiePMMLModel.getClass().getName()); } }); if (!generatedClasses.containsAll(expectedClasses)) { expectedClasses.removeAll(generatedClasses); String missingClasses = String.join(", ", expectedClasses); throw new KiePMMLException("Expected generated class " + missingClasses + " not found"); } Map<String, String> factorySourceMap = getFactorySourceCode(factoryClassName, packageName, expectedClasses); KiePMMLFactoryModel kiePMMLFactoryModel = new KiePMMLFactoryModel(factoryClassName, packageName, factorySourceMap); toReturn.add(kiePMMLFactoryModel); return toReturn; } catch (KiePMMLInternalException e) { throw new KiePMMLException("KiePMMLInternalException", e); } catch (KiePMMLException e) { throw e; } catch (Exception e) { throw new ExternalException("ExternalException", e); } }</code><technical_language>please add isTraceEnabled check</technical_language>

Target:
public List<KiePMMLModel> getModelsFromPlugin(String factoryClassName, String packageName, InputStream inputStream, Object kbuilder) { logger.trace("getModels {}", inputStream, kbuilder); try { PMML commonPMMLModel = KiePMMLUtil.load(inputStream); Set<String> expectedClasses = commonPMMLModel.getModels() .stream() .map(model -> packageName + "." + getSanitizedClassName(model.getModelName())) .collect(Collectors.toSet()); List<KiePMMLModel> toReturn = getModelsFromPlugin(packageName, commonPMMLModel, kbuilder); Set<String> generatedClasses = new HashSet<>(); toReturn.forEach(kiePMMLModel -> { if (kiePMMLModel instanceof HasSourcesMap) { generatedClasses.addAll(((HasSourcesMap) kiePMMLModel).getSourcesMap().keySet()); } else { throw new KiePMMLException(String.format("Expecting %s at this phase", HasSourcesMap.class.getCanonicalName())); } }); if (!generatedClasses.containsAll(expectedClasses)) { expectedClasses.removeAll(generatedClasses); String missingClasses = String.join(", ", expectedClasses); throw new KiePMMLException("Expected generated class " + missingClasses + " not found"); } Map<String, String> factorySourceMap = getFactorySourceCode(factoryClassName, packageName, expectedClasses); KiePMMLFactoryModel kiePMMLFactoryModel = new KiePMMLFactoryModel(factoryClassName, packageName, factorySourceMap); toReturn.add(kiePMMLFactoryModel); return toReturn; } catch (KiePMMLInternalException e) { throw new KiePMMLException("KiePMMLInternalException", e); } catch (KiePMMLException e) { throw e; } catch (Exception e) { throw new ExternalException("ExternalException", e); } }