[Java] API level support down to 23
This commit is contained in:
parent
1edf818104
commit
73f2f19984
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue