Program: 165368
Project: 165368
Buggy source:
public void run(){
  if (((FDroidApp)getApplication()).inActivity != 0)   return;
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(getBaseContext());
  long lastUpdate=prefs.getLong("String_Node_Str",0);
  String sint=prefs.getString("String_Node_Str","String_Node_Str");
  int interval=Integer.parseInt(sint);
  if (interval == 0)   return;
  if (lastUpdate + (interval * 60 * 60) > System.currentTimeMillis())   return;
  DB db=null;
  try {
    db=new DB(getBaseContext());
    boolean notify=prefs.getBoolean("String_Node_Str",false);
    int prevUpdates=0;
    if (notify)     prevUpdates=db.getNumUpdates();
    boolean success=RepoXMLHandler.doUpdates(getBaseContext(),db);
    if (success && notify) {
      if (db.getNumUpdates() > prevUpdates) {
        NotificationManager n=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification=new Notification(R.drawable.icon,"String_Node_Str",System.currentTimeMillis());
        Context context=getApplicationContext();
        CharSequence contentTitle="String_Node_Str";
        CharSequence contentText="String_Node_Str";
        Intent notificationIntent=new Intent(UpdateService.this,FDroid.class);
        PendingIntent contentIntent=PendingIntent.getActivity(UpdateService.this,0,notificationIntent,0);
        notification.setLatestEventInfo(context,contentTitle,contentText,contentIntent);
        notification.flags|=Notification.FLAG_AUTO_CANCEL;
        n.notify(1,notification);
      }
    }
  }
 catch (  Exception e) {
    Log.e("String_Node_Str","String_Node_Str" + Log.getStackTraceString(e));
  }
 finally {
    if (db != null)     db.close();
    stopSelf();
  }
}

Fixed version (ground truth):
public void run(){
  if (((FDroidApp)getApplication()).inActivity != 0)   return;
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(getBaseContext());
  long lastUpdate=prefs.getLong("String_Node_Str",0);
  String sint=prefs.getString("String_Node_Str","String_Node_Str");
  int interval=Integer.parseInt(sint);
  if (interval == 0)   return;
  if (lastUpdate + (interval * 60 * 60) > System.currentTimeMillis())   return;
  DB db=null;
  try {
    db=new DB(getBaseContext());
    boolean notify=prefs.getBoolean("String_Node_Str",false);
    int prevUpdates=0;
    if (notify)     prevUpdates=db.getNumUpdates();
    boolean success=RepoXMLHandler.doUpdates(getBaseContext(),db);
    if (success && notify) {
      int newUpdates=db.getNumUpdates();
      Log.d("String_Node_Str","String_Node_Str" + prevUpdates + "String_Node_Str"+ newUpdates);
      if (newUpdates > prevUpdates) {
        NotificationManager n=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification=new Notification(R.drawable.icon,"String_Node_Str",System.currentTimeMillis());
        Context context=getApplicationContext();
        CharSequence contentTitle="String_Node_Str";
        CharSequence contentText="String_Node_Str";
        Intent notificationIntent=new Intent(UpdateService.this,FDroid.class);
        PendingIntent contentIntent=PendingIntent.getActivity(UpdateService.this,0,notificationIntent,0);
        notification.setLatestEventInfo(context,contentTitle,contentText,contentIntent);
        notification.flags|=Notification.FLAG_AUTO_CANCEL;
        n.notify(1,notification);
      }
    }
  }
 catch (  Exception e) {
    Log.e("String_Node_Str","String_Node_Str" + Log.getStackTraceString(e));
  }
 finally {
    if (db != null)     db.close();
    stopSelf();
  }
}