AttachCurrentThread should only warn on missing thread name if CheckJNI is enabled.
Bug: 17108693
Change-Id: I346cc090e091605c552e5954d7ea1ca4874cea5f
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 05003cb..ba53c43 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -900,11 +900,7 @@
bool Runtime::AttachCurrentThread(const char* thread_name, bool as_daemon, jobject thread_group,
bool create_peer) {
- bool success = Thread::Attach(thread_name, as_daemon, thread_group, create_peer) != NULL;
- if (thread_name == NULL) {
- LOG(WARNING) << *Thread::Current() << " attached without supplying a name";
- }
- return success;
+ return Thread::Attach(thread_name, as_daemon, thread_group, create_peer) != NULL;
}
void Runtime::DetachCurrentThread() {
diff --git a/runtime/thread.cc b/runtime/thread.cc
index c7cd57d..dcc897f 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -403,6 +403,8 @@
if (thread_name != nullptr) {
self->tlsPtr_.name->assign(thread_name);
::art::SetThreadName(thread_name);
+ } else if (self->GetJniEnv()->check_jni) {
+ LOG(WARNING) << *Thread::Current() << " attached without supplying a name";
}
}