Browse Source

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 years ago
parent
commit
8113ca52a7
1 changed files with 5 additions and 6 deletions
  1. 5
    6
      dcc/src/com/dmdirc/addons/dcc/TransferContainer.java

+ 5
- 6
dcc/src/com/dmdirc/addons/dcc/TransferContainer.java View File

100
         myPlugin = plugin;
100
         myPlugin = plugin;
101
 
101
 
102
         if (parser != null) {
102
         if (parser != null) {
103
-            parser.getCallbackManager().addNonCriticalCallback(
104
-                    SocketCloseListener.class, this);
103
+            parser.getCallbackManager().addCallback(SocketCloseListener.class, this);
105
         }
104
         }
106
         dcc.addHandler(this);
105
         dcc.addHandler(this);
107
 
106
 
178
      * @return The percentage of this transfer that has been completed
177
      * @return The percentage of this transfer that has been completed
179
      */
178
      */
180
     public double getPercent() {
179
     public double getPercent() {
181
-        return (100.00 / dcc.getFileSize()) * (transferCount
180
+        return 100.00 / dcc.getFileSize() * (transferCount
182
                 + dcc.getFileStart());
181
                 + dcc.getFileStart());
183
     }
182
     }
184
 
183
 
192
         final long time = getElapsedTime();
191
         final long time = getElapsedTime();
193
 
192
 
194
         synchronized (this) {
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
                     - transferCount;
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
     public void addSocketCloseCallback(final SocketCloseListener listener) {
349
     public void addSocketCloseCallback(final SocketCloseListener listener) {
351
         if (connection != null) {
350
         if (connection != null) {
352
             connection.getParser().map(Parser::getCallbackManager).ifPresent(
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…
Cancel
Save