[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() { client.newCall(request).enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, IOException e) { public void onFailure(Call call, IOException e) {
responseSubject.onError(e.getCause()); Throwable cause = e.getCause();
if (cause == null) {
cause = e;
}
responseSubject.onError(cause);
} }
@Override @Override

View File

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