Merge pull request #3226 from dotnet-maestro-bot/merge/release/2.2-to-master
[automated] Merge branch 'release/2.2' => 'master'
This commit is contained in:
commit
e0f547e211
|
|
@ -14,6 +14,7 @@ plugins {
|
|||
id 'maven'
|
||||
}
|
||||
|
||||
apply plugin: "java-library"
|
||||
apply plugin: "com.diffplug.gradle.spotless"
|
||||
|
||||
group 'com.microsoft.signalr'
|
||||
|
|
@ -34,7 +35,7 @@ dependencies {
|
|||
testCompile 'org.slf4j:slf4j-jdk14:1.7.25'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
|
||||
api 'io.reactivex.rxjava2:rxjava:2.2.2'
|
||||
implementation 'org.slf4j:slf4j-api:1.7.25'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package com.microsoft.signalr;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
|
@ -96,7 +97,10 @@ final class DefaultHttpClient extends HttpClient {
|
|||
}
|
||||
|
||||
if (httpRequest.getHeaders() != null) {
|
||||
httpRequest.getHeaders().forEach(requestBuilder::addHeader);
|
||||
Collection<String> keys = httpRequest.getHeaders().keySet();
|
||||
for (String key : keys) {
|
||||
requestBuilder.addHeader(key, httpRequest.getHeaders().get(key));
|
||||
}
|
||||
}
|
||||
|
||||
Request request = requestBuilder.build();
|
||||
|
|
@ -106,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
|
||||
|
|
@ -125,4 +133,4 @@ final class DefaultHttpClient extends HttpClient {
|
|||
public WebSocketWrapper createWebSocket(String url, Map<String, String> headers) {
|
||||
return new OkHttpWebSocketWrapper(url, headers, client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue