if (cache == null) {
byte[] fileContents = getBytes(KieBuilderImpl.getCompilationCachePath(releaseId, kbaseName));
if (fileContents != null) {
ExtensionRegistry registry = KieModuleCacheHelper.buildRegistry();
try {
Header _header = KieModuleCacheHelper.readFromStreamWithHeaderPreloaded(new ByteArrayInputStream(fileContents), registry);
if (!Drools.isCompatible(_header.getVersion().getVersionMajor(),
_header.getVersion().getVersionMinor(),
_header.getVersion().getVersionRevision())) {
// if cache has been built with an incompatible version avoid to use it
log.warn("The compilation cache has been built with an incompatible version. " +
"You should recompile your project in order to use it with current release.");
return null;
}
KModuleCache _cache = KModuleCache.parseFrom(_header.getPayload());
cache = new CompilationCache();
for (CompilationData _data : _cache.getCompilationDataList()) {
for (CompDataEntry _entry : _data.getEntryList()) {
cache.addEntry(_data.getDialect(), _entry.getId(), _entry.getData().toByteArray());