Description of problem: Assuming you configure KnowledgeAgent/ResourceChangeScanner with ChangeSet.xml to connect to Guvnor. In addition, you configure drools.resource.urlcache to enable local file cache. When Guvnor is down, KnowledgeAgent keeps rebuilding kbase from cached files every time ResourceChangeScanner scans. This is because lastModified is always greater than lastRead. I added some comments in source codes after "<=" to explain. UrlResource.java: ===== public InputStream getInputStream() throws IOException { try { long lastMod = grabLastMod(); <= conn.getLastModified() of HTTP HEAD if (lastMod == 0) { //we will try the cache... if (cacheFileExists()) return fromCache(); } if (lastMod > 0 && lastMod > lastRead) { if (CACHE_DIR != null && url.getProtocol().equals("http") || url.getProtocol().equals("https")) { //lets grab a copy and cache it in case we need it in future... cacheStream(); <= A cache file is created. The cache file's lastModified is older than 'lastMod' above } } this.lastRead = lastMod; <= So lastRead is younger than cache file's lastModified return grabStream(); } catch (IOException e) { if (cacheFileExists()) { return fromCache(); } else { throw e; } } } ===== ResourceChangeScannerImpl.java: ===== public void scan() { ... for ( Entry<Resource, Set<ResourceChangeNotifier>> entry : this.resources.entrySet() ) { Resource resource = entry.getKey(); Set<ResourceChangeNotifier> notifiers = entry.getValue(); if ( !((InternalResource) resource).isDirectory() ) { // detect if Resource has been removed long lastModified = ((InternalResource) resource).getLastModified(); <= In case that Guvnor is down, lastModified is cache file's lastModified. long lastRead = ((InternalResource) resource).getLastRead(); ... } else if ( lastRead < lastModified && lastRead >= 0 ) { <= kbase rebuild this.listener.debug( "ResourceChangeScanner modified resource=" + resource + " : " + lastRead + " : " + lastModified ); // it's modified ===== Steps to Reproduce: 1. Start BRMS under GMT timezone (e.g. start with -Duser.timezone=GMT). If you test under other timezones, we need to fix BZ1027216 first. 2. Run a client with KnowledgeAgent 3. Shutdown BRMS Actual results: KnowledgeAgent rebuilds kbase from cached files every time ResourceChangeScanner scans. You will see log messages like: [2013-11-06 20:46:49,202:debug] KnowledgeAgent rebuilding KnowledgeBase using ChangeSet Expected results: KnowledgeAgent doesn't rebuild kbase until the resource in Guvnor is updated. Additional info: If packages are large, this would be a severe issue.
Created attachment 820295 [details] DroolsTest.java
Created attachment 820296 [details] ChangeSet.xml
Attached DroolsTest.java and ChangeSet.xml to reproduce the issue.
Sent a pull request: https://github.com/droolsjbpm/drools/pull/279
Verified fixed in 5.3.1-P05.
This product has been discontinued or is no longer tracked in Red Hat Bugzilla.