nus-yam/ex-repair huggingface dataset:
Program: 143879
Project: 143879
Buggy source:
/** 
 * Define el tipo de proveedor de URl que a ser utilizado. Si la persistencia esta activa se retorna un   {@link EntityURLProvider}que busca en la base de datos. En caso contrario retorna un  {@link JsonURLProvider}.
 * @return {@link WSInformationProvider}
 */
@Bean WSInformationProvider wsInformationProvider(){
  if (properties.getBoolean(KarakuPersistence.KARAKU_JPA_ENABLED,true)) {
    return new EntityURLProvider();
  }
 else {
    return new JsonURLProvider();
  }
}

Fixed version (ground truth):
/** 
 * Define el tipo de proveedor de URl que a ser utilizado. Si la persistencia esta activa se retorna un   {@link EntityURLProvider}que busca en la base de datos. En caso contrario retorna un  {@link JsonURLProvider}.
 * @return {@link WSInformationProvider}
 * @throws Exception
 */
@Bean WSInformationProvider wsInformationProvider() throws IOException {
  if (properties.getBoolean(KarakuPersistence.KARAKU_JPA_ENABLED,true)) {
    return new EntityURLProvider();
  }
 else {
    String url=properties.get("String_Node_Str","String_Node_Str");
    InputStream is;
    if (url.startsWith("String_Node_Str")) {
      is=new FileInputStream(url);
    }
 else {
      is=new ClassPathResource(properties.get("String_Node_Str","String_Node_Str")).getInputStream();
    }
    return new JsonURLProvider(is);
  }
}
Program: 143880
Project: 143880
Buggy source:
/** 
 * @param operation
 * @param dc
 * @return
 */
@SuppressWarnings("String_Node_Str") public <T>Operation redirect(Operation operation,Class<T> clazz,T dc){
  HashSet<Watcher<?>> watchers=getWatchers(clazz);
  for (  Watcher<?> watcher : watchers) {
    Watcher<T> wath=(Watcher<T>)watcher;
    Operation nOp=wath.redirect(operation,dc);
    if (nOp != operation) {
      return redirect(nOp,clazz,dc);
    }
  }
  return operation;
}

Fixed version (ground truth):
/** 
 * @param operation
 * @param dc
 * @return
 */
@SuppressWarnings("String_Node_Str") public <T>Operation redirect(Operation operation,Class<T> clazz,T dc){
  Set<Watcher<?>> watchers=getWatchers(clazz);
  for (  Watcher<?> watcher : watchers) {
    Watcher<T> wath=(Watcher<T>)watcher;
    Operation nOp=wath.redirect(operation,dc);
    if (!nOp.equals(operation)) {
      return redirect(nOp,clazz,dc);
    }
  }
  return operation;
}
Program: 143881
Project: 143881
Buggy source:
/** 
 * @param operation
 * @param dc
 * @return
 */
@SuppressWarnings("String_Node_Str") public <T>T process(Operation origin,Operation operation,Class<T> clazz,T dc){
  HashSet<Watcher<?>> watchers=getWatchers(clazz);
  T bean=dc;
  for (  Watcher<?> watcher : watchers) {
    Watcher<T> wath=(Watcher<T>)watcher;
    bean=wath.process(origin,operation,bean);
  }
  return bean;
}

Fixed version (ground truth):
/** 
 * @param operation
 * @param dc
 * @return
 */
@SuppressWarnings("String_Node_Str") public <T>T process(Operation origin,Operation operation,Class<T> clazz,T dc){
  Set<Watcher<?>> currentWatchers=getWatchers(clazz);
  T bean=dc;
  for (  Watcher<?> watcher : currentWatchers) {
    Watcher<T> wath=(Watcher<T>)watcher;
    bean=wath.process(origin,operation,bean);
  }
  return bean;
}
Program: 143882
Project: 143882
Buggy source:
/** 
 * @param clazz
 * @return
 */
private <T>HashSet<Watcher<?>> getWatchers(Class<T> clazz){
  HashSet<Watcher<?>> watchers=new HashSet<Watcher<?>>();
  for (  Entry<Class<?>,List<Watcher<?>>> entry : maps.entrySet()) {
    Class<?> oClazz=entry.getKey();
    if (oClazz.isAssignableFrom(clazz)) {
      watchers.addAll(entry.getValue());
    }
  }
  return watchers;
}

Fixed version (ground truth):
/** 
 * @param clazz
 * @return
 */
private <T>Set<Watcher<?>> getWatchers(Class<T> clazz){
  Set<Watcher<?>> currentWatchers=new HashSet<Watcher<?>>();
  for (  Entry<Class<?>,List<Watcher<?>>> entry : maps.entrySet()) {
    Class<?> oClazz=entry.getKey();
    if (oClazz.isAssignableFrom(clazz)) {
      currentWatchers.addAll(entry.getValue());
    }
  }
  return currentWatchers;
}
Program: 143883
Project: 143883
Buggy source:
@Override public List<Vehicle> list(int cusid) throws DataAccessException {
  logger.info("String_Node_Str");
  String sql="String_Node_Str";
  List<Vehicle> vhcList=jdbcTemplate.query(sql,new VehicleMapper());
  return vhcList;
}

Fixed version (ground truth):
@Override public List<Vehicle> list(int cusid) throws DataAccessException {
  logger.info("String_Node_Str");
  String sql="String_Node_Str";
  List<Vehicle> vhcList=jdbcTemplate.query(sql,new Object[]{cusid},new VehicleMapper());
  return vhcList;
}
Program: 143884
Project: 143884
Buggy source:
private void startAnimation(){
  ImageView centerWheel=(ImageView)findViewById(R.id.center_wheel);
  View infoView=findViewById(R.id.info);
  Animation rotation=AnimationUtils.loadAnimation(this,R.anim.rotation_start);
  centerWheel.startAnimation(rotation);
  Animation slideLeft=AnimationUtils.loadAnimation(this,R.anim.slide_in_left);
  button_logout.startAnimation(slideLeft);
  Animation slideRight=AnimationUtils.loadAnimation(this,R.anim.slide_in_right);
  button_web.startAnimation(slideRight);
  Animation slideTop=AnimationUtils.loadAnimation(this,R.anim.slide_in_top);
  infoView.startAnimation(slideTop);
  button_login.startAnimation(slideTop);
  Animation slideBottom=AnimationUtils.loadAnimation(this,R.anim.slide_in_bottom);
  Animation popBehind=AnimationUtils.loadAnimation(this,R.anim.pop_enter_behind);
  centerWheel.startAnimation(popBehind);
}

Fixed version (ground truth):
private void startAnimation(){
  ImageView centerWheel=(ImageView)findViewById(R.id.center_wheel);
  View infoView=findViewById(R.id.info);
  Animation rotation=AnimationUtils.loadAnimation(this,R.anim.rotation_start);
  centerWheel.startAnimation(rotation);
  Animation slideLeft=AnimationUtils.loadAnimation(this,R.anim.slide_in_left);
  button_logout.startAnimation(slideLeft);
  Animation slideRight=AnimationUtils.loadAnimation(this,R.anim.slide_in_right);
  button_web.startAnimation(slideRight);
  Animation slideTop=AnimationUtils.loadAnimation(this,R.anim.slide_in_top);
  infoView.startAnimation(slideTop);
  button_login.startAnimation(slideTop);
  Animation slideBottom=AnimationUtils.loadAnimation(this,R.anim.slide_in_bottom);
}
Program: 143885
Project: 143885
Buggy source:
public void add(LayoutInflater inflater){
  initialise(inflater);
  AlertDialog.Builder builder=new AlertDialog.Builder(this.context);
  builder.setView(v).setTitle("String_Node_Str").setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
      add_update=true;
      add_update(textbox_username.getText().toString(),textbox_password.getText().toString());
    }
  }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
      Toast.makeText(context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    }
  }
);
  builder.create().show();
}

Fixed version (ground truth):
public void add(LayoutInflater inflater){
  initialise(inflater);
  AlertDialog.Builder builder=new AlertDialog.Builder(this.context);
  builder.setView(v).setTitle("String_Node_Str").setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
    }
  }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
      Toast.makeText(context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    }
  }
);
  final AlertDialog dialog=builder.create();
  dialog.show();
  dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      add_update=true;
      if (add_update(textbox_username.getText().toString(),textbox_password.getText().toString())) {
        dialog.dismiss();
      }
    }
  }
);
}
Program: 143886
Project: 143886
Buggy source:
public void add_update(String un,String pwd){
  if (un.trim().isEmpty()) {
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_LONG).show();
    return;
  }
  if (pwd.trim().isEmpty()) {
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_LONG).show();
    return;
  }
  UserStructure userStructure=new UserStructure();
  userStructure.setUsername(un);
  userStructure.setPassword(pwd);
  if (add_update) {
    saveCredential(userStructure);
  }
 else {
    updateCredentials(userStructure);
  }
}

Fixed version (ground truth):
public boolean add_update(String un,String pwd){
  if (un.trim().isEmpty()) {
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_LONG).show();
    return false;
  }
  if (pwd.trim().isEmpty()) {
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_LONG).show();
    return false;
  }
  UserStructure userStructure=new UserStructure();
  userStructure.setUsername(un);
  userStructure.setPassword(pwd);
  if (add_update) {
    return saveCredential(userStructure);
  }
 else {
    return updateCredentials(userStructure);
  }
}
Program: 143887
Project: 143887
Buggy source:
public void updateCredentials(UserStructure userStructure){
  int i=databaseEngine.updateUser(userStructure,username);
  if (i == 1) {
    Log.e("String_Node_Str","String_Node_Str");
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_SHORT).show();
  }
 else   if (i == 0) {
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    Log.e("String_Node_Str","String_Node_Str");
  }
 else {
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    Log.e("String_Node_Str","String_Node_Str");
  }
}

Fixed version (ground truth):
public boolean updateCredentials(UserStructure userStructure){
  int i=databaseEngine.updateUser(userStructure,username);
  if (i == 1) {
    Log.e("String_Node_Str","String_Node_Str");
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    return true;
  }
 else   if (i == 0) {
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    Log.e("String_Node_Str","String_Node_Str");
    return false;
  }
 else {
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    Log.e("String_Node_Str","String_Node_Str");
    return true;
  }
}
Program: 143888
Project: 143888
Buggy source:
public void update(String un,LayoutInflater inflater){
  this.username=un;
  initialise(inflater);
  textbox_username.setText(un);
  UserStructure us=databaseEngine.getUsernamePassword(un);
  textbox_password.setText(us.getPassword());
  AlertDialog.Builder builder=new AlertDialog.Builder(this.context);
  builder.setView(v).setTitle("String_Node_Str").setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
      add_update=false;
      add_update(textbox_username.getText().toString(),textbox_password.getText().toString());
    }
  }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
      Toast.makeText(context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    }
  }
);
  builder.create().show();
}

Fixed version (ground truth):
public void update(String un,LayoutInflater inflater){
  this.username=un;
  initialise(inflater);
  textbox_username.setText(un);
  UserStructure us=databaseEngine.getUsernamePassword(un);
  textbox_password.setText(us.getPassword());
  AlertDialog.Builder builder=new AlertDialog.Builder(this.context);
  builder.setView(v).setTitle("String_Node_Str").setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
    }
  }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
      Toast.makeText(context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    }
  }
);
  final AlertDialog dialog=builder.create();
  dialog.show();
  dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      add_update=false;
      if (add_update(textbox_username.getText().toString(),textbox_password.getText().toString())) {
        dialog.dismiss();
      }
    }
  }
);
}
Program: 143889
Project: 143889
Buggy source:
void saveCredential(UserStructure userStructure){
  if (!databaseEngine.existsUser(userStructure.getUsername())) {
    if (databaseEngine.insert(userStructure)) {
      Toast.makeText(this.context,userStructure.getUsername() + "String_Node_Str",Toast.LENGTH_SHORT).show();
    }
 else {
      Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    }
  }
 else {
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_SHORT).show();
  }
}

Fixed version (ground truth):
boolean saveCredential(UserStructure userStructure){
  if (!databaseEngine.existsUser(userStructure.getUsername())) {
    if (databaseEngine.insert(userStructure)) {
      Toast.makeText(this.context,userStructure.getUsername() + "String_Node_Str",Toast.LENGTH_SHORT).show();
      return true;
    }
 else {
      Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_SHORT).show();
      return false;
    }
  }
 else {
    Toast.makeText(this.context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    return false;
  }
}
Program: 143891
Project: 143891
Buggy source:
void login(){
  NetworkEngine.StatusCode status=null;
  Log.d("String_Node_Str","String_Node_Str");
  String username, password;
  username=getSelectedUsername();
  password=databaseEngine.getUsernamePassword(username).getPassword();
  if (password.isEmpty()) {
    Toast.makeText(this,"String_Node_Str" + username,Toast.LENGTH_SHORT).show();
    return;
  }
  try {
    status=networkEngine.login(username,password);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
void login(){
  if (databaseEngine.isUserListEmpty()) {
    Toast.makeText(MainActivity.this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    return;
  }
  NetworkEngine.StatusCode status=null;
  Log.d("String_Node_Str","String_Node_Str");
  String username, password;
  username=getSelectedUsername();
  password=databaseEngine.getUsernamePassword(username).getPassword();
  if (password.isEmpty()) {
    Toast.makeText(this,"String_Node_Str" + username,Toast.LENGTH_SHORT).show();
    return;
  }
  try {
    status=networkEngine.login(username,password);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 143892
Project: 143892
Buggy source:
@Override public void onClick(View view){
  delete_user();
}

Fixed version (ground truth):
@Override public void onClick(DialogInterface dialogInterface,int i){
  Toast.makeText(getApplicationContext(),"String_Node_Str",Toast.LENGTH_SHORT).show();
}
Program: 143893
Project: 143893
Buggy source:
public void onClickNegative(){
  Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
  if (add_update) {
    this.finish();
  }
 else {
    dialogAlert.dismiss();
  }
}

Fixed version (ground truth):
public void onClickNegative(){
  Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
  dialogAlert.dismiss();
}
Program: 143894
Project: 143894
Buggy source:
public void onClickPositive(String local_username,String password){
  if (username.isEmpty()) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
    return;
  }
  UserStructure userStructure=new UserStructure();
  userStructure.setUsername(local_username);
  userStructure.setPassword(password);
  if (add_update) {
    saveCredential(userStructure);
  }
 else {
    updateCredentials(userStructure);
  }
  dialogAlert.dismiss();
}

Fixed version (ground truth):
public void onClickPositive(String local_username,String password){
  if (local_username.isEmpty()) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
    return;
  }
  if (password.isEmpty()) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
    return;
  }
  UserStructure userStructure=new UserStructure();
  userStructure.setUsername(local_username);
  userStructure.setPassword(password);
  if (add_update) {
    saveCredential(userStructure);
  }
 else {
    updateCredentials(userStructure);
  }
  dialogAlert.dismiss();
}
Program: 143895
Project: 143895
Buggy source:
public void updateCredentials(UserStructure userStructure){
  int i=databaseEngine.updateUser(userStructure,username);
  Boolean flag=false;
  if (i == 1) {
    Log.e("String_Node_Str","String_Node_Str");
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    flag=true;
  }
 else   if (i == 0) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    Log.e("String_Node_Str","String_Node_Str");
  }
 else {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    Log.e("String_Node_Str","String_Node_Str");
    flag=true;
  }
}

Fixed version (ground truth):
public void updateCredentials(UserStructure userStructure){
  int i=databaseEngine.updateUser(userStructure,username);
  if (i == 1) {
    Log.e("String_Node_Str","String_Node_Str");
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
  }
 else   if (i == 0) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    Log.e("String_Node_Str","String_Node_Str");
  }
 else {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    Log.e("String_Node_Str","String_Node_Str");
  }
}
Program: 143896
Project: 143896
Buggy source:
public void delete_user(){
  Intent intent=new Intent(this,DeleteUser.class);
  startActivity(intent);
}

Fixed version (ground truth):
public void delete_user(){
  showDeleteDialog("String_Node_Str","String_Node_Str" + username,"String_Node_Str","String_Node_Str").show();
}
Program: 143897
Project: 143897
Buggy source:
String getPassword(){
  String password=null;
  try {
    database=myDatabaseHelper.getReadableDatabase();
    String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
    System.out.println("String_Node_Str");
    cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
    int indexUsername=cursor.getColumnIndex("String_Node_Str");
    cursor.moveToLast();
    password=cursor.getString(1);
    database.close();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  return password;
}

Fixed version (ground truth):
String getPassword(){
  String password=null;
  try {
    database=myDatabaseHelper.getReadableDatabase();
    String[] columns=new String[]{dbhelper.USERNAME,dbhelper.PASSWORD};
    cursor=database.query(dbhelper.TABLE,columns,null,null,null,null,null);
    int indexPassword=cursor.getColumnIndex(dbhelper.PASSWORD);
    cursor.moveToLast();
    password=cursor.getString(indexPassword);
    database.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return password;
}
Program: 143898
Project: 143898
Buggy source:
void saveToDatabase(String username,String password){
  try {
    Log.d("String_Node_Str","String_Node_Str" + username + "String_Node_Str"+ password+ "String_Node_Str");
    database=myDatabaseHelper.getWritableDatabase();
    ContentValues values=new ContentValues();
    if (username != null && password != null) {
      values.put(dbhelper.USERNAME,username);
      values.put(dbhelper.PASSWORD,password);
      database.insert(dbhelper.TABLE,null,values);
      String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
      cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
      Log.v("String_Node_Str",DatabaseUtils.dumpCursorToString(cursor));
      Log.d("String_Node_Str","String_Node_Str");
      database.close();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
void saveToDatabase(String username,String password){
  try {
    Log.d("String_Node_Str","String_Node_Str" + username + "String_Node_Str"+ password+ "String_Node_Str");
    database=myDatabaseHelper.getWritableDatabase();
    ContentValues values=new ContentValues();
    if (username != null && password != null) {
      values.put(dbhelper.USERNAME,username);
      values.put(dbhelper.PASSWORD,password);
      database.insert(dbhelper.TABLE,null,values);
      String[] columns=new String[]{dbhelper.USERNAME,dbhelper.PASSWORD};
      cursor=database.query(dbhelper.TABLE,columns,null,null,null,null,null);
      Log.v("String_Node_Str","String_Node_Str" + DatabaseUtils.dumpCursorToString(cursor));
      Log.d("String_Node_Str","String_Node_Str");
      database.close();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 143899
Project: 143899
Buggy source:
String getUsername(){
  String username=null;
  try {
    database=myDatabaseHelper.getReadableDatabase();
    String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
    cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
    int indexUsername=cursor.getColumnIndex("String_Node_Str");
    cursor.moveToLast();
    username=cursor.getString(0);
    database.close();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  return username;
}

Fixed version (ground truth):
String getUsername(){
  String username=null;
  try {
    database=myDatabaseHelper.getReadableDatabase();
    String[] columns=new String[]{dbhelper.USERNAME,dbhelper.PASSWORD};
    cursor=database.query(dbhelper.TABLE,columns,null,null,null,null,null);
    int indexUsername=cursor.getColumnIndex(dbhelper.USERNAME);
    cursor.moveToLast();
    username=cursor.getString(indexUsername);
    database.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return username;
}
Program: 143900
Project: 143900
Buggy source:
String getPassword(){
  String password=null;
  try {
    database=DBHELPER.getReadableDatabase();
    String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
    System.out.println("String_Node_Str");
    cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
    int indexUsername=cursor.getColumnIndex("String_Node_Str");
    cursor.moveToLast();
    password=cursor.getString(1);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  database.close();
  return password;
}

Fixed version (ground truth):
String getPassword(){
  String password=null;
  try {
    database=myDatabaseHelper.getReadableDatabase();
    String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
    System.out.println("String_Node_Str");
    cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
    int indexUsername=cursor.getColumnIndex("String_Node_Str");
    cursor.moveToLast();
    password=cursor.getString(1);
    database.close();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  return password;
}
Program: 143901
Project: 143901
Buggy source:
void saveToDatabase(String username,String password){
  try {
    System.out.print("String_Node_Str");
    System.out.print("String_Node_Str");
    database=DBHELPER.getWritableDatabase();
    ContentValues values=new ContentValues();
    if (username != null && password != null) {
      values.put(dbhelper.USERNAME,username);
      values.put(dbhelper.PASSWORD,password);
      database.insert(dbhelper.TABLE,null,values);
      String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
      cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
      Log.v("String_Node_Str",DatabaseUtils.dumpCursorToString(cursor));
      Log.d("String_Node_Str","String_Node_Str");
    }
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
  }
  database.close();
}

Fixed version (ground truth):
void saveToDatabase(String username,String password){
  try {
    Log.d("String_Node_Str","String_Node_Str" + username + "String_Node_Str"+ password+ "String_Node_Str");
    database=myDatabaseHelper.getWritableDatabase();
    ContentValues values=new ContentValues();
    if (username != null && password != null) {
      values.put(dbhelper.USERNAME,username);
      values.put(dbhelper.PASSWORD,password);
      database.insert(dbhelper.TABLE,null,values);
      String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
      cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
      Log.v("String_Node_Str",DatabaseUtils.dumpCursorToString(cursor));
      Log.d("String_Node_Str","String_Node_Str");
      database.close();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 143902
Project: 143902
Buggy source:
String getUsername(){
  String username=null;
  try {
    database=DBHELPER.getReadableDatabase();
    String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
    cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
    int indexUsername=cursor.getColumnIndex("String_Node_Str");
    cursor.moveToLast();
    username=cursor.getString(0);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  database.close();
  return username;
}

Fixed version (ground truth):
String getUsername(){
  String username=null;
  try {
    database=myDatabaseHelper.getReadableDatabase();
    String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
    cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
    int indexUsername=cursor.getColumnIndex("String_Node_Str");
    cursor.moveToLast();
    username=cursor.getString(0);
    database.close();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  return username;
}
Program: 143903
Project: 143903
Buggy source:
String getUsername(){
  String username=null;
  try {
    database=DBHELPER.getReadableDatabase();
    String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
    cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
    int indexUsername=cursor.getColumnIndex("String_Node_Str");
    cursor.moveToFirst();
    username=cursor.getString(indexUsername);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
  }
  database.close();
  return username;
}

Fixed version (ground truth):
String getUsername(){
  String username=null;
  try {
    database=DBHELPER.getReadableDatabase();
    String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
    cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
    int indexUsername=cursor.getColumnIndex("String_Node_Str");
    cursor.moveToLast();
    username=cursor.getString(0);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  database.close();
  return username;
}
Program: 143904
Project: 143904
Buggy source:
public void login_runner(String username,String password) throws Exception {
  System.out.println("String_Node_Str");
  if (username == null || password == null) {
    Log.wtf("String_Node_Str","String_Node_Str");
    return;
  }
  String urlParameters="String_Node_Str" + username + "String_Node_Str"+ password;
  String request="String_Node_Str";
  URL puServerUrl=new URL(request);
  URLConnection puServerConnection=puServerUrl.openConnection();
  puServerConnection.setDoOutput(true);
  OutputStreamWriter writer=new OutputStreamWriter(puServerConnection.getOutputStream());
  writer.write(urlParameters);
  writer.flush();
  String line;
  BufferedReader reader=new BufferedReader(new InputStreamReader(puServerConnection.getInputStream()));
  while ((line=reader.readLine()) != null) {
    Log.w("String_Node_Str",line);
  }
  writer.close();
  reader.close();
}

Fixed version (ground truth):
public void login_runner(String username,String password) throws Exception {
  if (username == null || password == null) {
    Log.wtf("String_Node_Str","String_Node_Str");
    return;
  }
  System.out.println("String_Node_Str" + username + password);
  String urlParameters="String_Node_Str" + username + "String_Node_Str"+ password;
  String request="String_Node_Str";
  URL puServerUrl=new URL(request);
  URLConnection puServerConnection=puServerUrl.openConnection();
  puServerConnection.setDoOutput(true);
  OutputStreamWriter writer=new OutputStreamWriter(puServerConnection.getOutputStream());
  writer.write(urlParameters);
  writer.flush();
  String line;
  BufferedReader reader=new BufferedReader(new InputStreamReader(puServerConnection.getInputStream()));
  while ((line=reader.readLine()) != null) {
    Log.w("String_Node_Str",line);
  }
  writer.close();
  reader.close();
}
Program: 143905
Project: 143905
Buggy source:
String getPassword(){
  String password=null;
  try {
    database=DBHELPER.getReadableDatabase();
    String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
    cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
    int indexUsername=cursor.getColumnIndex("String_Node_Str");
    cursor.moveToFirst();
    password=cursor.getString(indexUsername);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
  }
  database.close();
  return password;
}

Fixed version (ground truth):
String getPassword(){
  String password=null;
  try {
    database=DBHELPER.getReadableDatabase();
    String[] columns=new String[]{"String_Node_Str","String_Node_Str"};
    System.out.println("String_Node_Str");
    cursor=database.query("String_Node_Str",columns,null,null,null,null,null);
    int indexUsername=cursor.getColumnIndex("String_Node_Str");
    cursor.moveToLast();
    password=cursor.getString(1);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  database.close();
  return password;
}
Program: 143908
Project: 143908
Buggy source:
/** 
 * Handle an incoming IAC SB &lt;type&gt; &lt;bytes&gt; IAC SE
 * @param type type of SB
 * @param sbata byte array as &lt;bytes&gt;
 * @param sbcount nr of bytes. may be 0 too.
 */
private void handle_sb(byte type,byte[] sbdata,int sbcount) throws IOException {
  if (debug > 1)   System.err.println("String_Node_Str" + type + "String_Node_Str");
switch (type) {
case TELOPT_TTYPE:
    if (sbcount > 0 && sbdata[0] == TELQUAL_SEND) {
      write(IACSB);
      write(TELOPT_TTYPE);
      write(TELQUAL_IS);
      String ttype=getTerminalType();
      if (ttype == null)       ttype="String_Node_Str";
      write(ttype.getBytes());
      write(IACSE);
    }
}
}

Fixed version (ground truth):
/** 
 * Handle an incoming IAC SB &lt;type&gt; &lt;bytes&gt; IAC SE
 * @param type type of SB
 * @param sbata byte array as &lt;bytes&gt;
 */
private void handle_sb(byte type,byte[] sbdata) throws IOException {
  if (debug > 1)   System.err.println("String_Node_Str" + type + "String_Node_Str");
switch (type) {
case TELOPT_TTYPE:
    if (sbdata.length > 0 && sbdata[0] == TELQUAL_SEND) {
      write(IACSB);
      write(TELOPT_TTYPE);
      write(TELQUAL_IS);
      String ttype=getTerminalType();
      if (ttype == null)       ttype="String_Node_Str";
      write(ttype.getBytes());
      write(IACSE);
    }
}
}
Program: 143911
Project: 143911
Buggy source:
public void actionPerformed(ActionEvent e){
  String urlID=e.getActionCommand();
  URL url=(URL)remoteUrlList.get(urlID);
  if (debug > 0)   System.err.println("String_Node_Str" + urlID + "String_Node_Str"+ remoteUrlList.get(urlID));
  try {
    URLConnection urlConnection=url.openConnection();
    DataOutputStream out;
    DataInputStream in;
    urlConnection.setDoInput(true);
    urlConnection.setDoOutput(true);
    urlConnection.setUseCaches(false);
    urlConnection.setRequestProperty("String_Node_Str","String_Node_Str");
    out=new DataOutputStream(urlConnection.getOutputStream());
    String content=(String)remoteUrlList.get(urlID + "String_Node_Str");
    content=(content == null ? "String_Node_Str" : content + "String_Node_Str") + "String_Node_Str" + URLEncoder.encode(textArea.getText());
    if (debug > 0)     System.err.println("String_Node_Str" + content);
    out.writeBytes(content);
    out.flush();
    out.close();
    if (debug > 0)     System.err.println("String_Node_Str");
    in=new DataInputStream(urlConnection.getInputStream());
    String str;
    while (null != ((str=in.readLine()))) {
      System.out.println("String_Node_Str" + str);
    }
    in.close();
  }
 catch (  IOException ioe) {
    dialog.setVisible(true);
    System.err.println("String_Node_Str" + url);
    ioe.printStackTrace();
  }
  if (debug > 0)   System.err.println("String_Node_Str" + url);
}

Fixed version (ground truth):
public void actionPerformed(ActionEvent e){
  String urlID=e.getActionCommand();
  if (debug > 0)   System.err.println("String_Node_Str" + urlID + "String_Node_Str"+ remoteUrlList.get(urlID));
  saveFile(urlID);
}
Program: 143912
Project: 143912
Buggy source:
public void setConfiguration(PluginConfig config){
  String tmp;
  int i=1;
  while ((tmp=config.getProperty("String_Node_Str",id,i + "String_Node_Str")) != null) {
    try {
      String urlID="String_Node_Str" + i;
      URL remoteURL=new URL(tmp);
      remoteUrlList.put(urlID,remoteURL);
      if ((tmp=config.getProperty("String_Node_Str",id,i + "String_Node_Str")) != null) {
        remoteUrlList.put(urlID + "String_Node_Str",tmp);
      }
      if ((tmp=config.getProperty("String_Node_Str",id,i + "String_Node_Str")) != null) {
        save=new MenuItem("String_Node_Str" + tmp);
      }
 else {
        save=new MenuItem("String_Node_Str" + remoteURL.toString());
      }
      save.setEnabled(true);
      save.addActionListener(Capture.this);
      save.setActionCommand(urlID);
      menu.add(save);
      i++;
    }
 catch (    MalformedURLException e) {
      System.err.println("String_Node_Str" + e);
    }
  }
}

Fixed version (ground truth):
public void setConfiguration(PluginConfig config){
  String tmp;
  MenuItem save=new MenuItem("String_Node_Str");
  menu.add(save);
  if ((tmp=config.getProperty("String_Node_Str",id,"String_Node_Str")) != null) {
    try {
      remoteUrlList.put("String_Node_Str",new URL(tmp));
      if ((tmp=config.getProperty("String_Node_Str",id,"String_Node_Str")) != null) {
        remoteUrlList.put("String_Node_Str",tmp);
      }
      save.addActionListener(new ActionListener(){
        public void actionPerformed(        ActionEvent e){
          fileDialog.setVisible(true);
        }
      }
);
      save.addActionListener(Capture.this);
      save.setActionCommand("String_Node_Str");
    }
 catch (    MalformedURLException e) {
      System.err.println("String_Node_Str" + e);
    }
  }
 else {
    save.setEnabled(false);
  }
  int i=1;
  while ((tmp=config.getProperty("String_Node_Str",id,i + "String_Node_Str")) != null) {
    try {
      String urlID="String_Node_Str" + i;
      URL remoteURL=new URL(tmp);
      remoteUrlList.put(urlID,remoteURL);
      if ((tmp=config.getProperty("String_Node_Str",id,i + "String_Node_Str")) != null) {
        remoteUrlList.put(urlID + "String_Node_Str",tmp);
      }
      if ((tmp=config.getProperty("String_Node_Str",id,i + "String_Node_Str")) != null) {
        save=new MenuItem("String_Node_Str" + tmp);
      }
 else {
        save=new MenuItem("String_Node_Str" + remoteURL.toString());
      }
      save.setEnabled(true);
      save.addActionListener(Capture.this);
      save.setActionCommand(urlID);
      menu.add(save);
      i++;
    }
 catch (    MalformedURLException e) {
      System.err.println("String_Node_Str" + e);
    }
  }
}
Program: 143917
Project: 143917
Buggy source:
public void mouseDragged(MouseEvent evt){
  if (buttonCheck(evt.getModifiers(),MouseEvent.BUTTON1_MASK)) {
    int xoffset=(super.getSize().width - size.width * charWidth) / 2;
    int yoffset=(super.getSize().height - size.height * charHeight) / 2;
    int x=(evt.getX() - xoffset) / charWidth;
    int y=(evt.getY() - yoffset) / charHeight + windowBase;
    int oldx=selectEnd.x, oldy=selectEnd.y;
    if ((x <= selectBegin.x && y <= selectBegin.y)) {
      selectBegin.x=x;
      selectBegin.y=y;
    }
 else {
      selectEnd.x=x;
      selectEnd.y=y;
    }
    if (oldx != x || oldy != y) {
      update[0]=true;
      if (debug > 0)       System.err.println("String_Node_Str" + selectBegin.x + "String_Node_Str"+ selectBegin.y+ "String_Node_Str"+ "String_Node_Str"+ selectEnd.x+ "String_Node_Str"+ selectEnd.y+ "String_Node_Str");
      redraw();
    }
  }
}

Fixed version (ground truth):
public void mouseDragged(MouseEvent evt){
  if (buttonCheck(evt.getModifiers(),MouseEvent.BUTTON1_MASK) || evt.getModifiers() == 0) {
    int xoffset=(super.getSize().width - size.width * charWidth) / 2;
    int yoffset=(super.getSize().height - size.height * charHeight) / 2;
    int x=(evt.getX() - xoffset) / charWidth;
    int y=(evt.getY() - yoffset) / charHeight + windowBase;
    int oldx=selectEnd.x, oldy=selectEnd.y;
    if ((x <= selectBegin.x && y <= selectBegin.y)) {
      selectBegin.x=x;
      selectBegin.y=y;
    }
 else {
      selectEnd.x=x;
      selectEnd.y=y;
    }
    if (oldx != x || oldy != y) {
      update[0]=true;
      if (debug > 0)       System.err.println("String_Node_Str" + selectBegin.x + "String_Node_Str"+ selectBegin.y+ "String_Node_Str"+ "String_Node_Str"+ selectEnd.x+ "String_Node_Str"+ selectEnd.y+ "String_Node_Str");
      redraw();
    }
  }
}
Program: 143920
Project: 143920
Buggy source:
private SshPacket handleBytes(byte buff[],int offset,int count) throws IOException {
  if (debug > 1)   System.out.println("String_Node_Str" + buff + "String_Node_Str"+ count+ "String_Node_Str");
  byte b;
  int boffset=offset;
  while (boffset < count) {
    b=buff[boffset++];
switch (phase) {
case PHASE_INIT:
      identification_string+=(char)b;
    if (b == '\n') {
      phase++;
      write(identification_string_sent.getBytes());
      position=0;
      byte[] data=SshMisc.createString(identification_string_sent);
      byte packet_type=SSH_SMSG_STDOUT_DATA;
      SshPacket fistLine=createPacket(packet_type,data);
      return fistLine;
    }
  break;
case PHASE_SSH_RECEIVE_PACKET:
SshPacket result=lastPacketReceived.getPacketfromBytes(buff,boffset - 1,count,encryption,crypto);
return result;
}
}
return null;
}

Fixed version (ground truth):
private SshPacket handleBytes(byte buff[],int offset,int count) throws IOException {
  if (debug > 1)   System.out.println("String_Node_Str" + buff + "String_Node_Str"+ count+ "String_Node_Str");
  byte b;
  int boffset=offset;
  while (boffset < count) {
    b=buff[boffset++];
switch (phase) {
case PHASE_INIT:
      identification_string+=(char)b;
    if (b == '\n') {
      phase++;
      write(identification_string_sent.getBytes());
      position=0;
      byte[] data=SshMisc.createString(identification_string);
      byte packet_type=SSH_SMSG_STDOUT_DATA;
      SshPacket firstLine=createPacket(packet_type,data);
      return firstLine;
    }
  break;
case PHASE_SSH_RECEIVE_PACKET:
SshPacket result=lastPacketReceived.getPacketfromBytes(buff,boffset - 1,count,encryption,crypto);
return result;
}
}
return null;
}
Program: 143921
Project: 143921
Buggy source:
/** 
 * Get the attributes for the specified position.
 * @param c x-coordinate (column)
 * @param l y-coordinate (line)
 * @see #putChar
 */
public int getAttributes(int c,int l){
  c=checkBounds(c,0,size.width - 1);
  l=checkBounds(l,0,size.height - 1);
  return charAttributes[l][c];
}

Fixed version (ground truth):
/** 
 * Get the attributes for the specified position.
 * @param c x-coordinate (column)
 * @param l y-coordinate (line)
 * @see #putChar
 */
public int getAttributes(int c,int l){
  c=checkBounds(c,0,size.width - 1);
  l=checkBounds(l,0,size.height - 1);
  return charAttributes[screenBase + l][c];
}
Program: 143922
Project: 143922
Buggy source:
/** 
 * Get the character at the specified position.
 * @param c x-coordinate (column)
 * @param l y-coordinate (line)
 * @see #putChar
 */
public char getChar(int c,int l){
  c=checkBounds(c,0,size.width - 1);
  l=checkBounds(l,0,size.height - 1);
  return charArray[l][c];
}

Fixed version (ground truth):
/** 
 * Get the character at the specified position.
 * @param c x-coordinate (column)
 * @param l y-coordinate (line)
 * @see #putChar
 */
public char getChar(int c,int l){
  c=checkBounds(c,0,size.width - 1);
  l=checkBounds(l,0,size.height - 1);
  return charArray[screenBase + l][c];
}
Program: 143923
Project: 143923
Buggy source:
public void disconnect(){
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
public void disconnect(){
  System.err.println("String_Node_Str");
  login="String_Node_Str";
  password="String_Node_Str";
  phase=0;
  encryption=false;
  lastPacketReceived=null;
}
Program: 143925
Project: 143925
Buggy source:
/** 
 * Initialise SshIO
 */
public SshIO(){
  SshPacket.encryption=encryption=false;
}

Fixed version (ground truth):
/** 
 * Initialise SshIO
 */
public SshIO(){
  encryption=false;
}
Program: 143927
Project: 143927
Buggy source:
private SshPacket handleBytes(byte buff[],int offset,int count) throws IOException {
  if (debug > 1)   System.out.println("String_Node_Str" + buff + "String_Node_Str"+ count+ "String_Node_Str");
  byte b;
  int boffset=offset;
  while (boffset < count) {
    b=buff[boffset++];
switch (phase) {
case PHASE_INIT:
      identification_string+=(char)b;
    if (b == '\n') {
      phase++;
      write(identification_string_sent.getBytes());
      position=0;
      byte[] data=SshMisc.createString(identification_string_sent);
      byte packet_type=SSH_SMSG_STDOUT_DATA;
      SshPacket fistLine=createPacket(packet_type,data);
      return fistLine;
    }
  break;
case PHASE_SSH_RECEIVE_PACKET:
SshPacket result=lastPacketReceived.getPacketfromBytes(buff,boffset - 1,count);
return result;
}
}
return null;
}

Fixed version (ground truth):
private SshPacket handleBytes(byte buff[],int offset,int count) throws IOException {
  if (debug > 1)   System.out.println("String_Node_Str" + buff + "String_Node_Str"+ count+ "String_Node_Str");
  byte b;
  int boffset=offset;
  while (boffset < count) {
    b=buff[boffset++];
switch (phase) {
case PHASE_INIT:
      identification_string+=(char)b;
    if (b == '\n') {
      phase++;
      write(identification_string_sent.getBytes());
      position=0;
      byte[] data=SshMisc.createString(identification_string_sent);
      byte packet_type=SSH_SMSG_STDOUT_DATA;
      SshPacket fistLine=createPacket(packet_type,data);
      return fistLine;
    }
  break;
case PHASE_SSH_RECEIVE_PACKET:
SshPacket result=lastPacketReceived.getPacketfromBytes(buff,boffset - 1,count,encryption,crypto);
return result;
}
}
return null;
}
Program: 143928
Project: 143928
Buggy source:
private SshPacket createPacket(byte newType,byte[] newData) throws IOException {
  return new SshPacket(newType,newData);
}

Fixed version (ground truth):
private SshPacket createPacket(byte newType,byte[] newData) throws IOException {
  return new SshPacket(newType,newData,encryption,crypto);
}
Program: 143929
Project: 143929
Buggy source:
public SshPacket getPacketfromBytes(byte buff[],int offset,int count) throws IOException {
  int boffset=offset;
  byte b;
  while (boffset < count) {
    b=buff[boffset++];
switch (phase_packet) {
case PHASE_packet_length:
      packet_length_array[position]=b;
    if (++position >= 4) {
      packet_length=(packet_length_array[3] & 0xff) + ((packet_length_array[2] & 0xff) << 8) + ((packet_length_array[1] & 0xff) << 16)+ ((packet_length_array[0] & 0xff) << 24);
      position=0;
      phase_packet++;
    }
  break;
case PHASE_block:
if (position == 0) {
  int lengthBlock=8 * (packet_length / 8 + 1);
  block=new byte[lengthBlock];
}
block[position]=b;
if (++position >= block.length) {
if (count > boffset) {
toBeFinished=true;
unfinishedBuffer=buff;
positionInUnfinishedBuffer=boffset;
}
 else toBeFinished=false;
position=0;
phase_packet=PHASE_packet_length;
if (encryption) crypto.decrypt(block);
decryptedBlock=block;
setPacketFromDecryptedBlock();
if (!checkCrc()) {
System.err.println("String_Node_Str");
return null;
}
return this;
}
break;
}
}
toBeFinished=false;
return null;
}

Fixed version (ground truth):
public SshPacket getPacketfromBytes(byte buff[],int offset,int count,boolean encryption,SshCrypto crypto) throws IOException {
  int boffset=offset;
  byte b;
  while (boffset < count) {
    b=buff[boffset++];
switch (phase_packet) {
case PHASE_packet_length:
      packet_length_array[position]=b;
    if (++position >= 4) {
      packet_length=(packet_length_array[3] & 0xff) + ((packet_length_array[2] & 0xff) << 8) + ((packet_length_array[1] & 0xff) << 16)+ ((packet_length_array[0] & 0xff) << 24);
      position=0;
      phase_packet++;
    }
  break;
case PHASE_block:
if (position == 0) {
  int lengthBlock=8 * (packet_length / 8 + 1);
  block=new byte[lengthBlock];
}
block[position]=b;
if (++position >= block.length) {
if (count > boffset) {
toBeFinished=true;
unfinishedBuffer=buff;
positionInUnfinishedBuffer=boffset;
}
 else toBeFinished=false;
position=0;
phase_packet=PHASE_packet_length;
if (encryption) crypto.decrypt(block);
decryptedBlock=block;
setPacketFromDecryptedBlock();
if (!checkCrc()) {
System.err.println("String_Node_Str");
return null;
}
return this;
}
break;
}
}
toBeFinished=false;
return null;
}
Program: 143930
Project: 143930
Buggy source:
public SshPacket(byte newType,byte[] newData) throws IOException {
  data=newData;
  packet_type=newType;
  if (data != null)   packet_length=data.length + 5;
 else   packet_length=5;
  packet_length_array[3]=(byte)(packet_length & 0xff);
  packet_length_array[2]=(byte)((packet_length >> 8) & 0xff);
  packet_length_array[1]=(byte)((packet_length >> 16) & 0xff);
  packet_length_array[0]=(byte)((packet_length >> 24) & 0xff);
  padding=new byte[(8 - (packet_length % 8))];
  if (!encryption)   for (int i=0; i < padding.length; i++)   padding[i]=0;
 else {
    for (int i=0; i < padding.length; i++)     padding[i]=SshMisc.getNotZeroRandomByte();
  }
  byte[] tempByte=new byte[packet_length + padding.length - 4];
  int offset=0;
  for (int i=0; i < padding.length; i++)   tempByte[offset++]=padding[i];
  tempByte[offset++]=packet_type;
  if (packet_length > 5)   for (int i=0; i < data.length; i++)   tempByte[offset++]=data[i];
  long crc=0;
  crc=SshMisc.crc32(tempByte,tempByte.length);
  crc_array[3]=(byte)(crc & 0xff);
  crc_array[2]=(byte)((crc >> 8) & 0xff);
  crc_array[1]=(byte)((crc >> 16) & 0xff);
  crc_array[0]=(byte)((crc >> 24) & 0xff);
  setBlock();
  if (encryption)   crypto.encrypt(block);
  encryptedBlock=block;
}

Fixed version (ground truth):
public SshPacket(byte newType,byte[] newData,boolean encryption,SshCrypto crypto) throws IOException {
  data=newData;
  packet_type=newType;
  if (data != null)   packet_length=data.length + 5;
 else   packet_length=5;
  packet_length_array[3]=(byte)(packet_length & 0xff);
  packet_length_array[2]=(byte)((packet_length >> 8) & 0xff);
  packet_length_array[1]=(byte)((packet_length >> 16) & 0xff);
  packet_length_array[0]=(byte)((packet_length >> 24) & 0xff);
  padding=new byte[(8 - (packet_length % 8))];
  if (!encryption)   for (int i=0; i < padding.length; i++)   padding[i]=0;
 else {
    for (int i=0; i < padding.length; i++)     padding[i]=SshMisc.getNotZeroRandomByte();
  }
  byte[] tempByte=new byte[packet_length + padding.length - 4];
  int offset=0;
  for (int i=0; i < padding.length; i++)   tempByte[offset++]=padding[i];
  tempByte[offset++]=packet_type;
  if (packet_length > 5)   for (int i=0; i < data.length; i++)   tempByte[offset++]=data[i];
  long crc=0;
  crc=SshMisc.crc32(tempByte,tempByte.length);
  crc_array[3]=(byte)(crc & 0xff);
  crc_array[2]=(byte)((crc >> 8) & 0xff);
  crc_array[1]=(byte)((crc >> 16) & 0xff);
  crc_array[0]=(byte)((crc >> 24) & 0xff);
  setBlock();
  if (encryption)   crypto.encrypt(block);
  encryptedBlock=block;
}