Просмотр исходного кода

Various bits of tidying up.

Change-Id: I08c0f6fc74d448051145807275426395629f50be
Reviewed-on: http://gerrit.dmdirc.com/3686
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
pull/1/head
Chris Smith 9 лет назад
Родитель
Сommit
29700a0fea

+ 1
- 0
.gitignore Просмотреть файл

@@ -43,3 +43,4 @@ __history
43 43
 /*.key
44 44
 /teamcity-info.xml
45 45
 /.idea/workspace.xml
46
+/.idea/uiDesigner.xml

+ 1
- 1
src/com/dmdirc/actions/ActionManager.java Просмотреть файл

@@ -378,7 +378,7 @@ public class ActionManager implements ActionController {
378 378
         }
379 379
 
380 380
         if (!killSwitch) {
381
-            res |= triggerActions(type, format, arguments);
381
+            res = triggerActions(type, format, arguments);
382 382
         }
383 383
 
384 384
         return !res;

+ 2
- 2
src/com/dmdirc/actions/ActionModel.java Просмотреть файл

@@ -252,7 +252,7 @@ public class ActionModel {
252 252
      * @return The triggers used by this action
253 253
      */
254 254
     public ActionType[] getTriggers() {
255
-        return triggers == null ? triggers : triggers.clone();
255
+        return triggers == null ? null : triggers.clone();
256 256
     }
257 257
 
258 258
     /**
@@ -290,7 +290,7 @@ public class ActionModel {
290 290
      * @return The commands that will be executed if this action is triggered
291 291
      */
292 292
     public String[] getResponse() {
293
-        return response == null ? response : response.clone();
293
+        return response == null ? null : response.clone();
294 294
     }
295 295
 
296 296
     /**

+ 7
- 3
src/com/dmdirc/commandparser/aliases/ActionAliasMigrator.java Просмотреть файл

@@ -34,6 +34,7 @@ import java.io.File;
34 34
 import java.io.IOException;
35 35
 import java.util.Map;
36 36
 
37
+import javax.annotation.Nullable;
37 38
 import javax.inject.Inject;
38 39
 import javax.inject.Singleton;
39 40
 
@@ -71,9 +72,12 @@ public class ActionAliasMigrator implements Migrator {
71 72
 
72 73
     @Override
73 74
     public void migrate() {
74
-        for (File child : directory.listFiles()) {
75
-            if (migrate(child)) {
76
-                child.delete();
75
+        @Nullable final File[] files = directory.listFiles();
76
+        if (files != null) {
77
+            for (File child : files) {
78
+                if (migrate(child)) {
79
+                    child.delete();
80
+                }
77 81
             }
78 82
         }
79 83
         directory.delete();

+ 2
- 2
src/com/dmdirc/commandparser/commands/flags/CommandFlagResult.java Просмотреть файл

@@ -69,8 +69,8 @@ public class CommandFlagResult {
69 69
      * @see #getArguments(com.dmdirc.commandparser.commands.flags.CommandFlag)
70 70
      */
71 71
     public String getArgumentsAsString(final CommandFlag flag) {
72
-        return flag == null ? (offsets.get(flag) > arguments.getArguments().length
73
-                ? "" : arguments.getArgumentsAsString(offsets.get(flag)))
72
+        return flag == null ? (offsets.get(null) > arguments.getArguments().length
73
+                ? "" : arguments.getArgumentsAsString(offsets.get(null)))
74 74
                 : arguments.getArgumentsAsString(offsets.get(flag),
75 75
                         offsets.get(flag) + flag.getDelayedArgs() + flag.getImmediateArgs() - 1);
76 76
     }

+ 1
- 2
src/com/dmdirc/plugins/PluginClassLoader.java Просмотреть файл

@@ -151,8 +151,7 @@ public class PluginClassLoader extends ClassLoader {
151 151
         }
152 152
 
153 153
         // We are meant to be loading this one!
154
-        byte[] data = null;
155
-
154
+        byte[] data;
156 155
         if (res.resourceExists(fileName)) {
157 156
             data = res.getResourceBytes(fileName);
158 157
         } else {

+ 1
- 14
src/com/dmdirc/updater/components/PluginComponent.java Просмотреть файл

@@ -29,7 +29,6 @@ import com.dmdirc.updater.Version;
29 29
 
30 30
 import java.io.File;
31 31
 import java.io.IOException;
32
-import java.util.zip.ZipException;
33 32
 import java.util.zip.ZipFile;
34 33
 
35 34
 /**
@@ -140,22 +139,10 @@ public class PluginComponent implements UpdateComponent {
140 139
      * @return true if the file is valid
141 140
      */
142 141
     private boolean isValid(final File file) {
143
-        ZipFile zipfile = null;
144
-        try {
145
-            zipfile = new ZipFile(file);
142
+        try (ZipFile ignored = new ZipFile(file)) {
146 143
             return true;
147
-        } catch (ZipException e) {
148
-            return false;
149 144
         } catch (IOException e) {
150 145
             return false;
151
-        } finally {
152
-            try {
153
-                if (zipfile != null) {
154
-                    zipfile.close();
155
-                    zipfile = null;
156
-                }
157
-            } catch (IOException e) {
158
-            }
159 146
         }
160 147
     }
161 148
 

Загрузка…
Отмена
Сохранить