mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-24 10:59:23 +01:00
fix: NULL pointer strategy when setting rotation never #4411
Regression from 66e93f98cc3530c9ea5a748cf2248d2592b61853.
This commit is contained in:
parent
6dcafc8989
commit
fe08b68c2a
@ -271,7 +271,9 @@ RotateStrategy* FileChannel::createRotationStrategy(const std::string& rotation,
|
||||
pStrategy = new RotateBySizeStrategy(n*1024*1024);
|
||||
else if (unit.empty())
|
||||
pStrategy = new RotateBySizeStrategy(n);
|
||||
else if (unit != "never")
|
||||
else if (unit == "never")
|
||||
pStrategy = new NullRotateStrategy();
|
||||
else
|
||||
throw InvalidArgumentException("rotation", rotation);
|
||||
|
||||
return pStrategy;
|
||||
|
@ -59,6 +59,33 @@ FileChannelTest::~FileChannelTest()
|
||||
}
|
||||
|
||||
|
||||
void FileChannelTest::testRotateNever()
|
||||
{
|
||||
std::string name = filename();
|
||||
try
|
||||
{
|
||||
AutoPtr<FileChannel> pChannel = new FileChannel(name);
|
||||
pChannel->setProperty(FileChannel::PROP_ROTATION, "never");
|
||||
pChannel->open();
|
||||
Message msg("source", "This is a log file entry", Message::PRIO_INFORMATION);
|
||||
for (int i = 0; i < 200; ++i)
|
||||
{
|
||||
pChannel->log(msg);
|
||||
}
|
||||
File f(name);
|
||||
assertTrue (f.exists());
|
||||
f = name + ".0";
|
||||
assertTrue (!f.exists());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
remove(name);
|
||||
throw;
|
||||
}
|
||||
remove(name);
|
||||
}
|
||||
|
||||
|
||||
void FileChannelTest::testRotateBySize()
|
||||
{
|
||||
std::string name = filename();
|
||||
@ -804,6 +831,7 @@ CppUnit::Test* FileChannelTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FileChannelTest");
|
||||
|
||||
CppUnit_addTest(pSuite, FileChannelTest, testRotateNever);
|
||||
CppUnit_addTest(pSuite, FileChannelTest, testRotateBySize);
|
||||
CppUnit_addTest(pSuite, FileChannelTest, testRotateByAge);
|
||||
CppUnit_addLongTest(pSuite, FileChannelTest, testRotateAtTimeDayUTC);
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
FileChannelTest(const std::string& name);
|
||||
~FileChannelTest();
|
||||
|
||||
void testRotateNever();
|
||||
void testRotateBySize();
|
||||
void testRotateByAge();
|
||||
void testRotateAtTimeDayUTC();
|
||||
|
Loading…
x
Reference in New Issue
Block a user