Fix HttpObservable collection parameters to not null
This commit is contained in:
Родитель
001739fcb9
Коммит
5818ce5eca
|
@ -362,8 +362,8 @@ public class HttpObservable implements Logger {
|
|||
*/
|
||||
public Observable<CloseableHttpResponse> request(final HttpRequestBase httpRequest,
|
||||
final @Nullable HttpEntity entity,
|
||||
final @Nullable List<NameValuePair> parameters,
|
||||
final @Nullable List<Header> addOrReplaceHeaders) {
|
||||
final List<NameValuePair> parameters,
|
||||
final List<Header> addOrReplaceHeaders) {
|
||||
return Observable.fromCallable(() -> {
|
||||
URIBuilder builder = new URIBuilder(httpRequest.getURI());
|
||||
|
||||
|
@ -399,8 +399,8 @@ public class HttpObservable implements Logger {
|
|||
*/
|
||||
public Observable<HttpResponse> requestWithHttpResponse(final HttpRequestBase httpRequest,
|
||||
final @Nullable HttpEntity entity,
|
||||
final @Nullable List<NameValuePair> parameters,
|
||||
final @Nullable List<Header> addOrReplaceHeaders) {
|
||||
final List<NameValuePair> parameters,
|
||||
final List<Header> addOrReplaceHeaders) {
|
||||
return request(httpRequest, entity, parameters, addOrReplaceHeaders)
|
||||
.flatMap(HttpObservable::toStringOnlyOkResponse);
|
||||
}
|
||||
|
@ -412,8 +412,8 @@ public class HttpObservable implements Logger {
|
|||
}
|
||||
|
||||
public <T> Observable<Pair<T, HttpResponse>> get(final String uri,
|
||||
final @Nullable List<NameValuePair> parameters,
|
||||
final @Nullable List<Header> addOrReplaceHeaders,
|
||||
final List<NameValuePair> parameters,
|
||||
final List<Header> addOrReplaceHeaders,
|
||||
final Class<T> clazz) {
|
||||
return requestWithHttpResponse(new HttpGet(uri), null, parameters, addOrReplaceHeaders)
|
||||
.map(resp -> this.convertJsonResponseToObject(resp, clazz));
|
||||
|
@ -421,8 +421,8 @@ public class HttpObservable implements Logger {
|
|||
|
||||
public <T> Observable<Pair<T, HttpResponse>> put(final String uri,
|
||||
final @Nullable HttpEntity entity,
|
||||
final @Nullable List<NameValuePair> parameters,
|
||||
final @Nullable List<Header> addOrReplaceHeaders,
|
||||
final List<NameValuePair> parameters,
|
||||
final List<Header> addOrReplaceHeaders,
|
||||
final Class<T> clazz) {
|
||||
return requestWithHttpResponse(new HttpPut(uri), entity, parameters, addOrReplaceHeaders)
|
||||
.map(resp -> this.convertJsonResponseToObject(resp, clazz));
|
||||
|
@ -430,23 +430,23 @@ public class HttpObservable implements Logger {
|
|||
|
||||
public <T> Observable<Pair<T, HttpResponse>> post(final String uri,
|
||||
final @Nullable HttpEntity entity,
|
||||
final @Nullable List<NameValuePair> parameters,
|
||||
final @Nullable List<Header> addOrReplaceHeaders,
|
||||
final List<NameValuePair> parameters,
|
||||
final List<Header> addOrReplaceHeaders,
|
||||
final Class<T> clazz) {
|
||||
return requestWithHttpResponse(new HttpPost(uri), entity, parameters, addOrReplaceHeaders)
|
||||
.map(resp -> this.convertJsonResponseToObject(resp, clazz));
|
||||
}
|
||||
|
||||
public Observable<HttpResponse> delete(final String uri,
|
||||
final @Nullable List<NameValuePair> parameters,
|
||||
final @Nullable List<Header> addOrReplaceHeaders) {
|
||||
final List<NameValuePair> parameters,
|
||||
final List<Header> addOrReplaceHeaders) {
|
||||
return requestWithHttpResponse(new HttpDelete(uri), null, parameters, addOrReplaceHeaders);
|
||||
}
|
||||
|
||||
public <T> Observable<Pair<T, HttpResponse>> patch(final String uri,
|
||||
final @Nullable HttpEntity entity,
|
||||
final @Nullable List<NameValuePair> parameters,
|
||||
final @Nullable List<Header> addOrReplaceHeaders,
|
||||
final List<NameValuePair> parameters,
|
||||
final List<Header> addOrReplaceHeaders,
|
||||
final Class<T> clazz) {
|
||||
return requestWithHttpResponse(new HttpPatch(uri), entity, parameters, addOrReplaceHeaders)
|
||||
.map(resp -> this.convertJsonResponseToObject(resp, clazz));
|
||||
|
|
|
@ -30,7 +30,6 @@ import com.microsoft.azure.spark.tools.utils.Pair;
|
|||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -42,6 +41,7 @@ import java.util.function.Predicate;
|
|||
import static com.microsoft.azure.spark.tools.events.MessageInfoType.Debug;
|
||||
import static com.microsoft.azure.spark.tools.events.MessageInfoType.Info;
|
||||
import static com.microsoft.azure.spark.tools.events.MessageInfoType.Log;
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
public class LivySparkBatch implements SparkBatchJob, Logger {
|
||||
public static final String WebHDFSPathPattern = "^(https?://)([^/]+)(/.*)?(/webhdfs/v1)(/.*)?$";
|
||||
|
@ -78,7 +78,7 @@ public class LivySparkBatch implements SparkBatchJob, Logger {
|
|||
private @Nullable String appId;
|
||||
private @Nullable Map<String, String> appInfo;
|
||||
|
||||
private List<String> submissionLogs = Collections.emptyList();
|
||||
private List<String> submissionLogs = emptyList();
|
||||
|
||||
public LivySparkBatch(
|
||||
final LivyCluster cluster,
|
||||
|
@ -342,7 +342,7 @@ public class LivySparkBatch implements SparkBatchJob, Logger {
|
|||
}
|
||||
|
||||
protected List<Header> getHeadersToAddOrReplace() {
|
||||
return Collections.emptyList();
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
protected HttpObservable getHttp() {
|
||||
|
@ -373,20 +373,20 @@ public class LivySparkBatch implements SparkBatchJob, Logger {
|
|||
Debug, String.format("Spark Batch request to %s, body: %s", uri, body.convertToJson())));
|
||||
|
||||
return getHttp()
|
||||
.post(uri.toString(), entity, null, getHeadersToAddOrReplace(), Batch.class)
|
||||
.post(uri.toString(), entity, emptyList(), getHeadersToAddOrReplace(), Batch.class)
|
||||
.map(Pair::getFirst);
|
||||
}
|
||||
|
||||
private Observable<HttpResponse> deleteSparkBatchRequest() {
|
||||
return Observable.fromCallable(this::getUri)
|
||||
.flatMap(uri -> getHttp()
|
||||
.delete(uri.toString(), null, getHeadersToAddOrReplace()));
|
||||
.delete(uri.toString(), emptyList(), getHeadersToAddOrReplace()));
|
||||
}
|
||||
|
||||
private Observable<Batch> getSparkBatchRequest() {
|
||||
return Observable.fromCallable(this::getUri)
|
||||
.flatMap(uri -> getHttp()
|
||||
.get(uri.toString(), null, getHeadersToAddOrReplace(), Batch.class)
|
||||
.get(uri.toString(), emptyList(), getHeadersToAddOrReplace(), Batch.class)
|
||||
.map(Pair::getFirst));
|
||||
}
|
||||
|
||||
|
@ -404,7 +404,7 @@ public class LivySparkBatch implements SparkBatchJob, Logger {
|
|||
this.state = batch.getState();
|
||||
this.appId = batch.getAppId();
|
||||
this.appInfo = batch.getAppInfo();
|
||||
this.submissionLogs = (batch.getLog() == null) ? Collections.emptyList() : batch.getLog();
|
||||
this.submissionLogs = (batch.getLog() == null) ? emptyList() : batch.getLog();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Map;
|
|||
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AzureHttpObservableScenario {
|
||||
|
@ -67,7 +68,7 @@ public class AzureHttpObservableScenario {
|
|||
String expectHeaderKey,
|
||||
String expectHeaderValue,
|
||||
Map<String, String> expectParameters) {
|
||||
this.httpMock.request(this.httpRequest, null, null, null )
|
||||
this.httpMock.request(this.httpRequest, null, emptyList(), emptyList())
|
||||
.toBlocking()
|
||||
.subscribe();
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
|
|||
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
|
||||
import static com.microsoft.azure.spark.tools.utils.MockHttpService.WIREMOCK_SSL_CERT_PUBLIC_KEY;
|
||||
import static com.microsoft.azure.spark.tools.utils.MockHttpService.WIREMOCK_SSL_CERT_TYPE;
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -111,7 +112,7 @@ public class HttpObservableScenario {
|
|||
public void checkRequestHeaderAndParameters(String method,
|
||||
String path,
|
||||
Map<String, String> expectHeaders) {
|
||||
this.httpMock.request(this.httpRequest, null, null, null )
|
||||
this.httpMock.request(this.httpRequest, null, emptyList(), emptyList())
|
||||
.toBlocking()
|
||||
.subscribe();
|
||||
|
||||
|
@ -126,7 +127,7 @@ public class HttpObservableScenario {
|
|||
public void checkHttpsRequestHeaderAndParameters(String method,
|
||||
String path,
|
||||
Map<String, String> expectHeaders) {
|
||||
this.httpMock.request(this.httpRequest, null, null, null )
|
||||
this.httpMock.request(this.httpRequest, null, emptyList(), emptyList())
|
||||
.toBlocking()
|
||||
.subscribe();
|
||||
|
||||
|
@ -143,7 +144,7 @@ public class HttpObservableScenario {
|
|||
String expectErrorMessage) {
|
||||
AtomicReference<Throwable> caught = new AtomicReference<>();
|
||||
|
||||
this.httpMock.request(this.httpRequest, null, null, null)
|
||||
this.httpMock.request(this.httpRequest, null, emptyList(), emptyList())
|
||||
.toBlocking()
|
||||
.subscribe(
|
||||
data -> {},
|
||||
|
@ -163,7 +164,7 @@ public class HttpObservableScenario {
|
|||
String expectErrorMessage) {
|
||||
AtomicReference<Throwable> caught = new AtomicReference<>();
|
||||
|
||||
this.httpMock.request(this.httpRequest, null, null, null)
|
||||
this.httpMock.request(this.httpRequest, null, emptyList(), emptyList())
|
||||
.toBlocking()
|
||||
.subscribe(
|
||||
data -> {},
|
||||
|
|
|
@ -22,6 +22,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
|
|||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -61,7 +62,7 @@ public class OAuthTokenHttpObservableScenario {
|
|||
|
||||
@Then("^send and check OAuthTokenHttp '(.+)' request to '(.*)' should contains header '(.*):\\s*(.*)'$")
|
||||
public void checkRequestHeader(String method, String path, String expectHeaderKey, String expectHeaderValue) {
|
||||
this.httpMock.request(this.httpRequest, null, null, null)
|
||||
this.httpMock.request(this.httpRequest, null, emptyList(), emptyList())
|
||||
.toBlocking()
|
||||
.subscribe();
|
||||
|
||||
|
@ -105,7 +106,7 @@ public class OAuthTokenHttpObservableScenario {
|
|||
public void sendRequestAndCheckError(String method, String path, String expectedErrorMessage) {
|
||||
AtomicReference<Throwable> caught = new AtomicReference<>();
|
||||
|
||||
this.httpMock.request(this.httpRequest, null, null, null)
|
||||
this.httpMock.request(this.httpRequest, null, emptyList(), emptyList())
|
||||
.toBlocking()
|
||||
.subscribe(
|
||||
data -> {},
|
||||
|
@ -123,7 +124,7 @@ public class OAuthTokenHttpObservableScenario {
|
|||
public void sendRequestAndCheckRuntimeError(String method, String path, String expectedErrorMessage) {
|
||||
AtomicReference<Throwable> caught = new AtomicReference<>();
|
||||
|
||||
this.httpMock.request(this.httpRequest, null, null, null)
|
||||
this.httpMock.request(this.httpRequest, null, emptyList(), emptyList())
|
||||
.toBlocking()
|
||||
.subscribe(
|
||||
data -> {},
|
||||
|
|
Загрузка…
Ссылка в новой задаче