Catch exception inside preprocessor loop so that loop continues after

error (for unit tests).  Also make sure to set ".loaded" variable before
calling loadFromSource so that if an exception happens we won't try to
load it again later.

Fixes #2542.
This commit is contained in:
Theron Tock
2011-06-29 14:28:33 -07:00
parent 57de77b341
commit 2ee4869fac
2 changed files with 22 additions and 16 deletions
+5
View File
@@ -4,6 +4,11 @@
validate the drop the same we we validate in dragMove to make sure validate the drop the same we we validate in dragMove to make sure
the drop is valid. the drop is valid.
* Fixed #2542. Catch exception inside preprocessor loop so that
loop continues after error (for unit tests). Also make sure to
set ".loaded" variable before calling loadFromSource so that if an
exception happens we won't try to load it again later.
2011-06-27 theron <theron@netcitadel.com> 2011-06-27 theron <theron@netcitadel.com>
* Fixed #2530, where adding a subfolder opens the parent folder in * Fixed #2530, where adding a subfolder opens the parent folder in
@@ -71,11 +71,9 @@ Preprocessor::Preprocessor(FWObjectDatabase *_db,
void Preprocessor::convertObject(FWObject *obj) void Preprocessor::convertObject(FWObject *obj)
{ {
MultiAddress *adt = MultiAddress::cast(obj); MultiAddress *adt = MultiAddress::cast(obj);
if (adt!=NULL && adt->isCompileTime() && if (adt!=NULL && adt->isCompileTime())
obj->getInt(".loaded") != infinite_recursion_breaker)
{ {
adt->loadFromSource(ipv6, inTestMode()); adt->loadFromSource(ipv6, inTestMode());
obj->setInt(".loaded", infinite_recursion_breaker);
} }
} }
@@ -107,7 +105,16 @@ void Preprocessor::findMultiAddressObjectsUsedInRules(FWObject *top)
else else
{ {
FWObject *obj_ptr = FWReference::getObject(obj); FWObject *obj_ptr = FWReference::getObject(obj);
convertObject(obj_ptr); if (obj_ptr->getInt(".loaded") == infinite_recursion_breaker)
continue;
obj_ptr->setInt(".loaded", infinite_recursion_breaker);
try
{
convertObject(obj_ptr);
} catch (FWException &ex) {
abort(ex.toString());
}
// Note that MultiAddress inherits ObjectGroup // Note that MultiAddress inherits ObjectGroup
if (Group::cast(obj_ptr)) if (Group::cast(obj_ptr))
@@ -127,20 +134,14 @@ void Preprocessor::compile()
infinite_recursion_breaker++; infinite_recursion_breaker++;
FWObject *rule_copy = NULL; FWObject *rule_copy = NULL;
try if (single_rule_mode)
{ {
if (single_rule_mode) rule_copy = dbcopy->findInIndex(single_rule_compile_rule->getId());
{ findMultiAddressObjectsUsedInRules(rule_copy);
rule_copy = dbcopy->findInIndex(single_rule_compile_rule->getId()); } else
findMultiAddressObjectsUsedInRules(rule_copy);
} else
{
FWObject *fwcopy = dbcopy->findInIndex(fw->getId());
findMultiAddressObjectsUsedInRules(fwcopy);
}
} catch (FWException &ex)
{ {
abort(ex.toString()); FWObject *fwcopy = dbcopy->findInIndex(fw->getId());
findMultiAddressObjectsUsedInRules(fwcopy);
} }
/* resolving MultiAddress objects */ /* resolving MultiAddress objects */
// convertObjectsRecursively(dbcopy); // convertObjectsRecursively(dbcopy);