"[SOLVED] Possible error in com.rapidminer.parameter.Parameters"
This is the code of com.rapidminer.parameter.Parameters.setParameter(String key, String value) as of Unuk rev 708:
The fix is simple: the knownType initializer needs to be changed, and the Javadoc refined as follows:
Now, note that the Javadoc states "This method returns [...] false if no parameter type was defined for this key." But if you take a close look at the method's code, you'll see that it can *never* return false.
/**
* Sets the parameter for the given key after performing a range-check. This method returns true if the type was
* known and false if no parameter type was defined for this key.
*/
public boolean setParameter(String key, String value) {
boolean knownType = true;
if (value == null) {
keyToValueMap.remove(key);
} else {
ParameterType type = keyToTypeMap.get(key);
if (type != null) {
value = type.transformNewValue(value);
knownType = true;
}
keyToValueMap.put(key, value);
}
fireUpdate(key);
return knownType;
}
The fix is simple: the knownType initializer needs to be changed, and the Javadoc refined as follows:
/**
* Sets the parameter for the given key after performing a range-check.
* This method returns true if the type was known and false if no
* parameter type was defined for this key (or if the parameter type
* is no longer defined as a result of setting its value to null).
*/
public boolean setParameter(String key, String value) {
boolean knownType = false;
...
0
Answers
-
Hi Urhixdur,
thanks for the report. Seems to be true, we should initialize knownType with false here. I've fixed it
Best,
Nils0