Jonas - 2014-05-21

I've found a problem in line 575 of ASMService.java, in the getDetails() function:

String runtimeID = (String) PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowName).getAllRuntimeInstance().keys().nextElement();

Specifically this doesn't check for that there are any elements in the result of .keys(), normally done using .hasMoreElements(), leading to a NoElementException when a workflow has run with some kind of Error.

To be able to continue with the work I am doing I fixed my working copy of ASM with the following, returning null when no details are available.

WorkflowInstanceBean workflowinstance = new WorkflowInstanceBean();
UserData user = PortalCacheService.getInstance().getUser(userID);
WorkflowData workflow = user.getWorkflow(workflowName);
ConcurrentHashMap<String,WorkflowRunTime> runtimes = workflow.getAllRuntimeInstance();
Enumeration<String> keys = runtimes.keys();
if (!keys.hasMoreElements()) {
    return null;
}
String runtimeID = (String) keys.nextElement();