nus-yam/ex-repair huggingface dataset:
Program: 117023
Project: 117023
Buggy source:
@Override protected String doInBackground(String... urls){
  try {
    URL parsedUrl=new URL(urls[0]);
    HttpURLConnection connection=null;
    boolean wasRedirected=false;
    int numRedirects=0;
    do {
      if (connection != null)       connection.disconnect();
      connection=(HttpURLConnection)parsedUrl.openConnection();
      connection.setInstanceFollowRedirects(true);
      connection.setRequestProperty("String_Node_Str",AppConfig.getInstance(context).userAgent);
      connection.connect();
      int responseCode=connection.getResponseCode();
      if (responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP) {
        wasRedirected=true;
        parsedUrl=new URL(connection.getHeaderField("String_Node_Str"));
        numRedirects++;
      }
 else {
        wasRedirected=false;
      }
    }
 while (!isCancelled() && wasRedirected && numRedirects < 10);
    String finalUrl=connection.getURL().toString();
    connection.disconnect();
    return finalUrl;
  }
 catch (  Exception e) {
    Log.e(TAG,e.getMessage(),e);
    return null;
  }
}

Fixed version (ground truth):
@Override protected String doInBackground(String... urls){
  try {
    URL parsedUrl=new URL(urls[0]);
    HttpURLConnection connection=null;
    boolean wasRedirected=false;
    int numRedirects=0;
    do {
      if (connection != null)       connection.disconnect();
      connection=(HttpURLConnection)parsedUrl.openConnection();
      connection.setInstanceFollowRedirects(true);
      connection.setRequestProperty("String_Node_Str",AppConfig.getInstance(context).userAgent);
      connection.connect();
      int responseCode=connection.getResponseCode();
      if (responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP) {
        wasRedirected=true;
        parsedUrl=new URL(parsedUrl,connection.getHeaderField("String_Node_Str"));
        numRedirects++;
      }
 else {
        wasRedirected=false;
      }
    }
 while (!isCancelled() && wasRedirected && numRedirects < 10);
    String finalUrl=connection.getURL().toString();
    connection.disconnect();
    return finalUrl;
  }
 catch (  Exception e) {
    Log.e(TAG,e.getMessage(),e);
    return null;
  }
}
Program: 117024
Project: 117024
Buggy source:
@Override protected void onResume(){
  super.onResume();
  this.mWebview.onResume();
  retryFailedPage();
  this.connectivityReceiver=new ConnectivityChangeReceiver();
  registerReceiver(this.connectivityReceiver,new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  this.mWebview.onResume();
  retryFailedPage();
  this.connectivityReceiver=new ConnectivityChangeReceiver();
  registerReceiver(this.connectivityReceiver,new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
  LoginManager.getInstance().checkLogin();
}
Program: 117025
Project: 117025
Buggy source:
void cancelSubmissionCheck(){
  if (handler != null)   handler.removeMessages(1);
}

Fixed version (ground truth):
void cancelSubmissionCheck(){
  if (checkAjaxHandler != null)   checkAjaxHandler.removeMessages(1);
}
Program: 117027
Project: 117027
Buggy source:
void scheduleSubmissionCheck(){
  handler=new Handler(){
    @Override public void handleMessage(    Message msg){
      runOnUiThread(new Runnable(){
        @Override public void run(){
          WebFormActivity.this.checkSubmissionStatus();
        }
      }
);
    }
  }
;
  Message message=Message.obtain();
  message.what=1;
  handler.sendMessageDelayed(message,1000);
}

Fixed version (ground truth):
void scheduleSubmissionCheck(){
  checkAjaxHandler=new Handler(){
    @Override public void handleMessage(    Message msg){
      runOnUiThread(new Runnable(){
        @Override public void run(){
          WebFormActivity.this.checkSubmissionStatus();
        }
      }
);
    }
  }
;
  Message message=Message.obtain();
  message.what=1;
  checkAjaxHandler.sendMessageDelayed(message,1000);
}
Program: 117029
Project: 117029
Buggy source:
public void update(Observable sender,Object data){
  if (sender instanceof LoginManager) {
    sender.deleteObserver(this);
    if (((LoginManager)sender).isLoggedIn()) {
      Intent returnIntent=new Intent();
      returnIntent.putExtra("String_Node_Str",true);
      setResult(RESULT_OK,returnIntent);
      finish();
    }
 else {
      mHiddenWebView.loadUrl(this.mJson.optString("String_Node_Str","String_Node_Str"));
      mLoginStatusView.setVisibility(View.GONE);
      mLoginFormView.setVisibility(View.VISIBLE);
    }
  }
}

Fixed version (ground truth):
public void update(Observable sender,Object data){
  if (sender instanceof LoginManager && mIsLogin) {
    sender.deleteObserver(this);
    if (((LoginManager)sender).isLoggedIn()) {
      Intent returnIntent=new Intent();
      returnIntent.putExtra("String_Node_Str",true);
      String currentUrl=mHiddenWebView.getUrl();
      if (currentUrl != null && !currentUrl.equals(this.mJson.optString("String_Node_Str","String_Node_Str"))) {
        returnIntent.putExtra("String_Node_Str",mHiddenWebView.getUrl());
      }
      setResult(RESULT_OK,returnIntent);
      finish();
    }
 else     if (AppConfig.getInstance(this).loginIsFirstPage) {
      mHiddenWebView.loadUrl(this.mJson.optString("String_Node_Str","String_Node_Str"));
      mLoginStatusView.setVisibility(View.GONE);
      mLoginFormView.setVisibility(View.VISIBLE);
    }
  }
}
Program: 117030
Project: 117030
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
  if (item.getItemId() == R.id.action_forgot_password) {
    InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mLoginFormView.getWindowToken(),0);
    Intent returnIntent=new Intent();
    returnIntent.putExtra("String_Node_Str",mForgotPasswordUrl);
    returnIntent.putExtra("String_Node_Str",false);
    setResult(RESULT_OK,returnIntent);
    finish();
    return true;
  }
 else   return super.onOptionsItemSelected(item);
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
  if (item.getItemId() == R.id.action_forgot_password) {
    InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mLoginFormView.getWindowToken(),0);
    Intent returnIntent=new Intent();
    returnIntent.putExtra("String_Node_Str",mForgotPasswordUrl);
    returnIntent.putExtra("String_Node_Str",false);
    setResult(RESULT_OK,returnIntent);
    finish();
    return true;
  }
 else   if (item.getItemId() == android.R.id.home) {
    this.finish();
    return true;
  }
 else   return super.onOptionsItemSelected(item);
}
Program: 117032
Project: 117032
Buggy source:
@Override public void onPageFinished(WebView view,String url){
  mainActivity.showWebview();
  UrlInspector.getInstance().inspectUrl(url);
  super.onPageFinished(view,url);
  Uri uri=Uri.parse(url);
  if (isInternalUri(uri)) {
    CookieSyncManager.getInstance().sync();
  }
  AppConfig appConfig=AppConfig.getInstance(mainActivity);
  if (appConfig.loginDetectionUrl != null) {
    if (mVisitedLoginOrSignup) {
      mainActivity.updateMenu();
    }
    mVisitedLoginOrSignup=LeanUtils.urlsMatchOnPath(url,appConfig.loginUrl) || LeanUtils.urlsMatchOnPath(url,appConfig.signupUrl);
  }
  if (this.dynamicUpdateExec != null) {
    view.loadUrl(this.dynamicUpdateExec);
  }
  if (this.profilePickerExec != null) {
    view.loadUrl(this.profilePickerExec);
  }
  if (this.analyticsExec != null) {
    view.loadUrl(this.analyticsExec);
  }
  mainActivity.checkTabs(url);
  if (mainActivity.postLoadJavascript != null) {
    String js=mainActivity.postLoadJavascript;
    mainActivity.postLoadJavascript=null;
    mainActivity.runJavascript(js);
  }
  LocalBroadcastManager.getInstance(mainActivity).sendBroadcast(new Intent(this.FINISHED_LOADING_MESSAGE));
}

Fixed version (ground truth):
@Override public void onPageFinished(WebView view,String url){
  mainActivity.runOnUiThread(new Runnable(){
    @Override public void run(){
      mainActivity.showWebview();
    }
  }
);
  UrlInspector.getInstance().inspectUrl(url);
  super.onPageFinished(view,url);
  Uri uri=Uri.parse(url);
  if (isInternalUri(uri)) {
    CookieSyncManager.getInstance().sync();
  }
  AppConfig appConfig=AppConfig.getInstance(mainActivity);
  if (appConfig.loginDetectionUrl != null) {
    if (mVisitedLoginOrSignup) {
      mainActivity.updateMenu();
    }
    mVisitedLoginOrSignup=LeanUtils.urlsMatchOnPath(url,appConfig.loginUrl) || LeanUtils.urlsMatchOnPath(url,appConfig.signupUrl);
  }
  if (this.dynamicUpdateExec != null) {
    view.loadUrl(this.dynamicUpdateExec);
  }
  if (this.profilePickerExec != null) {
    view.loadUrl(this.profilePickerExec);
  }
  if (this.analyticsExec != null) {
    view.loadUrl(this.analyticsExec);
  }
  mainActivity.checkTabs(url);
  if (mainActivity.postLoadJavascript != null) {
    String js=mainActivity.postLoadJavascript;
    mainActivity.postLoadJavascript=null;
    mainActivity.runJavascript(js);
  }
  LocalBroadcastManager.getInstance(mainActivity).sendBroadcast(new Intent(this.FINISHED_LOADING_MESSAGE));
}
Program: 117033
Project: 117033
Buggy source:
@Override public void onReceivedError(WebView view,int errorCode,String description,String failingUrl){
  mainActivity.showWebview();
  if (!mainActivity.isConnected()) {
    ((LeanWebView)view).loadUrlDirect("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void onReceivedError(WebView view,int errorCode,String description,String failingUrl){
  mainActivity.runOnUiThread(new Runnable(){
    @Override public void run(){
      mainActivity.showWebview();
    }
  }
);
  if (!mainActivity.isConnected()) {
    ((LeanWebView)view).loadUrlDirect("String_Node_Str");
  }
}
Program: 117034
Project: 117034
Buggy source:
@Override public void run(){
  mainActivity.showWebviewImmediately();
}

Fixed version (ground truth):
@Override public void run(){
  mainActivity.showWebview();
}
Program: 117035
Project: 117035
Buggy source:
@Override public void onAnimationEnd(Animation animation){
}

Fixed version (ground truth):
@Override public void onAnimationEnd(Animation animation){
  mProgress.setVisibility(View.INVISIBLE);
}
Program: 117036
Project: 117036
Buggy source:
public void showWebview(){
  startedLoading=false;
  stopCheckingReadyStatus();
  final WebView wv=this.mWebview;
  if (wv.getVisibility() == View.VISIBLE) {
    mProgress.setVisibility(View.INVISIBLE);
    return;
  }
  Animation fadein=AnimationUtils.loadAnimation(this,android.R.anim.fade_in);
  Animation fadeout=AnimationUtils.loadAnimation(this,android.R.anim.fade_out);
  fadein.setDuration(300);
  fadeout.setDuration(60);
  fadein.setStartOffset(150);
  mProgress.setAlpha(1.0f);
  wv.setVisibility(View.VISIBLE);
  fadeout.setAnimationListener(new Animation.AnimationListener(){
    @Override public void onAnimationStart(    Animation animation){
    }
    @Override public void onAnimationEnd(    Animation animation){
    }
    @Override public void onAnimationRepeat(    Animation animation){
    }
  }
);
  mProgress.startAnimation(fadeout);
  wv.startAnimation(fadein);
}

Fixed version (ground truth):
public void showWebview(){
  startedLoading=false;
  stopCheckingReadyStatus();
  final WebView wv=this.mWebview;
  if (wv.getVisibility() == View.VISIBLE) {
    mProgress.setVisibility(View.INVISIBLE);
    return;
  }
  Animation fadein=AnimationUtils.loadAnimation(this,android.R.anim.fade_in);
  Animation fadeout=AnimationUtils.loadAnimation(this,android.R.anim.fade_out);
  fadein.setDuration(300);
  fadeout.setDuration(60);
  fadein.setStartOffset(150);
  mProgress.setAlpha(1.0f);
  wv.setVisibility(View.VISIBLE);
  fadeout.setAnimationListener(new Animation.AnimationListener(){
    @Override public void onAnimationStart(    Animation animation){
    }
    @Override public void onAnimationEnd(    Animation animation){
      mProgress.setVisibility(View.INVISIBLE);
    }
    @Override public void onAnimationRepeat(    Animation animation){
    }
  }
);
  mProgress.startAnimation(fadeout);
  wv.startAnimation(fadein);
}
Program: 117037
Project: 117037
Buggy source:
@Override public void loadUrl(String url){
  if (url.startsWith("String_Node_Str"))   loadUrlDirect(url);
 else   if (mClient == null || !mClient.shouldOverrideUrlLoading(this,url)) {
    super.loadUrl(url);
  }
}

Fixed version (ground truth):
@Override public void loadUrl(String url){
  if (url.startsWith("String_Node_Str"))   LeanUtils.runJavascriptOnWebView(this,url.substring("String_Node_Str".length()));
 else   if (mClient == null || !mClient.shouldOverrideUrlLoading(this,url)) {
    super.loadUrl(url);
  }
}
Program: 117038
Project: 117038
Buggy source:
@Override public void onPageFinished(WebView view,String url){
  mainActivity.runOnUiThread(new Runnable(){
    @Override public void run(){
      mainActivity.showWebview();
    }
  }
);
  UrlInspector.getInstance().inspectUrl(url);
  super.onPageFinished(view,url);
  Uri uri=Uri.parse(url);
  if (isInternalUri(uri)) {
    CookieSyncManager.getInstance().sync();
  }
  AppConfig appConfig=AppConfig.getInstance(mainActivity);
  if (appConfig.loginDetectionUrl != null) {
    if (mVisitedLoginOrSignup) {
      mainActivity.updateMenu();
    }
    mVisitedLoginOrSignup=LeanUtils.urlsMatchOnPath(url,appConfig.loginUrl) || LeanUtils.urlsMatchOnPath(url,appConfig.signupUrl);
  }
  if (this.dynamicUpdateExec != null) {
    view.loadUrl(this.dynamicUpdateExec);
  }
  if (this.profilePickerExec != null) {
    view.loadUrl(this.profilePickerExec);
  }
  if (this.analyticsExec != null) {
    view.loadUrl(this.analyticsExec);
  }
  mainActivity.checkTabs(url);
  if (mainActivity.postLoadJavascript != null) {
    String js=mainActivity.postLoadJavascript;
    mainActivity.postLoadJavascript=null;
    mainActivity.runJavascript(js);
  }
  LocalBroadcastManager.getInstance(mainActivity).sendBroadcast(new Intent(this.FINISHED_LOADING_MESSAGE));
}

Fixed version (ground truth):
@Override public void onPageFinished(WebView view,String url){
  mainActivity.runOnUiThread(new Runnable(){
    @Override public void run(){
      mainActivity.showWebview();
    }
  }
);
  UrlInspector.getInstance().inspectUrl(url);
  super.onPageFinished(view,url);
  Uri uri=Uri.parse(url);
  if (isInternalUri(uri)) {
    CookieSyncManager.getInstance().sync();
  }
  AppConfig appConfig=AppConfig.getInstance(mainActivity);
  if (appConfig.loginDetectionUrl != null) {
    if (mVisitedLoginOrSignup) {
      mainActivity.updateMenu();
    }
    mVisitedLoginOrSignup=LeanUtils.urlsMatchOnPath(url,appConfig.loginUrl) || LeanUtils.urlsMatchOnPath(url,appConfig.signupUrl);
  }
  if (this.dynamicUpdateExec != null) {
    LeanUtils.runJavascriptOnWebView(view,this.dynamicUpdateExec);
  }
  if (this.profilePickerExec != null) {
    LeanUtils.runJavascriptOnWebView(view,this.profilePickerExec);
  }
  if (this.analyticsExec != null) {
    LeanUtils.runJavascriptOnWebView(view,this.analyticsExec);
  }
  mainActivity.checkTabs(url);
  if (mainActivity.postLoadJavascript != null) {
    String js=mainActivity.postLoadJavascript;
    mainActivity.postLoadJavascript=null;
    mainActivity.runJavascript(js);
  }
  LocalBroadcastManager.getInstance(mainActivity).sendBroadcast(new Intent(this.FINISHED_LOADING_MESSAGE));
}
Program: 117039
Project: 117039
Buggy source:
public LeanWebviewClient(MainActivity activity){
  super();
  this.mainActivity=activity;
  AppConfig appConfig=AppConfig.getInstance(mainActivity);
  if (appConfig.profilePickerJS != null) {
    StringBuilder sb=new StringBuilder();
    sb.append("String_Node_Str");
    sb.append(LeanUtils.jsWrapString(appConfig.profilePickerJS));
    sb.append("String_Node_Str");
    String encoded=LeanUtils.urlEncode(sb.toString());
    if (encoded != null)     this.profilePickerExec="String_Node_Str" + encoded;
  }
  if (appConfig.analytics) {
    String distribution=(String)Installation.getInfo(mainActivity).get("String_Node_Str");
    int idsite;
    if (distribution != null && (distribution.equals("String_Node_Str") || distribution.equals("String_Node_Str")))     idsite=appConfig.idsite_prod;
 else     idsite=appConfig.idsite_test;
    this.analyticsExec=String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",idsite);
  }
  if (appConfig.updateConfigJS != null) {
    StringBuilder sb=new StringBuilder();
    sb.append("String_Node_Str");
    sb.append(LeanUtils.jsWrapString(appConfig.updateConfigJS));
    sb.append("String_Node_Str");
    String encoded=LeanUtils.urlEncode(sb.toString());
    if (encoded != null)     this.dynamicUpdateExec="String_Node_Str" + encoded;
  }
}

Fixed version (ground truth):
public LeanWebviewClient(MainActivity activity){
  super();
  this.mainActivity=activity;
  AppConfig appConfig=AppConfig.getInstance(mainActivity);
  if (appConfig.profilePickerJS != null) {
    StringBuilder sb=new StringBuilder();
    sb.append("String_Node_Str");
    sb.append(LeanUtils.jsWrapString(appConfig.profilePickerJS));
    sb.append("String_Node_Str");
    this.profilePickerExec=sb.toString();
  }
  if (appConfig.analytics) {
    String distribution=(String)Installation.getInfo(mainActivity).get("String_Node_Str");
    int idsite;
    if (distribution != null && (distribution.equals("String_Node_Str") || distribution.equals("String_Node_Str")))     idsite=appConfig.idsite_prod;
 else     idsite=appConfig.idsite_test;
    this.analyticsExec=String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",idsite);
  }
  if (appConfig.updateConfigJS != null) {
    StringBuilder sb=new StringBuilder();
    sb.append("String_Node_Str");
    sb.append(LeanUtils.jsWrapString(appConfig.updateConfigJS));
    sb.append("String_Node_Str");
    this.dynamicUpdateExec=sb.toString();
  }
}
Program: 117040
Project: 117040
Buggy source:
public void runJavascript(String javascript){
  if (javascript == null)   return;
  this.mWebview.loadUrl("String_Node_Str" + javascript);
}

Fixed version (ground truth):
public void runJavascript(String javascript){
  if (javascript == null)   return;
  LeanUtils.runJavascriptOnWebView(this.mWebview,javascript);
}
Program: 117041
Project: 117041
Buggy source:
public void checkReadyStatus(){
  this.mWebview.loadUrl("String_Node_Str");
}

Fixed version (ground truth):
public void checkReadyStatus(){
  LeanUtils.runJavascriptOnWebView(this.mWebview,"String_Node_Str");
}
Program: 117042
Project: 117042
Buggy source:
@Override public void onPageFinished(WebView view,String url){
  super.onPageFinished(view,url);
  UrlInspector.getInstance().inspectUrl(url);
  CookieSyncManager.getInstance().sync();
  view.loadUrl("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  boolean success=false;
  if (!LeanUtils.urlsMatchOnPath(url,mFormUrl) && !LeanUtils.urlsMatchOnPath(url,mErrorUrl) && !LeanUtils.urlsMatchOnPath(url,mForgotPasswordUrl)) {
    success=true;
  }
  if (mSubmitted) {
    if (LeanUtils.urlsMatchOnPath(url,mErrorUrl)) {
      mSubmitted=false;
      mSubmitButton.setEnabled(true);
      String errorSelector=mJson.optString("String_Node_Str","String_Node_Str");
      if (errorSelector.length() > 0) {
        runJavascript(String.format("String_Node_Str",LeanUtils.jsWrapString(errorSelector),LeanUtils.jsWrapString(errorSelector)));
      }
 else {
        Toast.makeText(WebFormActivity.this,R.string.form_error,Toast.LENGTH_LONG).show();
      }
      mHiddenWebView.loadUrl(mFormUrl);
    }
 else     success=true;
  }
  if (success) {
    cancelSubmissionCheck();
    mSubmitted=false;
    Intent returnIntent=new Intent();
    returnIntent.putExtra("String_Node_Str",url);
    returnIntent.putExtra("String_Node_Str",true);
    setResult(RESULT_OK,returnIntent);
    finish();
  }
}

Fixed version (ground truth):
@Override public void onPageFinished(WebView view,String url){
  super.onPageFinished(view,url);
  UrlInspector.getInstance().inspectUrl(url);
  CookieSyncManager.getInstance().sync();
  LeanUtils.runJavascriptOnWebView(view,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  boolean success=false;
  if (!LeanUtils.urlsMatchOnPath(url,mFormUrl) && !LeanUtils.urlsMatchOnPath(url,mErrorUrl) && !LeanUtils.urlsMatchOnPath(url,mForgotPasswordUrl)) {
    success=true;
  }
  if (mSubmitted) {
    if (LeanUtils.urlsMatchOnPath(url,mErrorUrl)) {
      mSubmitted=false;
      mSubmitButton.setEnabled(true);
      String errorSelector=mJson.optString("String_Node_Str","String_Node_Str");
      if (errorSelector.length() > 0) {
        runJavascript(String.format("String_Node_Str",LeanUtils.jsWrapString(errorSelector),LeanUtils.jsWrapString(errorSelector)));
      }
 else {
        Toast.makeText(WebFormActivity.this,R.string.form_error,Toast.LENGTH_LONG).show();
      }
      mHiddenWebView.loadUrl(mFormUrl);
    }
 else     success=true;
  }
  if (success) {
    cancelSubmissionCheck();
    mSubmitted=false;
    Intent returnIntent=new Intent();
    returnIntent.putExtra("String_Node_Str",url);
    returnIntent.putExtra("String_Node_Str",true);
    setResult(RESULT_OK,returnIntent);
    finish();
  }
}
Program: 117043
Project: 117043
Buggy source:
private void runJavascript(String js){
  js=js.replace("String_Node_Str","String_Node_Str");
  mHiddenWebView.loadUrl("String_Node_Str" + js);
}

Fixed version (ground truth):
private void runJavascript(String js){
  LeanUtils.runJavascriptOnWebView(this.mHiddenWebView,js);
}
Program: 117046
Project: 117046
Buggy source:
@Override protected void onPostExecute(String finalUrl){
  UrlInspector.getInstance().inspectUrl(finalUrl);
  if (finalUrl == null) {
    loggedIn=false;
    loginStatus="String_Node_Str";
    setChanged();
    notifyObservers();
  }
  AppConfig appConfig=AppConfig.getInstance(LoginManager.this.context);
  List<Pattern> regexes=appConfig.loginDetectRegexes;
  for (int i=0; i < regexes.size(); i++) {
    Pattern regex=regexes.get(i);
    if (regex.matcher(finalUrl).matches()) {
      JSONObject entry=appConfig.loginDetectLocations.get(i);
      loggedIn=entry.optBoolean("String_Node_Str",false);
      loginStatus=AppConfig.optString(entry,"String_Node_Str");
      if (loginStatus == null)       loginStatus=loggedIn ? "String_Node_Str" : "String_Node_Str";
      setChanged();
      notifyObservers();
      break;
    }
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(String finalUrl){
  UrlInspector.getInstance().inspectUrl(finalUrl);
  if (finalUrl == null) {
    loggedIn=false;
    loginStatus="String_Node_Str";
    setChanged();
    notifyObservers();
    return;
  }
  AppConfig appConfig=AppConfig.getInstance(LoginManager.this.context);
  List<Pattern> regexes=appConfig.loginDetectRegexes;
  for (int i=0; i < regexes.size(); i++) {
    Pattern regex=regexes.get(i);
    if (regex.matcher(finalUrl).matches()) {
      JSONObject entry=appConfig.loginDetectLocations.get(i);
      loggedIn=entry.optBoolean("String_Node_Str",false);
      loginStatus=AppConfig.optString(entry,"String_Node_Str");
      if (loginStatus == null)       loginStatus=loggedIn ? "String_Node_Str" : "String_Node_Str";
      setChanged();
      notifyObservers();
      break;
    }
  }
}
Program: 117047
Project: 117047
Buggy source:
@Nullable private static Annotation createAnnotation(@NotNull AnnotationHolder holder,@NotNull PsiFile file,@NotNull Document document,@NotNull Result.Warn warn,@NotNull HighlightSeverity severity,@Nullable TextAttributes forcedTextAttributes,boolean showErrorOnWholeLine){
  int line=warn.line - 1;
  int column=warn.column - 1;
  if (line < 0 || line >= document.getLineCount()) {
    return null;
  }
  int lineEndOffset=document.getLineEndOffset(line);
  int lineStartOffset=document.getLineStartOffset(line);
  int errorLineStartOffset=StringUtil.lineColToOffset(document.getCharsSequence(),line,column);
  if (errorLineStartOffset == -1) {
    return null;
  }
  TextRange range;
  if (showErrorOnWholeLine) {
    range=new TextRange(lineStartOffset,lineEndOffset);
  }
 else {
    PsiElement lit=PsiUtil.getElementAtOffset(file,errorLineStartOffset);
    range=lit.getTextRange();
  }
  Annotation annotation=JSLinterUtil.createAnnotation(holder,severity,forcedTextAttributes,range,MESSAGE_PREFIX + warn.message.trim() + "String_Node_Str"+ warn.rule+ ')');
  if (annotation != null) {
    annotation.setAfterEndOfLine(errorLineStartOffset == lineEndOffset);
  }
  return annotation;
}

Fixed version (ground truth):
@Nullable private static Annotation createAnnotation(@NotNull AnnotationHolder holder,@NotNull PsiFile file,@NotNull Document document,@NotNull VerifyMessage warn,@NotNull HighlightSeverity severity,@Nullable TextAttributes forcedTextAttributes,boolean showErrorOnWholeLine){
  int line=warn.line - 1;
  int column=warn.column - 1;
  if (line < 0 || line >= document.getLineCount()) {
    return null;
  }
  int lineEndOffset=document.getLineEndOffset(line);
  int lineStartOffset=document.getLineStartOffset(line);
  int errorLineStartOffset=StringUtil.lineColToOffset(document.getCharsSequence(),line,column);
  if (errorLineStartOffset == -1) {
    return null;
  }
  TextRange range;
  if (showErrorOnWholeLine) {
    range=new TextRange(lineStartOffset,lineEndOffset);
  }
 else {
    PsiElement lit=PsiUtil.getElementAtOffset(file,errorLineStartOffset);
    range=lit.getTextRange();
  }
  Annotation annotation=JSLinterUtil.createAnnotation(holder,severity,forcedTextAttributes,range,MESSAGE_PREFIX + warn.message.trim() + "String_Node_Str"+ warn.ruleId+ ')');
  if (annotation != null) {
    annotation.setAfterEndOfLine(errorLineStartOffset == lineEndOffset);
  }
  return annotation;
}
Program: 117049
Project: 117049
Buggy source:
private static HighlightSeverity getHighlightSeverity(Result.Warn warn,boolean treatAsWarnings){
  if (treatAsWarnings) {
    return HighlightSeverity.WARNING;
  }
  return warn.level.equals("String_Node_Str") ? HighlightSeverity.ERROR : HighlightSeverity.WARNING;
}

Fixed version (ground truth):
private static HighlightSeverity getHighlightSeverity(VerifyMessage warn,boolean treatAsWarnings){
  if (treatAsWarnings) {
    return HighlightSeverity.WARNING;
  }
  return warn.severity == 2 ? HighlightSeverity.ERROR : HighlightSeverity.WARNING;
}
Program: 117050
Project: 117050
Buggy source:
public static boolean isESLintConfigFile(VirtualFile file){
  return file != null && file.getName().equals(ESLintConfigFileType.ESLINTRC);
}

Fixed version (ground truth):
public static boolean isESLintConfigFile(VirtualFile file){
  return file != null && isRC(file.getName());
}
Program: 117051
Project: 117051
Buggy source:
@NotNull static GeneralCommandLine createLint(@NotNull ESLintRunner.ESLintSettings settings){
  GeneralCommandLine commandLine=create(settings);
  commandLine.addParameter(settings.targetFile);
  CLI.addParamIfNotEmpty(commandLine,C,settings.config);
  if (StringUtil.isNotEmpty(settings.rules)) {
    CLI.addParam(commandLine,RULESDIR,"String_Node_Str" + settings.rules + "String_Node_Str");
  }
  if (StringUtil.isNotEmpty(settings.ext)) {
    CLI.addParam(commandLine,EXT,settings.ext);
  }
  return commandLine;
}

Fixed version (ground truth):
@NotNull static GeneralCommandLine createLint(@NotNull ESLintRunner.ESLintSettings settings){
  GeneralCommandLine commandLine=create(settings);
  commandLine.addParameter(settings.targetFile);
  CLI.addParamIfNotEmpty(commandLine,C,settings.config);
  if (StringUtil.isNotEmpty(settings.rules)) {
    CLI.addParam(commandLine,RULESDIR,"String_Node_Str" + settings.rules + "String_Node_Str");
  }
  if (StringUtil.isNotEmpty(settings.ext)) {
    CLI.addParam(commandLine,EXT,settings.ext);
  }
  CLI.addParam(commandLine,FORMAT,JSON);
  return commandLine;
}
Program: 117052
Project: 117052
Buggy source:
public static Result processResults(ProcessOutput output){
  Result result=new Result();
  List<String> lines=output.getStdoutLines();
  String file=null;
  for (  String line : lines) {
    if (file == null) {
      file=line;
    }
    Warn warn=parseLine(line);
    if (warn != null) {
      result.warns.add(warn);
    }
  }
  result.errorOutput=output.getStderr();
  return result;
}

Fixed version (ground truth):
public static Result processResults(ProcessOutput output){
  Result result=new Result();
  result.errorOutput=output.getStderr();
  try {
    List<FileResult> fileResults=parseInternal(output.getStdout());
    if (!fileResults.isEmpty()) {
      result.warns=fileResults.get(0).messages;
    }
  }
 catch (  Exception e) {
    result.errorOutput=e.toString();
  }
  return result;
}
Program: 117053
Project: 117053
Buggy source:
public boolean printToFile() throws PrintException, IOException {
  log.info("String_Node_Str" + outputPath.get());
  OutputStream out=new FileOutputStream(outputPath.get());
  out.write(this.getRawCmds().getByteArray());
  out.close();
  return true;
}

Fixed version (ground truth):
public boolean printToFile() throws PrintException, IOException {
  log.info("String_Node_Str" + outputPath.get());
  OutputStream out=null;
  try {
    out=new FileOutputStream(outputPath.get());
    out.write(this.getRawCmds().getByteArray());
  }
  finally {
    if (out != null) {
      out.close();
    }
    outputPath.set(null);
  }
  return true;
}
Program: 117054
Project: 117054
Buggy source:
/** 
 * A brute-force, however surprisingly elegant way to send a file to a networked printer. The socket host can be an IP Address or Host Name.  The port 9100 is a standard HP/JetDirect and may work well. Please note that this will completely bypass the Print Spooler, so the Operating System will have absolutely no printer information.  This is printing "blind".
 * @throws UnknownHostException
 * @throws IOException
 */
private boolean printToSocket() throws IOException {
  log.info("String_Node_Str" + socketHost.get() + "String_Node_Str"+ socketPort.get());
  Socket socket=new Socket(socketHost.get(),socketPort.get());
  DataOutputStream out=new DataOutputStream(socket.getOutputStream());
  out.write(getRawCmds().getByteArray());
  socket.close();
  return true;
}

Fixed version (ground truth):
/** 
 * A brute-force, however surprisingly elegant way to send a file to a networked printer. The socket host can be an IP Address or Host Name.  The port 9100 is a standard HP/JetDirect and may work well. Please note that this will completely bypass the Print Spooler, so the Operating System will have absolutely no printer information.  This is printing "blind".
 * @throws UnknownHostException
 * @throws IOException
 */
private boolean printToSocket() throws IOException {
  log.info("String_Node_Str" + socketHost.get() + "String_Node_Str"+ socketPort.get());
  Socket socket=null;
  DataOutputStream out=null;
  try {
    socket=new Socket(socketHost.get(),socketPort.get());
    out=new DataOutputStream(socket.getOutputStream());
    out.write(getRawCmds().getByteArray());
  }
  finally {
    if (out != null) {
      out.close();
    }
    if (socket != null) {
      socket.close();
    }
    socketHost.set(null);
    socketPort.set(null);
  }
  return true;
}
Program: 117055
Project: 117055
Buggy source:
public boolean prompt(String description,Certificate cert){
  persistentCheckBox.setSelected(false);
  if (cert == null || cert.isBlocked()) {
    approved=false;
    return false;
  }
  if (cert.isTrusted() && cert.isSaved()) {
    return true;
  }
  setDescription(description);
  setCertificate(cert);
  setVisible(true);
  return isApproved();
}

Fixed version (ground truth):
public boolean prompt(String description,Certificate cert){
  persistentCheckBox.setSelected(false);
  if (cert == null || cert.isBlocked()) {
    approved=false;
    return false;
  }
  if (cert.isTrusted() && cert.isSaved()) {
    approved=true;
    return true;
  }
  setDescription(description);
  setCertificate(cert);
  setVisible(true);
  return isApproved();
}
Program: 117056
Project: 117056
Buggy source:
public void setPrintParameters(PrintApplet applet){
  this.ps.set(applet.getPrintService());
  this.jobName.set(applet.getJobName().replace("String_Node_Str","String_Node_Str"));
  if (applet.getCopies() > 1) {
    setCopies(applet.getCopies());
  }
}

Fixed version (ground truth):
public void setPrintParameters(PrintApplet applet){
  this.jobName.set(applet.getJobName().replace("String_Node_Str","String_Node_Str"));
  if (applet.getCopies() > 1) {
    setCopies(applet.getCopies());
  }
}
Program: 117057
Project: 117057
Buggy source:
public void setPrintParameters(PrintApplet a){
  setPrintService(a.getPrintService());
  setPaperSize(a.getPaperSize());
  setCopies(a.getCopies());
  setJobName(a.getJobName().replace("String_Node_Str","String_Node_Str"));
  setLogPostScriptFeatures(a.getLogPostScriptFeatures());
}

Fixed version (ground truth):
public void setPrintParameters(PrintApplet a){
  setCopies(a.getCopies());
  setJobName(a.getJobName().replace("String_Node_Str","String_Node_Str"));
  setLogPostScriptFeatures(a.getLogPostScriptFeatures());
}
Program: 117058
Project: 117058
Buggy source:
public void setPrintParameters(PrintApplet rawPrintApplet){
  this.setPrintService(rawPrintApplet.getPrintService());
  this.setJobName(rawPrintApplet.getJobName().replace("String_Node_Str","String_Node_Str"));
  this.setCharset(rawPrintApplet.getCharset());
  this.setAlternatePrinting(rawPrintApplet.isAlternatePrinting());
  if (rawPrintApplet.getCopies() > 0) {
    setCopies(rawPrintApplet.getCopies());
  }
  this.clear();
}

Fixed version (ground truth):
public void setPrintParameters(PrintApplet rawPrintApplet){
  this.setJobName(rawPrintApplet.getJobName().replace("String_Node_Str","String_Node_Str"));
  this.setAlternatePrinting(rawPrintApplet.isAlternatePrinting());
  if (rawPrintApplet.getCopies() > 0) {
    setCopies(rawPrintApplet.getCopies());
  }
  this.clear();
}
Program: 117060
Project: 117060
Buggy source:
/** 
 * Returns the cached version of the found serial ports on the system. i.e. ["COM1","COM2","COM3"] or ["/dev/tty0","/dev/tty1"]
 * @return 
 */
public String getSerialPorts(){
  return this.serialPorts;
}

Fixed version (ground truth):
/** 
 * Returns the cached version of the found serial ports on the system. i.e. ["COM1","COM2","COM3"] or ["/dev/tty0","/dev/tty1"]
 * @return Cached version of serial ports
 */
public String getSerialPorts(){
  return this.serialPorts;
}
Program: 117061
Project: 117061
Buggy source:
/** 
 * Timeout in milliseconds for the port.readBytes() function. Default is 1200 (1.2 seconds)
 * @param timeout 
 */
public final void setTimeout(int timeout){
  this.timeout=timeout;
}

Fixed version (ground truth):
/** 
 * Timeout in milliseconds for the port.readBytes() function. Default is 1200 (1.2 seconds)
 * @param timeout the timeout
 */
public final void setTimeout(int timeout){
  this.timeout=timeout;
}
Program: 117062
Project: 117062
Buggy source:
/** 
 * Return whether or not the serial port is open
 * @return 
 */
public boolean isOpen(){
  return port == null ? false : port.isOpened();
}

Fixed version (ground truth):
/** 
 * Return whether or not the serial port is open
 * @return boolean indicating if port is open
 */
public boolean isOpen(){
  return port != null && port.isOpened();
}
Program: 117063
Project: 117063
Buggy source:
/** 
 * Timeout in milliseconds for the port.readBytes() function.
 * @return 
 */
public int getTimeout(){
  return this.timeout;
}

Fixed version (ground truth):
/** 
 * Timeout in milliseconds for the port.readBytes() function.
 * @return the timeout
 */
public int getTimeout(){
  return this.timeout;
}
Program: 117064
Project: 117064
Buggy source:
/** 
 * Caches a comma delimited list of ports found on this system.  Also caches the array so that it can be referenced by index when opening the port later.
 * @return 
 */
public String fetchSerialPorts(){
  StringBuilder sb=new StringBuilder();
  this.portArray=SerialPortList.getPortNames();
  for (int i=0; i < this.portArray.length; i++) {
    sb.append(this.portArray[i]).append(i < this.portArray.length - 1 ? "String_Node_Str" : "String_Node_Str");
  }
  return (this.serialPorts=sb.toString());
}

Fixed version (ground truth):
/** 
 * Caches a comma delimited list of ports found on this system.  Also caches the array so that it can be referenced by index when opening the port later.
 * @return List of ports
 */
public String fetchSerialPorts(){
  StringBuilder sb=new StringBuilder();
  this.portArray=SerialPortList.getPortNames();
  for (int i=0; i < this.portArray.length; i++) {
    sb.append(this.portArray[i]).append(i < this.portArray.length - 1 ? "String_Node_Str" : "String_Node_Str");
  }
  return (this.serialPorts=sb.toString());
}
Program: 117065
Project: 117065
Buggy source:
/** 
 * Closes the open serial port, if open.  If not, displays a warning message in the console and  continues quietly.  If the port cannot close, a  <code>SerialPortExcpetion</code> will be thrown.
 * @return
 * @throws SerialPortException 
 */
public boolean close() throws SerialPortException {
  if (port == null || !port.isOpened()) {
    LogIt.log(Level.WARNING,"String_Node_Str" + portName + "String_Node_Str");
    return false;
  }
  boolean closed=port.closePort();
  if (!closed) {
    LogIt.log(Level.WARNING,"String_Node_Str" + portName + "String_Node_Str");
  }
 else {
    LogIt.log("String_Node_Str" + portName + "String_Node_Str");
  }
  port=null;
  portName=null;
  return closed;
}

Fixed version (ground truth):
/** 
 * Closes the open serial port, if open.  If not, displays a warning message in the console and  continues quietly.  If the port cannot close, a  <code>SerialPortExcpetion</code> will be thrown.
 * @return boolean indicating success
 * @throws SerialPortException 
 */
public boolean close() throws SerialPortException {
  if (port == null || !port.isOpened()) {
    LogIt.log(Level.WARNING,"String_Node_Str" + portName + "String_Node_Str");
    return false;
  }
  boolean closed=port.closePort();
  if (!closed) {
    LogIt.log(Level.WARNING,"String_Node_Str" + portName + "String_Node_Str");
  }
 else {
    LogIt.log("String_Node_Str" + portName + "String_Node_Str");
  }
  port=null;
  portName=null;
  return closed;
}
Program: 117066
Project: 117066
Buggy source:
/** 
 * Allow a port to be selected from array of returned ports.
 * @param portID
 * @return
 * @throws SerialPortException
 * @throws SerialException 
 */
public boolean open(int portID) throws SerialPortException, SerialException {
  if (this.serialPorts == null) {
    this.getSerialPorts();
  }
  if (this.serialPorts.equals("String_Node_Str")) {
    throw new SerialException("String_Node_Str");
  }
  if (portID > -1 && this.portArray.length > 0 && this.portArray.length > portID) {
    return open(portArray[portID]);
  }
 else {
    throw new SerialException("String_Node_Str" + portID + "String_Node_Str"+ "String_Node_Str"+ serialPorts);
  }
}

Fixed version (ground truth):
/** 
 * Allow a port to be selected from array of returned ports.
 * @param portID the port ID to select
 * @return boolean indicting success
 * @throws SerialPortException
 * @throws SerialException 
 */
public boolean open(int portID) throws SerialPortException, SerialException {
  if (this.serialPorts == null) {
    this.getSerialPorts();
  }
  if ("String_Node_Str".equals(this.serialPorts)) {
    throw new SerialException("String_Node_Str");
  }
  if (portID > -1 && this.portArray.length > 0 && this.portArray.length > portID) {
    return open(portArray[portID]);
  }
 else {
    throw new SerialException("String_Node_Str" + portID + "String_Node_Str"+ "String_Node_Str"+ serialPorts);
  }
}
Program: 117067
Project: 117067
Buggy source:
private void generateIntArray(){
  LogIt.log("String_Node_Str");
  imageAsIntArray=new int[(int)(imageAsBooleanArray.length / 8)];
  for (int i=0; i < imageAsIntArray.length; i++) {
    for (int k=0; k < 8; k++) {
      imageAsIntArray[i]+=(imageAsBooleanArray[8 * i + k] ? 1 : 0) << 7 - k;
    }
  }
}

Fixed version (ground truth):
private void generateIntArray(){
  LogIt.log("String_Node_Str");
  imageAsIntArray=new int[imageAsBooleanArray.length / 8];
  for (int i=0; i < imageAsIntArray.length; i++) {
    for (int k=0; k < 8; k++) {
      imageAsIntArray[i]+=(imageAsBooleanArray[8 * i + k] ? 1 : 0) << 7 - k;
    }
  }
}
Program: 117068
Project: 117068
Buggy source:
/** 
 * Initializes the ImageWrapper. This populates the internal structures with the data created from the original image. It is normally called by the constructor, but if for any reason you change the image contents (for example, if you resize the image), it must be initialized again prior to calling getImageCommand()
 */
private final void init(){
  LogIt.log("String_Node_Str");
  generateBlackPixels();
  generateIntArray();
}

Fixed version (ground truth):
/** 
 * Initializes the ImageWrapper. This populates the internal structures with the data created from the original image. It is normally called by the constructor, but if for any reason you change the image contents (for example, if you resize the image), it must be initialized again prior to calling getImageCommand()
 */
private void init(){
  LogIt.log("String_Node_Str");
  generateBlackPixels();
  generateIntArray();
}
Program: 117070
Project: 117070
Buggy source:
/** 
 * http://android-essential-devtopics.blogspot.com/2013/02/sending-bit-image-to-epson-printer.html
 * @author Oleg Morozov 02/21/2013 (via public domain)
 * @author Tres Finocchiaro 10/01/2013
 * @param b 
 */
private void appendEpsonSlices(ByteArrayBuilder builder){
  builder.append(new byte[]{0x1B,0x33,24});
  int offset=0;
  while (offset < getHeight()) {
    byte nL=(byte)((int)(getWidth() % 256));
    byte nH=(byte)((int)(getWidth() / 256));
    builder.append(new byte[]{0x1B,0x2A,(byte)dotDensity,nL,nH});
    for (int x=0; x < getWidth(); ++x) {
      for (int k=0; k < 3; ++k) {
        byte slice=0;
        for (int b=0; b < 8; ++b) {
          int y=(((offset / 8) + k) * 8) + b;
          int i=(y * getWidth()) + x;
          boolean v=false;
          if (i < getImageAsBooleanArray().length) {
            v=getImageAsBooleanArray()[i];
          }
          slice|=(byte)((v ? 1 : 0) << (7 - b));
        }
        builder.append(new byte[]{slice});
      }
    }
    offset+=24;
    builder.append(new byte[]{10});
  }
  builder.append(new byte[]{0x1B,0x33,30});
}

Fixed version (ground truth):
/** 
 * http://android-essential-devtopics.blogspot.com/2013/02/sending-bit-image-to-epson-printer.html
 * @param builder the ByteArrayBuilder to use
 * @author Oleg Morozov 02/21/2013 (via public domain)
 * @author Tres Finocchiaro 10/01/2013
 */
private void appendEpsonSlices(ByteArrayBuilder builder){
  builder.append(new byte[]{0x1B,0x33,24});
  int offset=0;
  while (offset < getHeight()) {
    byte nL=(byte)((int)(getWidth() % 256));
    byte nH=(byte)((int)(getWidth() / 256));
    builder.append(new byte[]{0x1B,0x2A,(byte)dotDensity,nL,nH});
    for (int x=0; x < getWidth(); ++x) {
      for (int k=0; k < 3; ++k) {
        byte slice=0;
        for (int b=0; b < 8; ++b) {
          int y=(((offset / 8) + k) * 8) + b;
          int i=(y * getWidth()) + x;
          boolean v=false;
          if (i < getImageAsBooleanArray().length) {
            v=getImageAsBooleanArray()[i];
          }
          slice|=(byte)((v ? 1 : 0) << (7 - b));
        }
        builder.append(new byte[]{slice});
      }
    }
    offset+=24;
    builder.append(new byte[]{10});
  }
  builder.append(new byte[]{0x1B,0x33,30});
}
Program: 117071
Project: 117071
Buggy source:
/** 
 * Convenience method for append(byte[]) combined with a String of specified charset
 * @param s
 * @param c
 * @return
 * @throws UnsupportedEncodingException 
 */
public final ByteArrayBuilder append(StringBuilder s,Charset c) throws UnsupportedEncodingException {
  return append(s.toString(),c);
}

Fixed version (ground truth):
/** 
 * Convenience method for append(byte[]) combined with a String of specified charset
 * @param stringBuilder the StringBuilder to append
 * @param charset the Charset of the StringBuilder
 * @return this <code>ByteArrayBuilder</code>
 * @throws UnsupportedEncodingException 
 */
public final ByteArrayBuilder append(StringBuilder stringBuilder,Charset charset) throws UnsupportedEncodingException {
  return append(stringBuilder.toString(),charset);
}
Program: 117072
Project: 117072
Buggy source:
/** 
 * Convenience method for encoding data to a file. <p>As of v 2.3, if there is a error, the method will throw an java.io.IOException. <b>This is new to v2.3!</b> In earlier versions, it just returned false, but in retrospect that's a pretty poor way to handle it.</p>
 * @param dataToEncode byte array of data to encode in base64 form
 * @param filename Filename for saving encoded data
 * @throws java.io.IOException if there is an error
 * @throws NullPointerException if dataToEncode is null
 * @since 2.1
 */
public static void encodeToFile(byte[] dataToEncode,String filename) throws java.io.IOException {
  if (dataToEncode == null) {
    throw new NullPointerException("String_Node_Str");
  }
  Base64.OutputStream bos=null;
  try {
    bos=new Base64.OutputStream(new java.io.FileOutputStream(filename),Base64.ENCODE);
    bos.write(dataToEncode);
  }
 catch (  java.io.IOException e) {
    throw e;
  }
 finally {
    try {
      bos.close();
    }
 catch (    Exception e) {
    }
  }
}

Fixed version (ground truth):
/** 
 * Convenience method for encoding data to a file. <p>As of v 2.3, if there is a error, the method will throw an java.io.IOException. <b>This is new to v2.3!</b> In earlier versions, it just returned false, but in retrospect that's a pretty poor way to handle it.</p>
 * @param dataToEncode byte array of data to encode in base64 form
 * @param filename Filename for saving encoded data
 * @throws java.io.IOException if there is an error
 * @throws NullPointerException if dataToEncode is null
 * @since 2.1
 */
public static void encodeToFile(byte[] dataToEncode,String filename) throws java.io.IOException {
  if (dataToEncode == null) {
    throw new NullPointerException("String_Node_Str");
  }
  Base64.OutputStream bos=null;
  try {
    bos=new Base64.OutputStream(new java.io.FileOutputStream(filename),Base64.ENCODE);
    bos.write(dataToEncode);
  }
  finally {
    try {
      if (bos != null) {
        bos.close();
      }
    }
 catch (    Exception ignored) {
    }
  }
}