Skip to content

Commit

Permalink
Fix destruction of Intl Collator and DateTimeFormat
Browse files Browse the repository at this point in the history
Summary:
Like `NumberFormat`, `Collator` and `DateTimeFormat` also contain JNI
references. So we need to destroy them in a context that is
registered with the JVM.

Reviewed By: Huxpro

Differential Revision: D29005275

fbshipit-source-id: 38c53fad9c20a5146eedd1bd9c403b2bd6d0d46e
  • Loading branch information
neildhar authored and facebook-github-bot committed Jun 9, 2021
1 parent f8c6545 commit ed1baf1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Platform/Intl/PlatformIntlAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ struct Collator::Impl {

Collator::Collator() : impl_(std::make_unique<Impl>()) {}

Collator::~Collator() {}
Collator::~Collator() {
jni::ThreadScope::WithClassLoader([&] { impl_.reset(); });
}

vm::CallResult<std::vector<std::u16string>> Collator::supportedLocalesOf(
vm::Runtime *runtime,
Expand Down Expand Up @@ -408,7 +410,9 @@ struct DateTimeFormat::Impl {

DateTimeFormat::DateTimeFormat() : impl_(std::make_unique<Impl>()) {}

DateTimeFormat::~DateTimeFormat() {}
DateTimeFormat::~DateTimeFormat() {
jni::ThreadScope::WithClassLoader([&] { impl_.reset(); });
}

vm::CallResult<std::vector<std::u16string>> DateTimeFormat::supportedLocalesOf(
vm::Runtime *runtime,
Expand Down

0 comments on commit ed1baf1

Please sign in to comment.