File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
library/src/main/java/com/loopj/android/http Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ Android Asynchronous Http Client
3
+ Copyright (c) 2011 James Smith <james@loopj.com>
4
+ http://loopj.com
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ */
18
+
19
+ package com .loopj .android .http ;
20
+
21
+ /**
22
+ * Internal class, used to make some asserts, throw AssertError if asserts fail.
23
+ */
24
+ class AssertUtils {
25
+
26
+ private AssertUtils () {
27
+ }
28
+
29
+ public static void asserts (final boolean expression , final String failedMessage ) {
30
+ if (!expression ) {
31
+ throw new AssertionError (failedMessage );
32
+ }
33
+ }
34
+ }
Original file line number Diff line number Diff line change @@ -357,7 +357,7 @@ protected void sendMessage(Message msg) {
357
357
if (getUseSynchronousMode () || handler == null ) {
358
358
handleMessage (msg );
359
359
} else if (!Thread .currentThread ().isInterrupted ()) { // do not send messages if request has been cancelled
360
- assert handler != null ;
360
+ AssertUtils . asserts ( handler != null , "handler should not be null!" ) ;
361
361
handler .sendMessage (msg );
362
362
}
363
363
}
@@ -374,7 +374,7 @@ protected void postRunnable(Runnable runnable) {
374
374
runnable .run ();
375
375
} else {
376
376
// Otherwise, run on provided handler
377
- assert handler != null ;
377
+ AssertUtils . asserts ( handler != null , "handler should not be null!" ) ;
378
378
handler .post (runnable );
379
379
}
380
380
}
You can’t perform that action at this time.
0 commit comments