Browse Source

Fixed some potential NPEs

git-svn-id: http://svn.dmdirc.com/trunk@2424 00569f92-eb28-0410-84fd-f71c24880f
tags/0.5.5
Gregory Holmes 17 years ago
parent
commit
d42503992a

+ 17
- 17
src/com/dmdirc/actions/ActionManager.java View File

@@ -103,8 +103,8 @@ public final class ActionManager {
103 103
      * @param wrapper The wrapper to be registered
104 104
      */
105 105
     public static void registerWrapper(final ActionWrapper wrapper) {
106
-        Logger.doAssertion(wrapper != null, wrapper.getGroupName() != null,
107
-                !wrapper.getGroupName().isEmpty());
106
+        Logger.doAssertion(wrapper != null && wrapper.getGroupName() != null
107
+                 && wrapper.getGroupName().isEmpty());
108 108
         
109 109
         actionWrappers.add(wrapper);
110 110
     }
@@ -216,7 +216,7 @@ public final class ActionManager {
216 216
      * @return An ActionWrapper with the specified group name, or null
217 217
      */
218 218
     private static ActionWrapper getWrapper(final String name) {
219
-        Logger.doAssertion(name != null, !name.isEmpty());
219
+        Logger.doAssertion(name != null && !name.isEmpty());
220 220
         
221 221
         for (ActionWrapper wrapper : actionWrappers) {
222 222
             if (name.equals(wrapper.getGroupName())) {
@@ -235,7 +235,7 @@ public final class ActionManager {
235 235
      * @return True if the group is part of a wrapper, false otherwise
236 236
      */
237 237
     private static boolean isWrappedGroup(final String name) {
238
-        Logger.doAssertion(name != null, !name.isEmpty());
238
+        Logger.doAssertion(name != null && !name.isEmpty());
239 239
         
240 240
         return getWrapper(name) != null;
241 241
     }
@@ -246,7 +246,7 @@ public final class ActionManager {
246 246
      * @param dir The directory to scan.
247 247
      */
248 248
     private static void loadActions(final File dir) {
249
-        Logger.doAssertion(dir != null, dir.isDirectory());
249
+        Logger.doAssertion(dir != null && dir.isDirectory());
250 250
         
251 251
         for (File file : dir.listFiles()) {
252 252
             new Action(dir.getName(), file.getName());
@@ -324,8 +324,8 @@ public final class ActionManager {
324 324
      */
325 325
     public static void processEvent(final ActionType type,
326 326
             final StringBuffer format, final Object ... arguments) {
327
-        Logger.doAssertion(type != null, type.getType() != null,
328
-                type.getType().getArity() == arguments.length);
327
+        Logger.doAssertion(type != null &&type.getType() != null 
328
+                && type.getType().getArity() == arguments.length);
329 329
         
330 330
         PluginManager.getPluginManager().processEvent(type, format, arguments);
331 331
         
@@ -368,8 +368,8 @@ public final class ActionManager {
368 368
      * @param group The group to be created
369 369
      */
370 370
     public static void makeGroup(final String group) {
371
-        Logger.doAssertion(group != null, !group.isEmpty(),
372
-                !groups.containsKey(group));
371
+        Logger.doAssertion(group != null && !group.isEmpty()
372
+               && groups.containsKey(group));
373 373
         
374 374
         if (new File(getDirectory() + group).mkdir()) {
375 375
             groups.put(group, new ArrayList<Action>());
@@ -382,8 +382,8 @@ public final class ActionManager {
382 382
      * @param group The group to be removed
383 383
      */
384 384
     public static void removeGroup(final String group) {
385
-        Logger.doAssertion(group != null, !group.isEmpty(),
386
-                groups.containsKey(group));
385
+        Logger.doAssertion(group != null && !group.isEmpty()
386
+                && groups.containsKey(group));
387 387
         
388 388
         for (Action action : new ArrayList<Action>(groups.get(group))) {
389 389
             unregisterAction(action);
@@ -415,9 +415,9 @@ public final class ActionManager {
415 415
      * @param newName The new name of the group
416 416
      */
417 417
     public static void renameGroup(final String oldName, final String newName) {
418
-        Logger.doAssertion(oldName != null, !oldName.isEmpty(),
419
-                newName != null, !newName.isEmpty(), groups.containsKey(oldName),
420
-                !groups.containsKey(newName), !newName.equals(oldName));
418
+        Logger.doAssertion(oldName != null && !oldName.isEmpty()
419
+                && newName != null && !newName.isEmpty() && groups.containsKey(oldName)
420
+                &&!groups.containsKey(newName) && !newName.equals(oldName));
421 421
         
422 422
         makeGroup(newName);
423 423
         
@@ -439,7 +439,7 @@ public final class ActionManager {
439 439
      * @return The actioncomparison with the specified name, or null on failure
440 440
      */
441 441
     public static ActionType getActionType(final String type) {
442
-        Logger.doAssertion(type != null, !type.isEmpty());
442
+        Logger.doAssertion(type != null && !type.isEmpty());
443 443
         
444 444
         for (ActionType target : actionTypes) {
445 445
             if (((Enum) target).name().equals(type)) {
@@ -536,7 +536,7 @@ public final class ActionManager {
536 536
      * @return The actioncomponent with the specified name, or null on failure
537 537
      */
538 538
     public static ActionComponent getActionComponent(final String type) {
539
-        Logger.doAssertion(type != null, !type.isEmpty());
539
+        Logger.doAssertion(type != null && !type.isEmpty());
540 540
         
541 541
         for (ActionComponent target : actionComponents) {
542 542
             if (((Enum) target).name().equals(type)) {
@@ -555,7 +555,7 @@ public final class ActionManager {
555 555
      * @return The actiontype with the specified name, or null on failure
556 556
      */
557 557
     public static ActionComparison getActionComparison(final String type) {
558
-        Logger.doAssertion(type != null, !type.isEmpty());
558
+        Logger.doAssertion(type != null && !type.isEmpty());
559 559
         
560 560
         for (ActionComparison target : actionComparisons) {
561 561
             if (((Enum) target).name().equals(type)) {

+ 3
- 1
src/com/dmdirc/commandparser/commands/global/Debug.java View File

@@ -33,6 +33,7 @@ import com.dmdirc.logger.Logger;
33 33
 import com.dmdirc.ui.input.AdditionalTabTargets;
34 34
 import com.dmdirc.ui.interfaces.InputWindow;
35 35
 import com.dmdirc.updater.UpdateChecker;
36
+import java.io.Serializable;
36 37
 import java.util.Comparator;
37 38
 
38 39
 import java.util.List;
@@ -279,7 +280,8 @@ public class Debug extends GlobalCommand implements IntelligentCommand {
279 280
     }
280 281
     
281 282
     /** Reverse value comparator for a map entry. */
282
-    private static class ValueComparator implements Comparator<Entry<String, Integer>> {
283
+    private static class ValueComparator implements 
284
+            Comparator<Entry<String, Integer>>, Serializable {
283 285
         
284 286
         /** Instantiates a new ValueComparator. */
285 287
         public ValueComparator() {

+ 1
- 1
src/com/dmdirc/config/Identity.java View File

@@ -232,7 +232,7 @@ public class Identity implements Serializable, Comparable<Identity> {
232 232
             final String value) {
233 233
         final String oldValue = getOption(domain, option);
234 234
         
235
-        if ((oldValue == null && value != null) || !oldValue.equals(value)) {
235
+        if ((oldValue == null && value != null) || (oldValue != null && !oldValue.equals(value))) {
236 236
             properties.setProperty(domain + "." + option, value);
237 237
             needSave = true;
238 238
             

+ 4
- 3
src/com/dmdirc/config/IdentityManager.java View File

@@ -182,7 +182,7 @@ public final class IdentityManager {
182 182
      * @param identity The identity to be removed
183 183
      */
184 184
     public static void removeIdentity(final Identity identity) {
185
-        Logger.doAssertion(identity != null, identities.contains(identity));
185
+        Logger.doAssertion(identity != null && identities.contains(identity));
186 186
         
187 187
         identities.remove(identity);
188 188
     }
@@ -296,7 +296,8 @@ public final class IdentityManager {
296 296
      */
297 297
     public static Identity getChannelConfig(final String network,
298 298
             final String channel) {
299
-        Logger.doAssertion(network != null, channel != null, !network.isEmpty(), !channel.isEmpty());
299
+        Logger.doAssertion(network != null && !network.isEmpty()
300
+               && channel != null && !channel.isEmpty());
300 301
         
301 302
         final String myTarget = (channel + "@" + network).toLowerCase();
302 303
         
@@ -321,7 +322,7 @@ public final class IdentityManager {
321 322
      * @return A config source for the network
322 323
      */
323 324
     public static Identity getNetworkConfig(final String network) {
324
-        Logger.doAssertion(network != null, !network.isEmpty());
325
+        Logger.doAssertion(network != null && !network.isEmpty());
325 326
         
326 327
         final String myTarget = network.toLowerCase();
327 328
         

Loading…
Cancel
Save