[jboss-jira] [JBoss JIRA] Commented: (JBPM-821) ProcessClassLoader.getResourceAsStream throws JbpmException when the resource is not found in DB

Jan Ypma (JIRA) jira-events at lists.jboss.org
Wed Apr 4 11:49:58 EDT 2007


    [ http://jira.jboss.com/jira/browse/JBPM-821?page=comments#action_12358381 ] 
            
Jan Ypma commented on JBPM-821:
-------------------------------

It also seems that getResourceAsStream(s) will always look at 's' relating to the root of the process archive. The usual contract for getResourceAsStream for class loaders, is to look only in source packages. So getResourceAsStream(s) should also prepend "/classes" to [s], before delegating to fileDefinition (because .PAR classes are stored in the 'classes' folder). This could just be me missing out on some of the jBPM architecture, however.

> ProcessClassLoader.getResourceAsStream throws JbpmException when the resource is not found in DB
> ------------------------------------------------------------------------------------------------
>
>                 Key: JBPM-821
>                 URL: http://jira.jboss.com/jira/browse/JBPM-821
>             Project: JBoss jBPM
>          Issue Type: Bug
>          Components: Core Engine
>    Affects Versions:  jBPM 3.1.2
>            Reporter: Victor Suarez
>         Assigned To: Tom Baeyens
>
> "ProcessClassLoader.getResourceAsStream(String name)" must return null when the resource is not found <link>http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassLoader.html#getResourceAsStream(java.lang.String)</link>.
> But when the resource look up must be performed in the DB, if that resource is not found I get a JbpmException.
> "ProcessClassLoader.getResourceAsStream(String name)" delegates in "fileDefinition.getBytes(name)" for searching the resource, and this calls to "getBytesFromDb(name)", and finally, this calls to "getByteArray(name)", that performs this code:
>     if (byteArray == null) {
>       throw new JbpmException("file '" + name + "' not found in db");
>     }
> I think that a possible solution could be:
>   byte[] getBytesFromDb(String name) {
>     byte[] bytes = null;
>     
>     //refactored this line
>     ByteArray byteArray = doGetByteArray(name);
>     
>     if (byteArray != null)
>       bytes = byteArray.getBytes();
>     return bytes;
>   }
>   ByteArray getByteArray(String name) {
>     //extract method refactoring
>     ByteArray byteArray = doGetByteArray(name);
>     
>     if (byteArray == null) {
>       throw new JbpmException("file '" + name + "' not found in db");
>     }
>     return byteArray;
>   }
>   //extracted method
> 	ByteArray doGetByteArray(String name) {
> 		ByteArray byteArray = (ByteArray) (processFiles != null ? processFiles.get(name) : null);
> 		return byteArray;
> 	}
>   
> I let with no modifications "getByteArray(String name)" because is referenced in the rest of code.
> Thanks

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

        



More information about the jboss-jira mailing list