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

V?ctor Su?rez (JIRA) jira-events at jboss.com
Wed Jan 10 09:30:26 EST 2007


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: V?ctor Su?rez
         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;
    
    //refactored this line
    ByteArray byteArray = doGetByteArray(name);
    
    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