Program: 157720
Project: 157720
Buggy source:
private void findPublicServerActionPerformed(java.awt.event.ActionEvent evt){
  BufferedReader in=null;
  try {
    String serverUrl=PreferencesDialog.getCachedValue(KEY_CONNECTION_URL_SERVER_LIST,"String_Node_Str");
    if (serverUrl.contains("String_Node_Str")) {
      serverUrl=serverUrl.replace("String_Node_Str","String_Node_Str");
      PreferencesDialog.saveValue(KEY_CONNECTION_URL_SERVER_LIST,serverUrl);
    }
    URL serverListURL=new URL(serverUrl);
    Connection.ProxyType configProxyType=Connection.ProxyType.valueByText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_TYPE,"String_Node_Str"));
    Proxy p=null;
    Proxy.Type type=Proxy.Type.DIRECT;
switch (configProxyType) {
case HTTP:
      type=Proxy.Type.HTTP;
    break;
case SOCKS:
  type=Proxy.Type.SOCKS;
break;
case NONE:
default :
p=Proxy.NO_PROXY;
break;
}
if (p == null || !p.equals(Proxy.NO_PROXY)) {
try {
String address=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_ADDRESS,"String_Node_Str");
Integer port=Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_PORT,"String_Node_Str"));
p=new Proxy(type,new InetSocketAddress(address,port));
}
 catch (Exception ex) {
throw new RuntimeException("String_Node_Str" + ex);
}
}
if (p == null) {
JOptionPane.showMessageDialog(null,"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
return;
}
boolean URLNotFound=false;
try {
in=new BufferedReader(new InputStreamReader(serverListURL.openConnection(p).getInputStream()));
}
 catch (SocketTimeoutException|FileNotFoundException|UnknownHostException ex) {
logger.warn("String_Node_Str" + serverListURL.toString());
File f=new File("String_Node_Str");
if (f.exists() && !f.isDirectory()) {
logger.info("String_Node_Str");
URLNotFound=true;
in=new BufferedReader(new FileReader("String_Node_Str"));
}
}
List<String> servers=new ArrayList<>();
if (in != null) {
Writer output=null;
if (!URLNotFound) {
File file=new File("String_Node_Str");
if (file.exists() && !file.isDirectory()) {
file.delete();
}
output=new BufferedWriter(new FileWriter(file));
}
String inputLine;
while ((inputLine=in.readLine()) != null) {
logger.debug("String_Node_Str" + inputLine);
servers.add(inputLine);
if (output != null) {
output.append(inputLine).append('\n');
}
}
if (output != null) {
output.close();
}
in.close();
}
if (servers.isEmpty()) {
JOptionPane.showMessageDialog(null,"String_Node_Str");
return;
}
String selectedServer=(String)JOptionPane.showInputDialog(null,"String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null,servers.toArray(),servers.get(0));
if (selectedServer != null) {
String[] params=selectedServer.split("String_Node_Str");
if (params.length == 3) {
String serverAddress=params[1];
this.txtServer.setText(serverAddress);
this.txtPort.setText(params[2]);
this.txtUserName.setText(MagePreferences.getUserName(serverAddress));
this.txtPassword.setText(MagePreferences.getPassword(serverAddress));
}
 else {
JOptionPane.showMessageDialog(null,"String_Node_Str");
}
}
}
 catch (Exception ex) {
logger.error(ex,ex);
}
 finally {
if (in != null) {
try {
in.close();
}
 catch (Exception e) {
}
}
}
}

Fixed version (ground truth):
private void findPublicServerActionPerformed(java.awt.event.ActionEvent evt){
  BufferedReader in=null;
  Writer output=null;
  try {
    String serverUrl=PreferencesDialog.getCachedValue(KEY_CONNECTION_URL_SERVER_LIST,"String_Node_Str");
    if (serverUrl.contains("String_Node_Str")) {
      serverUrl=serverUrl.replace("String_Node_Str","String_Node_Str");
      PreferencesDialog.saveValue(KEY_CONNECTION_URL_SERVER_LIST,serverUrl);
    }
    URL serverListURL=new URL(serverUrl);
    Connection.ProxyType configProxyType=Connection.ProxyType.valueByText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_TYPE,"String_Node_Str"));
    Proxy p=null;
    Proxy.Type type=Proxy.Type.DIRECT;
switch (configProxyType) {
case HTTP:
      type=Proxy.Type.HTTP;
    break;
case SOCKS:
  type=Proxy.Type.SOCKS;
break;
case NONE:
default :
p=Proxy.NO_PROXY;
break;
}
if (p == null || !p.equals(Proxy.NO_PROXY)) {
try {
String address=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_ADDRESS,"String_Node_Str");
Integer port=Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_PORT,"String_Node_Str"));
p=new Proxy(type,new InetSocketAddress(address,port));
}
 catch (Exception ex) {
throw new RuntimeException("String_Node_Str" + ex);
}
}
if (p == null) {
JOptionPane.showMessageDialog(null,"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
return;
}
boolean URLNotFound=false;
try {
in=new BufferedReader(new InputStreamReader(serverListURL.openConnection(p).getInputStream()));
}
 catch (SocketTimeoutException|FileNotFoundException|UnknownHostException ex) {
logger.warn("String_Node_Str" + serverListURL.toString());
File f=new File("String_Node_Str");
if (f.exists() && !f.isDirectory()) {
logger.info("String_Node_Str");
URLNotFound=true;
in=new BufferedReader(new FileReader("String_Node_Str"));
}
}
List<String> servers=new ArrayList<>();
if (in != null) {
if (!URLNotFound) {
File file=new File("String_Node_Str");
if (file.exists() && !file.isDirectory()) {
file.delete();
}
output=new BufferedWriter(new FileWriter(file));
}
String inputLine;
while ((inputLine=in.readLine()) != null) {
logger.debug("String_Node_Str" + inputLine);
servers.add(inputLine);
if (output != null) {
output.append(inputLine).append('\n');
}
}
}
if (servers.isEmpty()) {
JOptionPane.showMessageDialog(null,"String_Node_Str");
return;
}
String selectedServer=(String)JOptionPane.showInputDialog(null,"String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null,servers.toArray(),servers.get(0));
if (selectedServer != null) {
String[] params=selectedServer.split("String_Node_Str");
if (params.length == 3) {
String serverAddress=params[1];
this.txtServer.setText(serverAddress);
this.txtPort.setText(params[2]);
this.txtUserName.setText(MagePreferences.getUserName(serverAddress));
this.txtPassword.setText(MagePreferences.getPassword(serverAddress));
}
 else {
JOptionPane.showMessageDialog(null,"String_Node_Str");
}
}
}
 catch (Exception ex) {
logger.error(ex,ex);
}
 finally {
StreamUtils.closeQuietly(in);
StreamUtils.closeQuietly(output);
}
}