Skip to content

Commit c8028bf

Browse files
RomanBalabanov-NIBRmanuelschwarze
authored andcommitted
KNIME-1938 Fixed: Incorrect non-existing node setting handling
1 parent c893cc1 commit c8028bf

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

org.rdkit.knime.nodes/src/org/rdkit/knime/nodes/AbstractRDKitGenericNodeModel.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ protected void loadValidatedSettingsFrom(final NodeSettingsRO settings)
14491449
if (iErrorCounter == arrDeprecatedKeys.length - 1) {
14501450
LOGGER.debug("Deprecated keys did not work either. - Giving up.");
14511451

1452-
if (bIgnoreNonExistingSetting) {
1452+
if (bIgnoreNonExistingSetting && isNonExistingSettingException(excOrig)) {
14531453
LOGGER.warn("The new setting '" + newKey + "' was not known when the node" +
14541454
(nodeName == null ? "" : " '" + nodeName + "'") + " was saved. " +
14551455
"Please save the workflow again to include it for the future.");
@@ -1465,7 +1465,7 @@ protected void loadValidatedSettingsFrom(final NodeSettingsRO settings)
14651465
setting.loadSettingsFrom(settings);
14661466
}
14671467
catch (final InvalidSettingsException excOrig) {
1468-
if (bIgnoreNonExistingSetting) {
1468+
if (bIgnoreNonExistingSetting && isNonExistingSettingException(excOrig)) {
14691469
LOGGER.debug("A new setting was not known when the node" +
14701470
(nodeName == null ? "" : " '" + nodeName + "'") + " was saved.");
14711471
}
@@ -1547,7 +1547,7 @@ protected void validateSettings(final NodeSettingsRO settings)
15471547
if (iErrorCounter == arrDeprecatedKeys.length - 1) {
15481548
LOGGER.debug("Deprecated keys did not work either. - Giving up.");
15491549

1550-
if (!bIgnoreNonExistingSetting) {
1550+
if (!bIgnoreNonExistingSetting || !isNonExistingSettingException(excOrig)) {
15511551
throw excOrig;
15521552
}
15531553
}
@@ -1558,7 +1558,7 @@ protected void validateSettings(final NodeSettingsRO settings)
15581558
setting.validateSettings(settings);
15591559
}
15601560
catch (final InvalidSettingsException excOrig) {
1561-
if (!bIgnoreNonExistingSetting) {
1561+
if (!bIgnoreNonExistingSetting || !isNonExistingSettingException(excOrig)) {
15621562
throw excOrig;
15631563
}
15641564
}
@@ -2907,5 +2907,22 @@ protected static PortObject[] tablesToObjects(BufferedDataTable[] inTables) {
29072907
.toArray(PortObject[]::new);
29082908
}
29092909

2910+
//
2911+
// Private static methods
2912+
//
2913+
2914+
/**
2915+
* Checks and returns True if the supplied {@code InvalidSettingsException} instance
2916+
* is about a non-existing settings entry, otherwise False.
2917+
*
2918+
* @param e The {@code InvalidSettingsException} instance to check.
2919+
* Can be null.
2920+
* @return True if the supplied {@code InvalidSettingsException} instance is about a non-existing settings entry, otherwise False.
2921+
*/
2922+
private static boolean isNonExistingSettingException(InvalidSettingsException e) {
2923+
return e != null && e.getMessage() != null
2924+
&& e.getMessage().matches(".*? for key \".*?\" not found.");
2925+
}
2926+
29102927
}
29112928

0 commit comments

Comments
 (0)