From 41d1d57af0f5cfccc73a5cccdc279324cf507f34 Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Wed, 13 May 2020 17:17:56 -0700 Subject: [PATCH] ICU-21122 Fix flaky TestAdoptCalendarLeak --- icu4c/source/test/intltest/dtfmttst.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/icu4c/source/test/intltest/dtfmttst.cpp b/icu4c/source/test/intltest/dtfmttst.cpp index 59eb11ef145..945728d5e4f 100644 --- a/icu4c/source/test/intltest/dtfmttst.cpp +++ b/icu4c/source/test/intltest/dtfmttst.cpp @@ -5576,14 +5576,19 @@ void DateFormatTest::TestAdoptCalendarLeak() { UErrorCode status = U_ZERO_ERROR; // This test relies on the locale fullName exceeding ULOC_FULLNAME_CAPACITY // in order for setKeywordValue to fail. + Calendar* cal = Calendar::createInstance(status); + ASSERT_OK(status); SimpleDateFormat sdf( "d.M.y", Locale("de__POSIX@colstrength=primary;currency=eur;em=default;" "hours=h23;lb=strict;lw=normal;measure=metric;numbers=latn;" "rg=atzzzz;sd=atat1;ss=none;timezone=Europe/Vienna"), status); - ASSERT_OK(status); - sdf.adoptCalendar(Calendar::createInstance(status)); + // ASSERT_OK(status); Please do NOT add ASSERT_OK here. The point of this + // test is to ensure sdf.adoptCalendar won't leak AFTER the above FAILED. + // If the following caused crash we should fix the implementation not change + // this test. + sdf.adoptCalendar(cal); } /** -- 2.40.0