mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-01 09:42:11 +00:00
ReactiveElasticsearchOperations indexName is encoded twice.
Original Pull Request #1666 Closes #1665
This commit is contained in:
parent
1a02c1e05a
commit
4829b07e53
@ -27,6 +27,7 @@ import org.springframework.lang.Nullable;
|
|||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
import org.springframework.web.reactive.function.client.WebClient.Builder;
|
import org.springframework.web.reactive.function.client.WebClient.Builder;
|
||||||
|
import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default {@link WebClientProvider} that uses cached {@link WebClient} instances per {@code hostAndPort}.
|
* Default {@link WebClientProvider} that uses cached {@link WebClient} instances per {@code hostAndPort}.
|
||||||
@ -155,8 +156,13 @@ class DefaultWebClientProvider implements WebClientProvider {
|
|||||||
|
|
||||||
String baseUrl = String.format("%s://%s:%d%s", this.scheme, socketAddress.getHostString(), socketAddress.getPort(),
|
String baseUrl = String.format("%s://%s:%d%s", this.scheme, socketAddress.getHostString(), socketAddress.getPort(),
|
||||||
pathPrefix == null ? "" : '/' + pathPrefix);
|
pathPrefix == null ? "" : '/' + pathPrefix);
|
||||||
|
|
||||||
|
DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory(baseUrl);
|
||||||
|
// the template will already be encoded by the RequestConverters methods
|
||||||
|
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY);
|
||||||
|
builder.uriBuilderFactory(uriBuilderFactory); //
|
||||||
|
|
||||||
WebClient webClient = builder //
|
WebClient webClient = builder //
|
||||||
.baseUrl(baseUrl) //
|
|
||||||
.filter((request, next) -> next.exchange(request) //
|
.filter((request, next) -> next.exchange(request) //
|
||||||
.doOnError(errorListener)) //
|
.doOnError(errorListener)) //
|
||||||
.build(); //
|
.build(); //
|
||||||
|
@ -32,6 +32,8 @@ import java.lang.Boolean;
|
|||||||
import java.lang.Long;
|
import java.lang.Long;
|
||||||
import java.lang.Object;
|
import java.lang.Object;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -1031,6 +1033,32 @@ public class ReactiveElasticsearchTemplateIntegrationTests {
|
|||||||
assertThat(searchHits.getSearchHits().size()).isEqualTo(5);
|
assertThat(searchHits.getSearchHits().size()).isEqualTo(5);
|
||||||
}).verifyComplete();
|
}).verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // #1665
|
||||||
|
@DisplayName("should be able to process date-math-index names")
|
||||||
|
void shouldBeAbleToProcessDateMathIndexNames() {
|
||||||
|
|
||||||
|
String indexName = "foo-" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy.MM"));
|
||||||
|
String dateMathIndexName = "<foo-{now/M{yyyy.MM}}>";
|
||||||
|
|
||||||
|
template.indexOps(IndexCoordinates.of(dateMathIndexName)) //
|
||||||
|
.create() //
|
||||||
|
.as(StepVerifier::create) //
|
||||||
|
.expectNext(true) //
|
||||||
|
.verifyComplete(); //
|
||||||
|
|
||||||
|
template.indexOps(IndexCoordinates.of(indexName)) //
|
||||||
|
.exists() //
|
||||||
|
.as(StepVerifier::create) //
|
||||||
|
.expectNext(true) //
|
||||||
|
.verifyComplete(); //
|
||||||
|
|
||||||
|
template.indexOps(IndexCoordinates.of(dateMathIndexName)) //
|
||||||
|
.delete() //
|
||||||
|
.as(StepVerifier::create) //
|
||||||
|
.expectNext(true) //
|
||||||
|
.verifyComplete(); //
|
||||||
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region Helper functions
|
// region Helper functions
|
||||||
@ -1128,5 +1156,6 @@ public class ReactiveElasticsearchTemplateIntegrationTests {
|
|||||||
@Id private String id;
|
@Id private String id;
|
||||||
@Version private Long version;
|
@Version private Long version;
|
||||||
}
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user