[Java] API level support down to 23

This commit is contained in:
BrennanConroy 2018-10-29 16:53:47 -07:00 committed by GitHub
parent 1edf818104
commit 73f2f19984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

View File

@ -110,7 +110,11 @@ final class DefaultHttpClient extends HttpClient {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
responseSubject.onError(e.getCause());
Throwable cause = e.getCause();
if (cause == null) {
cause = e;
}
responseSubject.onError(cause);
}
@Override

View File

@ -4,6 +4,7 @@
package com.microsoft.signalr;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -762,13 +763,14 @@ public class HubConnection {
public void cancelOutstandingInvocations(Exception ex) {
lock.lock();
try {
pendingInvocations.forEach((key, irq) -> {
Collection<String> keys = pendingInvocations.keySet();
for (String key : keys) {
if (ex == null) {
irq.cancel();
pendingInvocations.get(key).cancel();
} else {
irq.fail(ex);
pendingInvocations.get(key).fail(ex);
}
});
}
pendingInvocations.clear();
} finally {
@ -779,14 +781,11 @@ public class HubConnection {
public void addInvocation(InvocationRequest irq) {
lock.lock();
try {
pendingInvocations.compute(irq.getInvocationId(), (key, value) -> {
if (value != null) {
// This should never happen
throw new IllegalStateException("Invocation Id is already used");
}
return irq;
});
if (pendingInvocations.containsKey(irq.getInvocationId())) {
throw new IllegalStateException("Invocation Id is already used");
} else {
pendingInvocations.put(irq.getInvocationId(), irq);
}
} finally {
lock.unlock();
}