stop reporting handler leaks

Reviewed By: jeremydubreil

Differential Revision: D3295094

fbshipit-source-id: 038d933
master
Sam Blackshear 9 years ago committed by Facebook Github Bot 5
parent 44edd9ba7f
commit 83f511107b

@ -1,37 +0,0 @@
/*
* Copyright (c) 2015 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package android.os;
import com.facebook.infer.models.InferUndefined;
class Handler {
// model queue of tasks using 1-recency abstraction
private static Runnable sFakeHandlerQueue;
public final boolean postDelayed(Runnable r, long delayMillis) {
// model posting a delayed message as keeping a persistent reference to the Runnable
sFakeHandlerQueue = r;
return InferUndefined.boolean_undefined();
}
public final void removeCallbacks(Runnable r) {
if (r == sFakeHandlerQueue)
sFakeHandlerQueue = null;
}
public final void removeCallbacks(Runnable r, Object token) {
removeCallbacks(r);
}
public final void removeCallbacksAndMessages(Object token) {
sFakeHandlerQueue = null;
}
}

@ -402,10 +402,7 @@ let java_unchecked_exn_desc proc_name exn_name pre_str : error_desc =
let desc_context_leak pname context_typ fieldname leak_path : error_desc =
let fld_str = Ident.fieldname_to_string fieldname in
let leak_root =
if fld_str = "android.os.Handler.sFakeHandlerQueue"
then " Runnable passed to Handler.postDelayed |->\n "
else " Static field " ^ fld_str ^ " |->\n " in
let leak_root = " Static field " ^ fld_str ^ " |->\n " in
let leak_path_entry_to_str acc entry =
let entry_str = match entry with
| (Some fld, _) -> Ident.fieldname_to_string fld

@ -19,11 +19,6 @@
"file": "codetoanalyze/java/infer/ContextLeaks.java",
"procedure": "ContextLeaks$Singleton ContextLeaks$Singleton.getInstance(Context)"
},
{
"bug_type": "CONTEXT_LEAK",
"file": "codetoanalyze/java/infer/ContextLeaks.java",
"procedure": "void ContextLeaks.indirectHandlerLeak()"
},
{
"bug_type": "CONTEXT_LEAK",
"file": "codetoanalyze/java/infer/ContextLeaks.java",

@ -19,11 +19,6 @@
"file": "infer/tests/codetoanalyze/java/infer/ContextLeaks.java",
"procedure": "ContextLeaks$Singleton ContextLeaks$Singleton.getInstance(Context)"
},
{
"bug_type": "CONTEXT_LEAK",
"file": "infer/tests/codetoanalyze/java/infer/ContextLeaks.java",
"procedure": "void ContextLeaks.indirectHandlerLeak()"
},
{
"bug_type": "CONTEXT_LEAK",
"file": "infer/tests/codetoanalyze/java/infer/ContextLeaks.java",

@ -11,8 +11,6 @@ package codetoanalyze.java.infer;
import android.content.Context;
import android.app.Activity;
import android.os.Handler;
public class ContextLeaks extends Activity {
@ -92,29 +90,4 @@ public class ContextLeaks extends Activity {
return Singleton.getInstance(this.getApplicationContext());
}
private Handler handler = new Handler();
public void indirectHandlerLeak() {
handlerLeak();
}
private void handlerLeak() {
Runnable r =
new Runnable() {
public void run() {
}
};
handler.postDelayed(r, 10000);
}
public void handlerNoLeak() {
Runnable r =
new Runnable() {
public void run() {
}
};
handler.postDelayed(r, 10000);
handler.removeCallbacks(r);
}
}

@ -45,7 +45,6 @@ public class ContextLeaksTest {
"nonStaticInnerClassLeak",
"leakAfterInstanceFieldWrite",
"singletonLeak",
"indirectHandlerLeak",
"getInstance",
};
assertThat(

Loading…
Cancel
Save