mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-27 18:30:51 +02: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);
|
pStrategy = new RotateBySizeStrategy(n*1024*1024);
|
||||||
else if (unit.empty())
|
else if (unit.empty())
|
||||||
pStrategy = new RotateBySizeStrategy(n);
|
pStrategy = new RotateBySizeStrategy(n);
|
||||||
else if (unit != "never")
|
else if (unit == "never")
|
||||||
|
pStrategy = new NullRotateStrategy();
|
||||||
|
else
|
||||||
throw InvalidArgumentException("rotation", rotation);
|
throw InvalidArgumentException("rotation", rotation);
|
||||||
|
|
||||||
return pStrategy;
|
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()
|
void FileChannelTest::testRotateBySize()
|
||||||
{
|
{
|
||||||
std::string name = filename();
|
std::string name = filename();
|
||||||
@ -804,6 +831,7 @@ CppUnit::Test* FileChannelTest::suite()
|
|||||||
{
|
{
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FileChannelTest");
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FileChannelTest");
|
||||||
|
|
||||||
|
CppUnit_addTest(pSuite, FileChannelTest, testRotateNever);
|
||||||
CppUnit_addTest(pSuite, FileChannelTest, testRotateBySize);
|
CppUnit_addTest(pSuite, FileChannelTest, testRotateBySize);
|
||||||
CppUnit_addTest(pSuite, FileChannelTest, testRotateByAge);
|
CppUnit_addTest(pSuite, FileChannelTest, testRotateByAge);
|
||||||
CppUnit_addLongTest(pSuite, FileChannelTest, testRotateAtTimeDayUTC);
|
CppUnit_addLongTest(pSuite, FileChannelTest, testRotateAtTimeDayUTC);
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
FileChannelTest(const std::string& name);
|
FileChannelTest(const std::string& name);
|
||||||
~FileChannelTest();
|
~FileChannelTest();
|
||||||
|
|
||||||
|
void testRotateNever();
|
||||||
void testRotateBySize();
|
void testRotateBySize();
|
||||||
void testRotateByAge();
|
void testRotateByAge();
|
||||||
void testRotateAtTimeDayUTC();
|
void testRotateAtTimeDayUTC();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user