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:
BrennanConroy 2018-10-29 19:41:42 -07:00 committed by GitHub
commit e0f547e211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 16 deletions

View File

@ -14,6 +14,7 @@ plugins {
id 'maven' id 'maven'
} }
apply plugin: "java-library"
apply plugin: "com.diffplug.gradle.spotless" apply plugin: "com.diffplug.gradle.spotless"
group 'com.microsoft.signalr' group 'com.microsoft.signalr'
@ -34,7 +35,7 @@ dependencies {
testCompile 'org.slf4j:slf4j-jdk14:1.7.25' testCompile 'org.slf4j:slf4j-jdk14:1.7.25'
implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.okhttp3:okhttp:3.11.0' 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' implementation 'org.slf4j:slf4j-api:1.7.25'
} }

View File

@ -5,6 +5,7 @@ package com.microsoft.signalr;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
@ -96,7 +97,10 @@ final class DefaultHttpClient extends HttpClient {
} }
if (httpRequest.getHeaders() != null) { 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(); Request request = requestBuilder.build();
@ -106,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
@ -125,4 +133,4 @@ final class DefaultHttpClient extends HttpClient {
public WebSocketWrapper createWebSocket(String url, Map<String, String> headers) { public WebSocketWrapper createWebSocket(String url, Map<String, String> headers) {
return new OkHttpWebSocketWrapper(url, headers, client); return new OkHttpWebSocketWrapper(url, headers, client);
} }
} }

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();
} }