From 6020aae778a6a6554a8c4fe846a34215d0bc320d Mon Sep 17 00:00:00 2001 From: scott snyder <snyder@bnl.gov> Date: Mon, 24 Sep 2018 20:57:40 +0200 Subject: [PATCH] CollectionBase: In test code, make sure files are closed before reopening. The test in this package was leaking ICollection objects. This meant that we could try to open a ROOT file that we still had open. With root 6.14, this can cause an infinite recursion. Make sure to delete ICollectionObjects when we're done with them, so that the files get closed. Former-commit-id: 478f5ee36314449c60fcb0cc897842f39871d856 --- .../APR/CollectionBase/test/Factory_test.cxx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Database/APR/CollectionBase/test/Factory_test.cxx b/Database/APR/CollectionBase/test/Factory_test.cxx index fffbfe50c12..6d389082da3 100644 --- a/Database/APR/CollectionBase/test/Factory_test.cxx +++ b/Database/APR/CollectionBase/test/Factory_test.cxx @@ -117,8 +117,10 @@ int main(int argc, char** ) collection = factory->openWithPhysicalName(physicalName, 0); } cout << (collection ? "OK":"KO") << endl; + delete collection; + collection = nullptr; + - cout << "Open collection 1 with guid .... "; if(crude) { CollectionDescription desc( guid, "" ); @@ -126,6 +128,8 @@ int main(int argc, char** ) } else collection = factory->openWithGuid(guid, 0); cout << (collection ? "OK":"KO") << endl; + delete collection; + collection = nullptr; cout << "Open collection 2 with logical name .... "; @@ -135,6 +139,8 @@ int main(int argc, char** ) } else collection = factory->openWithLogicalName("logicalName2", 0); cout << (collection ? "OK":"KO") << endl; + delete collection; + collection = nullptr; cout << "Try to create the existing collection 0 ... "; @@ -153,7 +159,7 @@ int main(int argc, char** ) } - + cout << "Try to replace the replicated collection 1 ... "; physicalName = collType+"|"+collConnection+"|"+"Collection1"; try{ @@ -181,13 +187,15 @@ int main(int argc, char** ) CollectionDescription desc( "Collection0", collType, collConnection ); collection = factory->createAndRegister( desc, 0, true, "", collMetaData ); } + delete collection; + collection = nullptr; cout << "OK, this works" << endl; }catch( std::exception& e){ cout << "ERROR, this should work" << endl; std::cout << "Exception: "<<e.what()<<std::endl; } - + cout << "Try to update the NON replicated collection 0 ... "; physicalName = collType+"|"+collConnection+"|"+"Collection0"; try{ @@ -198,6 +206,8 @@ int main(int argc, char** ) collection = factory->openWithPhysicalName( physicalName, 0, ICollection::UPDATE ); cout << "OK, this works" << endl; + delete collection; + collection = nullptr; }catch( std::exception&e ){ cout << "ERROR, this should work" << endl; std::cout << "Exception: "<<e.what()<<std::endl; @@ -227,6 +237,8 @@ int main(int argc, char** ) collection = factory->openWithLogicalName( "logicalName0", 0,// logical name false ); // readOnly cout << "OK it works" << endl; + delete collection; + collection = nullptr; }catch( std::exception&){ cout << "ERROR, this should work" << endl; } -- GitLab