forked from External/mage
Blocker and Critical level bugfixes throughout the project (#4648)
* fixed https://sonarcloud.io/project/issues?id=org.xmage%3Amage-root&issues=AWIlv32RgrzAwlaaQ7rP&open=AWIlv32RgrzAwlaaQ7rP * ensure closing of scanner if it was opened * Refactored method in EmpyrialArchAngel to not always return same value. * Refactored method in FalkenrathAristocrat to not always return same value. * Refactored method in GilderBairn to not always return the same value. * fixed left open resources, ensured quiet closing of the streams * Refactored method in IceCave to not always return same value. * Refactored method in KjeldoranRoyalGuard to not always return same value. * Refactored method in LegionsInitiative to not always return same value. * Refactored method in NaturesWill to not always return same value. * added quiet closing method in new streamutils class, used to clean up the connectdialog * Fix small typo * added quiet closing to saveobjectutil * closed resources in savegame method of gamecontroller * properly close resources in loadGame method of GameReplay class * further proper resource closing in ServerMessagesUtil * fixed unclosed resources in copy method in mage framework Copier * closed unclosed resources in copyCompressed method in Copier * ensure closing of filewriter in manasymbols * ensure proper closing of Stream in arcane UI * ensure closing of datagram socket in arcane Util * ensure resource closing in deckimport from clipboard * ensure closing of plugin classloader * ensured closing of zipinputstream resource * ensure closing of fileoutputstream in ScryfallSymbolsSource * ensure closing resources after finishing/canceling download of pictures * remove commented code * move locks to try block to ensure unlocking along all execution paths * remove dangerous instance of double-checked locking * removed dangerous instance of double checked locking in settingsmanager * Removed dangerous instance of double-checked locking in ThemePluginImpl * close resource which did not happen certainly * close another stream * ensure closing of inputstream
This commit is contained in:
parent
ec77cecbf6
commit
5ac975c52e
31 changed files with 288 additions and 276 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;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package mage.client.deckeditor;
|
||||
|
||||
import mage.util.StreamUtils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.BufferedWriter;
|
||||
|
|
@ -39,15 +41,16 @@ public class DeckImportFromClipboardDialog extends JDialog {
|
|||
}
|
||||
|
||||
private void onOK() {
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
File temp = File.createTempFile("cbimportdeck", ".txt");
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(temp));
|
||||
bw = new BufferedWriter(new FileWriter(temp));
|
||||
bw.write(txtDeckList.getText());
|
||||
bw.close();
|
||||
|
||||
tmpPath = temp.getPath();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
StreamUtils.closeQuietly(bw);
|
||||
}
|
||||
|
||||
dispose();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -45,16 +45,12 @@ public class ArrowBuilder {
|
|||
* Get the panel where all arrows are being drawn.
|
||||
* @return
|
||||
*/
|
||||
public JPanel getArrowsManagerPanel() {
|
||||
public synchronized JPanel getArrowsManagerPanel() {
|
||||
if (arrowsManagerPanel == null) {
|
||||
synchronized (ArrowBuilder.class) {
|
||||
if (arrowsManagerPanel == null) {
|
||||
arrowsManagerPanel = new JPanel();
|
||||
arrowsManagerPanel.setVisible(true);
|
||||
arrowsManagerPanel.setOpaque(false);
|
||||
arrowsManagerPanel.setLayout(null);
|
||||
}
|
||||
}
|
||||
arrowsManagerPanel = new JPanel();
|
||||
arrowsManagerPanel.setVisible(true);
|
||||
arrowsManagerPanel.setOpaque(false);
|
||||
arrowsManagerPanel.setLayout(null);
|
||||
}
|
||||
return arrowsManagerPanel;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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