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

Tom Baeyens (JIRA) jira-events at lists.jboss.org
Fri Sep 7 09:06:11 EDT 2007


     [ http://jira.jboss.com/jira/browse/JBPM-821?page=all ]

Tom Baeyens closed JBPM-821.
----------------------------

    Resolution: Done

> 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
>             Fix For: jBPM jPDL 3.2.2
>
>
> "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