mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
Merge branches 'hotfix/close-unclosed-resources-mage-client', 'hotfix/close-streams-in-updater', 'hotfix/fix-non-closed-scanner' and 'hotfix/manapiechart-potential-zero-division' into feature/SonarqubeFixes
This commit is contained in:
commit
4bc5a9bd61
6 changed files with 61 additions and 19 deletions
|
|
@ -67,6 +67,10 @@ public class ManaPieChart extends JComponent {
|
|||
for (int i = 0; i < slices.length; i++) {
|
||||
total += slices[i].value;
|
||||
}
|
||||
|
||||
if (total == 0.0D) {
|
||||
return; //there are no slices or no slices with a value > 0, stop here
|
||||
}
|
||||
|
||||
double curValue = 0.0D;
|
||||
int startAngle = 0;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import java.io.FileReader;
|
|||
import java.io.FileWriter;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Writer;
|
||||
import java.io.Closeable;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.SocketException;
|
||||
|
|
@ -73,6 +74,7 @@ import mage.client.util.Config;
|
|||
import mage.client.util.gui.countryBox.CountryItemEditor;
|
||||
import mage.client.util.sets.ConstructedFormats;
|
||||
import mage.remote.Connection;
|
||||
import mage.utils.StreamUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -565,6 +567,7 @@ public class ConnectDialog extends MageDialog {
|
|||
|
||||
private void findPublicServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
BufferedReader in = null;
|
||||
Writer output = null;
|
||||
try {
|
||||
String serverUrl = PreferencesDialog.getCachedValue(KEY_CONNECTION_URL_SERVER_LIST, "http://xmage.de/files/server-list.txt");
|
||||
if (serverUrl.contains("xmage.info/files/")) {
|
||||
|
|
@ -618,7 +621,7 @@ public class ConnectDialog extends MageDialog {
|
|||
}
|
||||
List<String> servers = new ArrayList<>();
|
||||
if (in != null) {
|
||||
Writer output = null;
|
||||
|
||||
if (!URLNotFound) {
|
||||
// write serverlist to be able to read if URL is not available
|
||||
File file = new File("serverlist.txt");
|
||||
|
|
@ -637,10 +640,6 @@ public class ConnectDialog extends MageDialog {
|
|||
|
||||
}
|
||||
}
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
if (servers.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(null, "Couldn't find any server.");
|
||||
|
|
@ -668,15 +667,12 @@ public class ConnectDialog extends MageDialog {
|
|||
} catch (Exception ex) {
|
||||
logger.error(ex, ex);
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
StreamUtils.closeQuietly(in);
|
||||
StreamUtils.closeQuietly(output);
|
||||
}
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
|
||||
private void jProxySettingsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jProxySettingsButtonActionPerformed
|
||||
PreferencesDialog.main(new String[]{PreferencesDialog.OPEN_CONNECTION_TAB});
|
||||
}//GEN-LAST:event_jProxySettingsButtonActionPerformed
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package mage.client.util.object;
|
||||
|
||||
import mage.utils.StreamUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
|
|
@ -61,10 +63,9 @@ public final class SaveObjectUtil {
|
|||
oos.writeObject(object);
|
||||
oos.close();
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
return;
|
||||
} catch (IOException io) {
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
} finally {
|
||||
StreamUtils.closeQuietly(oos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue