diff --git a/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java b/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java index 247c69b..b872719 100644 --- a/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java +++ b/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java @@ -609,6 +609,7 @@ public class AutoExtract implements ActionListener { } catch (IOException e) { e.printStackTrace(); } finally { + if(out!=null) out.close(); if (file != null) { if (!file.delete()) { diff --git a/代码/workspace_robo4/robocode.repository/src/main/java/net/sf/robocode/repository/root/BaseRoot.java b/代码/workspace_robo4/robocode.repository/src/main/java/net/sf/robocode/repository/root/BaseRoot.java index 14b6c89..6221701 100644 --- a/代码/workspace_robo4/robocode.repository/src/main/java/net/sf/robocode/repository/root/BaseRoot.java +++ b/代码/workspace_robo4/robocode.repository/src/main/java/net/sf/robocode/repository/root/BaseRoot.java @@ -61,7 +61,7 @@ public abstract class BaseRoot implements Serializable, IRepositoryRoot { public void extractJAR() { throw new UnsupportedOperationException(); } - + @Override public boolean equals(Object obj) { if (obj instanceof IRepositoryRoot) { return ((IRepositoryRoot) obj).getURL().equals(rootURL); diff --git a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/BattlesRunner.java b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/BattlesRunner.java index 13cbd64..78a2c22 100644 --- a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/BattlesRunner.java +++ b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/BattlesRunner.java @@ -109,7 +109,7 @@ public class BattlesRunner { lastResults = null; engine.runBattle(specification, true); - if (lastResults != null && lastResults.length > 1) { + if (lastResults.length > 1) { dumpResults(outtxt, lastResults, param[param.length - 1], melee); } } @@ -157,11 +157,10 @@ public class BattlesRunner { try { FileReader fr = new FileReader(inputfile); br = new BufferedReader(fr); - + fr.close(); String record; while ((record = br.readLine()) != null) { robots.add(record); - fr.close(); } } catch (IOException e) { System.out.println("Battles input file not found ... Aborting"); diff --git a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/PrepareBattles.java b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/PrepareBattles.java index a2a30ca..5043562 100644 --- a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/PrepareBattles.java +++ b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/PrepareBattles.java @@ -425,6 +425,7 @@ public class PrepareBattles { } } } + fr.close(); } catch (IOException e) { System.out.println("Participants file not found ... Aborting"); System.out.println(e); diff --git a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/BotsDownload.java b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/BotsDownload.java index d29b50b..78d5920 100644 --- a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/BotsDownload.java +++ b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/BotsDownload.java @@ -392,7 +392,7 @@ public class BotsDownload { InputStream properties = jarf.getInputStream(zipe); Properties parameters = getProperties(properties); - + jarf.close(); if (!isteams.equals("YES")) { String classname = parameters.getProperty("robot.classname", ""); String version = parameters.getProperty("robot.version", ""); @@ -402,7 +402,7 @@ public class BotsDownload { String version = parameters.getProperty("team.version", ""); return (botname.equals(botname.substring(0, botname.indexOf(" ")) + " " + version)); - jarf.close(); + } catch (Exception e) { System.out.println(e); return false; diff --git a/代码/workspace_robo4/robocode.tests/src/test/java/net/sf/robocode/test/core/util/AlphanumericComparatorTest.java b/代码/workspace_robo4/robocode.tests/src/test/java/net/sf/robocode/test/core/util/AlphanumericComparatorTest.java index 255fbd2..828ded7 100644 --- a/代码/workspace_robo4/robocode.tests/src/test/java/net/sf/robocode/test/core/util/AlphanumericComparatorTest.java +++ b/代码/workspace_robo4/robocode.tests/src/test/java/net/sf/robocode/test/core/util/AlphanumericComparatorTest.java @@ -50,7 +50,7 @@ public class AlphanumericComparatorTest { String str1 = unsortedStrings[i]; String str2 = correctlySortedStrings[i]; - if (!(str1 == null && str2 == null) && !str1.equals(str2)) { + if (str1!=null&&!(str1 == null && str2 == null) && !str1.equals(str2)) { sortedCorrectly = false; break; } diff --git a/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/JavaDocument.java b/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/JavaDocument.java index 7497f42..d3fd266 100644 --- a/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/JavaDocument.java +++ b/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/JavaDocument.java @@ -484,6 +484,7 @@ public class JavaDocument extends StyledDocument { spaceBuffer = new String(chars); } // Return a string containing the given number of spaces + if(spaceBuffer!=null) return spaceBuffer.substring(0, count); } diff --git a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesSoundOptionsTab.java b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesSoundOptionsTab.java index 1653e10..d642d20 100644 --- a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesSoundOptionsTab.java +++ b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesSoundOptionsTab.java @@ -227,8 +227,9 @@ public class PreferencesSoundOptionsTab extends WizardPanel { for (Mixer.Info mi : mixerInfo) { if (AudioSystem.getMixer(mi).getSourceLineInfo(clipLineInfo).length > 0) { mixers.add(mi); + AudioSystem.getMixer(mi).close(); } - AudioSystem.getMixer(mi).close(); + } mixerComboBox = new JComboBox(mixers); @@ -297,9 +298,8 @@ public class PreferencesSoundOptionsTab extends WizardPanel { if (mixerInfo != null) { Mixer mixer = AudioSystem.getMixer((Mixer.Info) getMixerComboBox().getSelectedItem()); - if (mixer != null) { mixerClassName = mixer.getClass().getSimpleName(); - } + } if (mixerClassName != null) { props.setOptionsSoundMixer(mixerClassName); @@ -317,9 +317,10 @@ public class PreferencesSoundOptionsTab extends WizardPanel { for (Mixer.Info mi : AudioSystem.getMixerInfo()) { if (AudioSystem.getMixer(mi).getClass().getSimpleName().equals(mixerName)) { getMixerComboBox().setSelectedItem(mi); + AudioSystem.getMixer(mi).close(); break; } - AudioSystem.getMixer(mi).close(); + } }