Commit 9084f434 authored by rosemaryng's avatar rosemaryng
Browse files

[Ding] Fixed null pointer handling on impatience metrics for closed class

parent 467beb97
No preview for this file type
......@@ -739,7 +739,7 @@ public class Queue extends InputSection {
* @return
*/
private boolean jobClassHasRequiredImpatience(int jobClassId, ImpatienceType requiredImpatience) {
return impatienceStrategyPerStationClass[jobClassId] != null
return impatienceStrategyPerStationClass != null && impatienceStrategyPerStationClass[jobClassId] != null
&& impatienceStrategyPerStationClass[jobClassId].isImpatienceType(requiredImpatience);
}
......
......@@ -824,6 +824,7 @@ public class LinkedJobInfoList implements JobInfoList {
}
}
if (balkingRate != null) {
balkingRate.update(NetSystem.getTime() - getLastJobBalkingTime(), 1.0);
}
}
......
......@@ -629,21 +629,27 @@ public class XMLWriter implements CommonConstants, XMLConstantNames {
Object classKey = classes.get(i);
ImpatienceType impatienceType = model.getImpatienceType(stationKey, classKey);
// Based on the ImpatienceStrategy, retrieve the object from the model and write it to XML
switch (impatienceType) {
case RENEGING:
impatienceParams[i] = createRenegingParameter(model, stationKey, classKey);
break;
case BALKING:
impatienceParams[i] = createBalkingParameter(model, stationKey, classKey, classes.size(), i);
break;
default:
// Write a null parameter when no impatience strategy was selected
impatienceParams[i] = new XMLParameter(impatienceClassName, impatiencePath,
model.getClassName(classKey), "null", true);
break;
if (impatienceType != null) { // handling null pointer
// Based on the ImpatienceStrategy, retrieve the object from the model and write it to XML
switch (impatienceType) {
case RENEGING:
impatienceParams[i] = createRenegingParameter(model, stationKey, classKey);
break;
case BALKING:
impatienceParams[i] = createBalkingParameter(model, stationKey, classKey, classes.size(), i);
break;
default:
// Write a null parameter when no impatience strategy was selected
impatienceParams[i] = new XMLParameter(impatienceClassName, impatiencePath,
model.getClassName(classKey), "null", true);
break;
}
} else {
// Write a null parameter when no impatience strategy was selected
impatienceParams[i] = new XMLParameter(impatienceClassName, impatiencePath,
model.getClassName(classKey), "null", true);
}
}
// finally, create node from parameters and append it to the section element
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment