[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2293) Classpath resources being scanned by ResourceChangeScanner could cause improper resource removal

Michael Neale (JIRA) jira-events at lists.jboss.org
Tue Oct 13 19:08:05 EDT 2009


    [ https://jira.jboss.org/jira/browse/JBRULES-2293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12489695#action_12489695 ] 

Michael Neale commented on JBRULES-2293:
----------------------------------------

Something like the following may help get a more correct lastModified time... 

  URL url = this.getClass().getResource(myResource);
    String fileName;
    if (url.getProtocol().equals("file")) {
        fileName = url.getFile();        
    } else if (url.getProtocol().equals("jar")) {
        JarURLConnection jarUrl = (JarURLConnection) url.openConnection();
        fileName = jarUrl.getJarFile().getName();            
    } else {
        throw new IllegalArgumentException("Not a file");
    }
    File file = new File(fileName);
    long lastModified = file.lastModified();

> Classpath resources being scanned by ResourceChangeScanner could cause improper resource removal
> ------------------------------------------------------------------------------------------------
>
>                 Key: JBRULES-2293
>                 URL: https://jira.jboss.org/jira/browse/JBRULES-2293
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-core
>    Affects Versions: 5.0.1.FINAL
>         Environment: Windows XP
> Java 5
> Running in Oracle OC4J 10.1.3.2
>            Reporter: Steve Ronderos
>            Assignee: Mark Proctor
>         Attachments: fix_for_classpath_resources.patch
>
>
> I encountered an issue today with my KnowledgeAgent removing resources from its RuleBase shortly after creating it.  I have the ResourceChangeScanner running in my application.
> I tracked the issue back to the scan() method in ResourceChangeScannerImpl.  It appears that the method is trying to identify resources that are no longer available and remove them from both the RuleBase and future scans.  To do this it is checking lastModified on the resource and on a result of 0 removing the resource.  The resources that I configured in my change-set definitely still exist, but due to URL handler implementation provided by my classloader, getLastModified always returns 0.  (The resource I'm retrieving is coming from a jar that is in my application's classpath and the URL handler implementation is oracle.classloader.SharedCodeSourceURL)
> Full Email Group trail: http://www.nabble.com/Issue-with-ResourceChangeScanner-td25792358.html
> Michael recommends to never scan classpath resources.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list