Skip to content

Commit 84e5170

Browse files
Koushik DuttaKoushik Dutta
Koushik Dutta
authored and
Koushik Dutta
committed
Merge branch 'master' of ssh://github.com/koush/AndroidAsync
2 parents fa0eec4 + b29c67f commit 84e5170

28 files changed

+134
-62
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: koush
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

AndroidAsync/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.koushikdutta.async"
3-
android:versionCode="308"
4-
android:versionName="3.0.9">
3+
android:versionCode="310"
4+
android:versionName="3.1.0">
55

66
<uses-permission android:name="android.permission.INTERNET"/>
77

AndroidAsync/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,4 @@ android {
5050
}
5151
}
5252

53-
if (false && System.getenv().I_AM_KOUSH == 'true') {
54-
apply from: 'https://raw.githubusercontent.com/koush/mvn-repo/master/maven.gradle'
55-
}
53+
apply from: 'maven.gradle'

AndroidAsync/maven.gradle

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
// Setup
2+
3+
// 0) Setup your sonatype credentials by editing/creating ~/.gradle/gradle.properties and enter:
4+
// signing.keyId=<HEXADECIMCAL KEY ID RETRIVABLE VIA gpg --list-keys>
5+
// signing.password=<KEY PASSWORD>
6+
// signing.secretKeyRingFile=<PATH TO KEY RING, USUALLY ~/.gnupg/secring.gpg>
7+
// sonatypeUsername=<SONATYPE USERNAME OR WHATEVER YOU USE>
8+
// sonatypePassword=<CORRESPONDING PASSWORD>
9+
10+
// 1) Setup your build.gradle for your android project and add this one line of code which imports this gist:
11+
// apply from: 'https://raw.github.com/koush/mvn-repo/master/maven.gradle'
12+
13+
// 2) gradle clean && gradle build && gradle uploadArchives
14+
15+
// 3) That's it!
16+
17+
18+
apply plugin: 'maven'
19+
apply plugin: 'signing'
20+
21+
22+
afterEvaluate { project ->
23+
String user = null
24+
String repo = null
25+
'git remote -v'.execute(null, project.projectDir).getText().find('.*[email protected]/(.*?)/(.*?) .*?') {
26+
match ->
27+
user = match[1]
28+
repo = match[2]
29+
}
30+
31+
String githubUrl = 'https://api.github.com/repos/' + user + '/' + repo;
32+
if (System.getenv().GITHUB_TOKEN)
33+
githubUrl += '?access_token=' + System.getenv().GITHUB_TOKEN
34+
def repoInfo = new groovy.json.JsonSlurper().parseText(new URL(githubUrl).getText())
35+
36+
def android_manifest
37+
try {
38+
android_manifest = new XmlParser(false, false).parseText(new File(project.projectDir, 'AndroidManifest.xml').getText())
39+
}
40+
catch (e) {
41+
android_manifest = new XmlParser(false, false).parseText(new File(project.projectDir, 'src/main/AndroidManifest.xml').getText())
42+
}
43+
def versionName = android_manifest.'@android:versionName'
44+
def package_name = android_manifest.'@package'
45+
def artifact_id = project.projectDir.getName().toLowerCase()
46+
project.version = versionName
47+
project.group = package_name
48+
49+
uploadArchives {
50+
repositories {
51+
mavenDeployer {
52+
53+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
54+
pom.groupId = package_name
55+
pom.artifactId = artifact_id
56+
pom.version = versionName
57+
58+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
59+
authentication(userName: sonatypeUsername, password: sonatypePassword)
60+
}
61+
62+
pom.project {
63+
name repo
64+
packaging 'jar'
65+
description repoInfo.description
66+
url repoInfo.html_url
67+
68+
scm {
69+
url repoInfo.git_url
70+
connection repoInfo.git_url
71+
developerConnection repoInfo.ssh_url
72+
}
73+
74+
licenses {
75+
license {
76+
name 'The Apache Software License, Version 2.0'
77+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
78+
distribution 'repo'
79+
}
80+
}
81+
82+
developers {
83+
developer {
84+
id user
85+
name user
86+
}
87+
}
88+
}
89+
}
90+
}
91+
}
92+
93+
signing {
94+
sign configurations.archives
95+
}
96+
97+
task androidJavadocs(type: Javadoc) {
98+
source = android.sourceSets.main.java.srcDirs
99+
}
100+
101+
task androidJavadocsJar(type: Jar) {
102+
classifier = 'javadoc'
103+
baseName = artifact_id
104+
from androidJavadocs.destinationDir
105+
}
106+
107+
task androidSourcesJar(type: Jar) {
108+
classifier = 'sources'
109+
baseName = artifact_id
110+
from android.sourceSets.main.java.srcDirs
111+
}
112+
113+
artifacts {
114+
// archives packageReleaseJar
115+
archives androidSourcesJar
116+
archives androidJavadocsJar
117+
}
118+
}
119+

AndroidAsync/src/com/koushikdutta/async/AsyncNetworkSocket.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ ChannelWrapper getChannel() {
4949
}
5050

5151
public void onDataWritable() {
52-
// assert mWriteableHandler != null;
5352
if (!mChannel.isChunked()) {
5453
// turn write off
5554
mKey.interestOps(~SelectionKey.OP_WRITE & mKey.interestOps());
@@ -79,7 +78,6 @@ public void run() {
7978
return;
8079
}
8180
if (!mChannel.isConnected()) {
82-
assert !mChannel.isChunked();
8381
return;
8482
}
8583

@@ -103,7 +101,6 @@ private void handleRemaining(int remaining) throws IOException {
103101
throw new IOException(new CancelledKeyException());
104102
if (remaining > 0) {
105103
// chunked channels should not fail
106-
assert !mChannel.isChunked();
107104
// register for a write notification if a write fails
108105
// turn write on
109106
mKey.interestOps(SelectionKey.OP_WRITE | mKey.interestOps());

AndroidAsync/src/com/koushikdutta/async/AsyncSSLSocketWrapper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,6 @@ public void write(ByteBufferList bb) {
471471
bb.addAll(arr);
472472
writeBuf.flip();
473473
writeList.add(writeBuf);
474-
assert !writeList.hasRemaining();
475474
if (writeList.remaining() > 0)
476475
mSink.write(writeList);
477476
int previousCapacity = writeBuf.capacity();

AndroidAsync/src/com/koushikdutta/async/AsyncServer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ public Cancellable connectResolvedInetSocketAddress(final InetSocketAddress addr
396396

397397
public ConnectFuture connectResolvedInetSocketAddress(final InetSocketAddress address, final ConnectCallback callback, final SocketCreateCallback createCallback) {
398398
final ConnectFuture cancel = new ConnectFuture();
399-
assert !address.isUnresolved();
400399

401400
post(new Runnable() {
402401
@Override

AndroidAsync/src/com/koushikdutta/async/BufferedDataSink.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ public int getMaxBuffer() {
104104
}
105105

106106
public void setMaxBuffer(int maxBuffer) {
107-
assert maxBuffer >= 0;
108107
mMaxBuffer = maxBuffer;
109108
}
110109

AndroidAsync/src/com/koushikdutta/async/ByteBufferList.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ public void get(byte[] bytes, int offset, int length) {
166166
offset += read;
167167
if (b.remaining() == 0) {
168168
ByteBuffer removed = mBuffers.remove();
169-
assert b == removed;
170169
reclaim(b);
171170
}
172171
}
@@ -196,8 +195,6 @@ public void get(ByteBufferList into, int length) {
196195
b.get(subset.array(), 0, need);
197196
into.add(subset);
198197
mBuffers.addFirst(b);
199-
assert subset.capacity() >= need;
200-
assert subset.position() == 0;
201198
break;
202199
}
203200
else {
@@ -338,7 +335,6 @@ public void recycle() {
338335
while (mBuffers.size() > 0) {
339336
reclaim(mBuffers.remove());
340337
}
341-
assert mBuffers.size() == 0;
342338
remaining = 0;
343339
}
344340

@@ -465,14 +461,11 @@ public static void reclaim(ByteBuffer b) {
465461
return;
466462
}
467463

468-
assert !reclaimedContains(b);
469-
470464
b.position(0);
471465
b.limit(b.capacity());
472466
currentSize += b.capacity();
473467

474468
r.add(b);
475-
assert r.size() != 0 ^ currentSize == 0;
476469

477470
maxItem = Math.max(maxItem, b.capacity());
478471
}
@@ -490,7 +483,6 @@ public static ByteBuffer obtain(int size) {
490483
if (r.size() == 0)
491484
maxItem = 0;
492485
currentSize -= ret.capacity();
493-
assert r.size() != 0 ^ currentSize == 0;
494486
if (ret.capacity() >= size) {
495487
// System.out.println("using " + ret.capacity());
496488
return ret;
@@ -516,7 +508,6 @@ public static void obtainArray(ByteBuffer[] arr, int size) {
516508
while (r.size() > 0 && total < size && index < arr.length - 1) {
517509
ByteBuffer b = r.remove();
518510
currentSize -= b.capacity();
519-
assert r.size() != 0 ^ currentSize == 0;
520511
int needed = Math.min(size - total, b.capacity());
521512
total += needed;
522513
arr[index++] = b;

AndroidAsync/src/com/koushikdutta/async/DataEmitterReader.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ public class DataEmitterReader implements com.koushikdutta.async.callback.DataCa
88
ByteBufferList mPendingData = new ByteBufferList();
99

1010
public void read(int count, DataCallback callback) {
11-
assert mPendingRead == null;
1211
mPendingReadLength = count;
1312
mPendingRead = callback;
14-
assert !mPendingData.hasRemaining();
1513
mPendingData.recycle();
1614
}
1715

@@ -22,7 +20,6 @@ private boolean handlePendingData(DataEmitter emitter) {
2220
DataCallback pendingRead = mPendingRead;
2321
mPendingRead = null;
2422
pendingRead.onDataAvailable(emitter, mPendingData);
25-
assert !mPendingData.hasRemaining();
2623

2724
return true;
2825
}
@@ -32,7 +29,6 @@ public DataEmitterReader() {
3229
@Override
3330
public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
3431
// if we're registered for data, we must be waiting for a read
35-
assert mPendingRead != null;
3632
do {
3733
int need = Math.min(bb.remaining(), mPendingReadLength - mPendingData.remaining());
3834
bb.get(mPendingData, need);

AndroidAsync/src/com/koushikdutta/async/LineEmitter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
3737
while (bb.remaining() > 0) {
3838
byte b = bb.get();
3939
if (b == '\n') {
40-
assert mLineCallback != null;
4140
buffer.flip();
4241
data.add(buffer);
4342
mLineCallback.onStringAvailable(data.readString(charset));

AndroidAsync/src/com/koushikdutta/async/ServerSocketChannelWrapper.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,17 @@ public int getLocalPort() {
3737
@Override
3838
public int read(ByteBuffer buffer) throws IOException {
3939
final String msg = "Can't read ServerSocketChannel";
40-
assert false;
4140
throw new IOException(msg);
4241
}
4342

4443
@Override
4544
public boolean isConnected() {
46-
assert false;
4745
return false;
4846
}
4947

5048
@Override
5149
public int write(ByteBuffer src) throws IOException {
5250
final String msg = "Can't write ServerSocketChannel";
53-
assert false;
5451
throw new IOException(msg);
5552
}
5653

@@ -62,21 +59,18 @@ public SelectionKey register(Selector sel) throws ClosedChannelException {
6259
@Override
6360
public int write(ByteBuffer[] src) throws IOException {
6461
final String msg = "Can't write ServerSocketChannel";
65-
assert false;
6662
throw new IOException(msg);
6763
}
6864

6965
@Override
7066
public long read(ByteBuffer[] byteBuffers) throws IOException {
7167
final String msg = "Can't read ServerSocketChannel";
72-
assert false;
7368
throw new IOException(msg);
7469
}
7570

7671
@Override
7772
public long read(ByteBuffer[] byteBuffers, int i, int i2) throws IOException {
7873
final String msg = "Can't read ServerSocketChannel";
79-
assert false;
8074
throw new IOException(msg);
8175
}
8276

AndroidAsync/src/com/koushikdutta/async/Util.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public static void emitAllData(DataEmitter emitter, ByteBufferList list) {
3636
list.recycle();
3737
if (SUPRESS_DEBUG_EXCEPTIONS)
3838
return;
39-
assert false;
4039
throw new RuntimeException("mDataHandler failed to consume data, yet remains the mDataHandler.");
4140
}
4241
}
@@ -50,7 +49,6 @@ public static void emitAllData(DataEmitter emitter, ByteBufferList list) {
5049
list.recycle();
5150
if (SUPRESS_DEBUG_EXCEPTIONS)
5251
return;
53-
// assert false;
5452
// throw new AssertionError("Not all data was consumed by Util.emitAllData");
5553
}
5654
}

AndroidAsync/src/com/koushikdutta/async/future/Continuation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public void onCompleted(Exception ex) {
5656
if (mThisCompleted)
5757
return;
5858
mThisCompleted = true;
59-
assert waiting;
6059
waiting = false;
6160
if (ex == null) {
6261
next();

AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ public boolean cancel() {
153153
}
154154

155155
private void reportConnectedCompleted(FutureAsyncHttpResponse cancel, Exception ex, AsyncHttpResponseImpl response, AsyncHttpRequest request, final HttpConnectCallback callback) {
156-
assert callback != null;
157156
cancel.scheduled.cancel();
158157
boolean complete;
159158
if (ex != null) {
@@ -166,7 +165,6 @@ private void reportConnectedCompleted(FutureAsyncHttpResponse cancel, Exception
166165
}
167166
if (complete) {
168167
callback.onConnectCompleted(ex, response);
169-
assert ex != null || response.socket() == null || response.getDataCallback() != null || response.isPaused();
170168
return;
171169
}
172170

@@ -204,7 +202,6 @@ private static void copyHeader(AsyncHttpRequest from, AsyncHttpRequest to, Strin
204202
}
205203

206204
private void executeAffinity(final AsyncHttpRequest request, final int redirectCount, final FutureAsyncHttpResponse cancel, final HttpConnectCallback callback) {
207-
assert mServer.isAffinityThread();
208205
if (redirectCount > 15) {
209206
reportConnectedCompleted(cancel, new RedirectLimitExceededException("too many redirects"), null, request, callback);
210207
return;
@@ -704,13 +701,11 @@ public Future<WebSocket> websocket(final AsyncHttpRequest req, String[] protocol
704701
}
705702

706703
public Future<WebSocket> websocket(String uri, String protocol, final WebSocketConnectCallback callback) {
707-
// assert callback != null;
708704
final AsyncHttpGet get = new AsyncHttpGet(uri.replace("ws://", "http://").replace("wss://", "https://"));
709705
return websocket(get, protocol, callback);
710706
}
711707

712708
public Future<WebSocket> websocket(String uri, String[] protocols, final WebSocketConnectCallback callback) {
713-
// assert callback != null;
714709
final AsyncHttpGet get = new AsyncHttpGet(uri.replace("ws://", "http://").replace("wss://", "https://"));
715710
return websocket(get, protocols, callback);
716711
}

0 commit comments

Comments
 (0)