Program: 20812
Project: 20812
Buggy source:
/** 
 * Create a new instance of DiscoveryManager. Direct use of this constructor is not recommended. In most cases, you should use DiscoveryManager.getInstance() instead.
 */
public DiscoveryManager(Context context,ConnectableDeviceStore connectableDeviceStore){
  this.context=context;
  this.connectableDeviceStore=connectableDeviceStore;
  allDevices=new ConcurrentHashMap<String,ConnectableDevice>(8,0.75f,2);
  compatibleDevices=new ConcurrentHashMap<String,ConnectableDevice>(8,0.75f,2);
  deviceClasses=new ConcurrentHashMap<String,Class<? extends DeviceService>>(4,0.75f,2);
  discoveryProviders=new CopyOnWriteArrayList<DiscoveryProvider>();
  discoveryListeners=new CopyOnWriteArrayList<DiscoveryManagerListener>();
  WifiManager wifiMgr=(WifiManager)context.getSystemService(Context.WIFI_SERVICE);
  multicastLock=wifiMgr.createMulticastLock("String_Node_Str");
  capabilityFilters=new ArrayList<CapabilityFilter>();
  pairingLevel=PairingLevel.OFF;
  receiver=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      String action=intent.getAction();
      if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
        NetworkInfo networkInfo=intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
switch (networkInfo.getState()) {
case CONNECTED:
          TimerTask task=new TimerTask(){
            @Override public void run(){
              if (mSearching) {
                for (                DiscoveryProvider provider : discoveryProviders) {
                  provider.start();
                }
              }
            }
          }
;
        Timer t=new Timer();
      t.schedule(task,2000);
    break;
case DISCONNECTED:
  Log.w("String_Node_Str","String_Node_Str");
for (DiscoveryProvider provider : discoveryProviders) {
  provider.reset();
}
allDevices.clear();
for (ConnectableDevice device : compatibleDevices.values()) {
handleDeviceLoss(device);
}
compatibleDevices.clear();
for (DiscoveryProvider provider : discoveryProviders) {
provider.stop();
}
break;
case CONNECTING:
break;
case DISCONNECTING:
break;
case SUSPENDED:
break;
case UNKNOWN:
break;
}
}
}
}
;
registerBroadcastReceiver();
}

Fixed version (ground truth):
/** 
 * Create a new instance of DiscoveryManager. Direct use of this constructor is not recommended. In most cases, you should use DiscoveryManager.getInstance() instead.
 */
public DiscoveryManager(Context context,ConnectableDeviceStore connectableDeviceStore){
  this.context=context;
  this.connectableDeviceStore=connectableDeviceStore;
  allDevices=new ConcurrentHashMap<String,ConnectableDevice>(8,0.75f,2);
  compatibleDevices=new ConcurrentHashMap<String,ConnectableDevice>(8,0.75f,2);
  deviceClasses=new ConcurrentHashMap<String,Class<? extends DeviceService>>(4,0.75f,2);
  discoveryProviders=new CopyOnWriteArrayList<DiscoveryProvider>();
  discoveryListeners=new CopyOnWriteArrayList<DiscoveryManagerListener>();
  WifiManager wifiMgr=(WifiManager)context.getSystemService(Context.WIFI_SERVICE);
  multicastLock=wifiMgr.createMulticastLock("String_Node_Str");
  multicastLock.setReferenceCounted(true);
  capabilityFilters=new ArrayList<CapabilityFilter>();
  pairingLevel=PairingLevel.OFF;
  receiver=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      String action=intent.getAction();
      if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
        NetworkInfo networkInfo=intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
switch (networkInfo.getState()) {
case CONNECTED:
          TimerTask task=new TimerTask(){
            @Override public void run(){
              if (mSearching) {
                for (                DiscoveryProvider provider : discoveryProviders) {
                  provider.start();
                }
              }
            }
          }
;
        Timer t=new Timer();
      t.schedule(task,2000);
    break;
case DISCONNECTED:
  Log.w("String_Node_Str","String_Node_Str");
for (DiscoveryProvider provider : discoveryProviders) {
  provider.reset();
}
allDevices.clear();
for (ConnectableDevice device : compatibleDevices.values()) {
handleDeviceLoss(device);
}
compatibleDevices.clear();
for (DiscoveryProvider provider : discoveryProviders) {
provider.stop();
}
break;
case CONNECTING:
break;
case DISCONNECTING:
break;
case SUSPENDED:
break;
case UNKNOWN:
break;
}
}
}
}
;
registerBroadcastReceiver();
}