瀏覽代碼

Don't use addNonCriticalCallback.

All this does is suppress a runtime exception that should never
occur in these cases.

If a callback isn't found then it's a serious error and should
be handled properly, not squelshed.
pull/210/head
Chris Smith 9 年之前
父節點
當前提交
8113ca52a7
共有 1 個文件被更改,包括 5 次插入6 次删除
  1. 5
    6
      dcc/src/com/dmdirc/addons/dcc/TransferContainer.java

+ 5
- 6
dcc/src/com/dmdirc/addons/dcc/TransferContainer.java 查看文件

@@ -100,8 +100,7 @@ public class TransferContainer extends FrameContainer implements
100 100
         myPlugin = plugin;
101 101
 
102 102
         if (parser != null) {
103
-            parser.getCallbackManager().addNonCriticalCallback(
104
-                    SocketCloseListener.class, this);
103
+            parser.getCallbackManager().addCallback(SocketCloseListener.class, this);
105 104
         }
106 105
         dcc.addHandler(this);
107 106
 
@@ -178,7 +177,7 @@ public class TransferContainer extends FrameContainer implements
178 177
      * @return The percentage of this transfer that has been completed
179 178
      */
180 179
     public double getPercent() {
181
-        return (100.00 / dcc.getFileSize()) * (transferCount
180
+        return 100.00 / dcc.getFileSize() * (transferCount
182 181
                 + dcc.getFileStart());
183 182
     }
184 183
 
@@ -192,7 +191,7 @@ public class TransferContainer extends FrameContainer implements
192 191
         final long time = getElapsedTime();
193 192
 
194 193
         synchronized (this) {
195
-            return time > 0 ? ((double) transferCount / time) : transferCount;
194
+            return time > 0 ? (double) transferCount / time : transferCount;
196 195
         }
197 196
     }
198 197
 
@@ -211,7 +210,7 @@ public class TransferContainer extends FrameContainer implements
211 210
                     - transferCount;
212 211
         }
213 212
 
214
-        return bytesPerSecond > 0 ? (remainingBytes / bytesPerSecond) : 1;
213
+        return bytesPerSecond > 0 ? remainingBytes / bytesPerSecond : 1;
215 214
     }
216 215
 
217 216
     /**
@@ -350,7 +349,7 @@ public class TransferContainer extends FrameContainer implements
350 349
     public void addSocketCloseCallback(final SocketCloseListener listener) {
351 350
         if (connection != null) {
352 351
             connection.getParser().map(Parser::getCallbackManager).ifPresent(
353
-                    cbm -> cbm.addNonCriticalCallback(SocketCloseListener.class, listener));
352
+                    cbm -> cbm.addCallback(SocketCloseListener.class, listener));
354 353
         }
355 354
     }
356 355
 

Loading…
取消
儲存