Options

"[SOLVED] Possible error in com.rapidminer.parameter.Parameters"

UrhixidurUrhixidur Member Posts: 40 Contributor II
edited June 2019 in Help
This is the code of com.rapidminer.parameter.Parameters.setParameter(String key, String value) as of Unuk rev 708:

/**
* 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;
}
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.

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;
...
Tagged:

Answers

  • Options
    Nils_WoehlerNils_Woehler Member Posts: 463 Maven
    Hi Urhixdur,

    thanks for the report. Seems to be true, we should initialize knownType with false here. I've fixed it :)

    Best,
    Nils
Sign In or Register to comment.