Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
d282eb61
Commit
d282eb61
authored
Jan 13, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade to Elasticsearch 7.5.1
See gh-19588
parent
f268ede3
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
73 additions
and
66 deletions
+73
-66
ElasticsearchDataConfiguration.java
...re/data/elasticsearch/ElasticsearchDataConfiguration.java
+9
-26
ElasticsearchAutoConfigurationTests.java
...ta/elasticsearch/ElasticsearchAutoConfigurationTests.java
+4
-3
ElasticsearchDataAutoConfigurationTests.java
...lasticsearch/ElasticsearchDataAutoConfigurationTests.java
+7
-26
ElasticsearchRepositoriesAutoConfigurationTests.java
...arch/ElasticsearchRepositoriesAutoConfigurationTests.java
+3
-3
ReactiveElasticsearchRepositoriesAutoConfigurationTests.java
...ctiveElasticsearchRepositoriesAutoConfigurationTests.java
+2
-2
ReactiveRestClientAutoConfigurationTests.java
...asticsearch/ReactiveRestClientAutoConfigurationTests.java
+6
-5
VersionOverridingElasticsearchContainer.java
...lasticsearch/VersionOverridingElasticsearchContainer.java
+41
-0
build.gradle
spring-boot-project/spring-boot-dependencies/build.gradle
+1
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataConfiguration.java
View file @
d282eb61
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -27,15 +27,11 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient
;
import
org.springframework.data.elasticsearch.core.DefaultEntityMapper
;
import
org.springframework.data.elasticsearch.core.DefaultResultMapper
;
import
org.springframework.data.elasticsearch.core.ElasticsearchOperations
;
import
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
;
import
org.springframework.data.elasticsearch.core.ElasticsearchTemplate
;
import
org.springframework.data.elasticsearch.core.EntityMapper
;
import
org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations
;
import
org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate
;
import
org.springframework.data.elasticsearch.core.ResultsMapper
;
import
org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter
;
import
org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter
;
import
org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext
;
...
...
@@ -48,6 +44,7 @@ import org.springframework.web.reactive.function.client.WebClient;
* their order of execution.
*
* @author Brian Clozel
* @author Scott Frederick
*/
abstract
class
ElasticsearchDataConfiguration
{
...
...
@@ -66,18 +63,6 @@ abstract class ElasticsearchDataConfiguration {
return
new
SimpleElasticsearchMappingContext
();
}
@Bean
@ConditionalOnMissingBean
EntityMapper
entityMapper
(
SimpleElasticsearchMappingContext
mappingContext
)
{
return
new
DefaultEntityMapper
(
mappingContext
);
}
@Bean
@ConditionalOnMissingBean
ResultsMapper
resultsMapper
(
SimpleElasticsearchMappingContext
mappingContext
,
EntityMapper
entityMapper
)
{
return
new
DefaultResultMapper
(
mappingContext
,
entityMapper
);
}
}
@Configuration
(
proxyBeanMethods
=
false
)
...
...
@@ -87,9 +72,8 @@ abstract class ElasticsearchDataConfiguration {
@Bean
@ConditionalOnMissingBean
(
value
=
ElasticsearchOperations
.
class
,
name
=
"elasticsearchTemplate"
)
@ConditionalOnBean
(
RestHighLevelClient
.
class
)
ElasticsearchRestTemplate
elasticsearchTemplate
(
RestHighLevelClient
client
,
ElasticsearchConverter
converter
,
ResultsMapper
resultsMapper
)
{
return
new
ElasticsearchRestTemplate
(
client
,
converter
,
resultsMapper
);
ElasticsearchRestTemplate
elasticsearchTemplate
(
RestHighLevelClient
client
,
ElasticsearchConverter
converter
)
{
return
new
ElasticsearchRestTemplate
(
client
,
converter
);
}
}
...
...
@@ -101,10 +85,10 @@ abstract class ElasticsearchDataConfiguration {
@Bean
@ConditionalOnMissingBean
(
value
=
ElasticsearchOperations
.
class
,
name
=
"elasticsearchTemplate"
)
@ConditionalOnBean
(
Client
.
class
)
ElasticsearchTemplate
elasticsearchTemplate
(
Client
client
,
ElasticsearchConverter
converter
,
ResultsMapper
resultsMapp
er
)
{
@Deprecated
ElasticsearchTemplate
elasticsearchTemplate
(
Client
client
,
ElasticsearchConverter
convert
er
)
{
try
{
return
new
ElasticsearchTemplate
(
client
,
converter
,
resultsMapper
);
return
new
ElasticsearchTemplate
(
client
,
converter
);
}
catch
(
Exception
ex
)
{
throw
new
IllegalStateException
(
ex
);
...
...
@@ -121,9 +105,8 @@ abstract class ElasticsearchDataConfiguration {
@ConditionalOnMissingBean
(
value
=
ReactiveElasticsearchOperations
.
class
,
name
=
"reactiveElasticsearchTemplate"
)
@ConditionalOnBean
(
ReactiveElasticsearchClient
.
class
)
ReactiveElasticsearchTemplate
reactiveElasticsearchTemplate
(
ReactiveElasticsearchClient
client
,
ElasticsearchConverter
converter
,
ResultsMapper
resultsMapper
)
{
ReactiveElasticsearchTemplate
template
=
new
ReactiveElasticsearchTemplate
(
client
,
converter
,
resultsMapper
);
ElasticsearchConverter
converter
)
{
ReactiveElasticsearchTemplate
template
=
new
ReactiveElasticsearchTemplate
(
client
,
converter
);
template
.
setIndicesOptions
(
IndicesOptions
.
strictExpandOpenAndForbidClosed
());
template
.
setRefreshPolicy
(
WriteRequest
.
RefreshPolicy
.
IMMEDIATE
);
return
template
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfigurationTests.java
View file @
d282eb61
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -47,8 +47,8 @@ import static org.mockito.Mockito.mock;
class
ElasticsearchAutoConfigurationTests
{
@Container
public
static
ElasticsearchContainer
elasticsearch
=
new
ElasticsearchContainer
().
withStartupAttempts
(
5
)
.
withStartupTimeout
(
Duration
.
ofMinutes
(
10
));
public
static
ElasticsearchContainer
elasticsearch
=
new
VersionOverridingElasticsearchContainer
(
)
.
withStartup
Attempts
(
5
).
withStartup
Timeout
(
Duration
.
ofMinutes
(
10
));
private
AnnotationConfigApplicationContext
context
;
...
...
@@ -76,6 +76,7 @@ class ElasticsearchAutoConfigurationTests {
}
@Test
@SuppressWarnings
(
"deprecation"
)
void
createTransportClient
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
TestPropertyValues
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfigurationTests.java
View file @
d282eb61
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -30,10 +30,8 @@ import org.springframework.boot.autoconfigure.elasticsearch.rest.RestClientAutoC
import
org.springframework.boot.test.context.runner.ApplicationContextRunner
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.elasticsearch.core.ElasticsearchEntityMapper
;
import
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
;
import
org.springframework.data.elasticsearch.core.ElasticsearchTemplate
;
import
org.springframework.data.elasticsearch.core.EntityMapper
;
import
org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate
;
import
org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter
;
import
org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext
;
...
...
@@ -48,12 +46,13 @@ import static org.mockito.Mockito.mock;
* @author Artur Konczak
* @author Brian Clozel
* @author Peter-Josef Meisch
* @author Scott Frederick
*/
@Testcontainers
(
disabledWithoutDocker
=
true
)
class
ElasticsearchDataAutoConfigurationTests
{
@Container
static
ElasticsearchContainer
elasticsearch
=
new
ElasticsearchContainer
().
withStartupAttempts
(
5
)
static
ElasticsearchContainer
elasticsearch
=
new
VersionOverriding
ElasticsearchContainer
().
withStartupAttempts
(
5
)
.
withStartupTimeout
(
Duration
.
ofMinutes
(
10
));
private
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
().
withConfiguration
(
...
...
@@ -71,6 +70,7 @@ class ElasticsearchDataAutoConfigurationTests {
}
@Test
@SuppressWarnings
(
"deprecation"
)
void
defaultTransportBeansAreRegistered
()
{
this
.
contextRunner
.
withPropertyValues
(
...
...
@@ -83,6 +83,7 @@ class ElasticsearchDataAutoConfigurationTests {
}
@Test
@SuppressWarnings
(
"deprecation"
)
void
defaultTransportBeansNotRegisteredIfNoTransportClient
()
{
this
.
contextRunner
.
run
((
context
)
->
assertThat
(
context
).
doesNotHaveBean
(
ElasticsearchTemplate
.
class
));
}
...
...
@@ -91,16 +92,11 @@ class ElasticsearchDataAutoConfigurationTests {
void
defaultRestBeansRegistered
()
{
this
.
contextRunner
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
ElasticsearchRestTemplate
.
class
)
.
hasSingleBean
(
ReactiveElasticsearchTemplate
.
class
).
hasSingleBean
(
ElasticsearchConverter
.
class
)
.
hasSingleBean
(
SimpleElasticsearchMappingContext
.
class
).
hasSingleBean
(
EntityMapper
.
class
)
.
hasSingleBean
(
ElasticsearchConverter
.
class
));
}
@Test
void
defaultEntityMapperRegistered
()
{
this
.
contextRunner
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
EntityMapper
.
class
));
}
@Test
@SuppressWarnings
(
"deprecation"
)
void
customTransportTemplateShouldBeUsed
()
{
this
.
contextRunner
.
withUserConfiguration
(
CustomTransportTemplate
.
class
).
run
((
context
)
->
assertThat
(
context
)
.
getBeanNames
(
ElasticsearchTemplate
.
class
).
hasSize
(
1
).
contains
(
"elasticsearchTemplate"
));
...
...
@@ -119,16 +115,11 @@ class ElasticsearchDataAutoConfigurationTests {
.
contains
(
"reactiveElasticsearchTemplate"
));
}
@Test
void
customEntityMapperShouldeBeUsed
()
{
this
.
contextRunner
.
withUserConfiguration
(
CustomEntityMapper
.
class
).
run
((
context
)
->
assertThat
(
context
)
.
getBeanNames
(
EntityMapper
.
class
).
containsExactly
(
"elasticsearchEntityMapper"
));
}
@Configuration
(
proxyBeanMethods
=
false
)
static
class
CustomTransportTemplate
{
@Bean
@SuppressWarnings
(
"deprecation"
)
ElasticsearchTemplate
elasticsearchTemplate
()
{
return
mock
(
ElasticsearchTemplate
.
class
);
}
...
...
@@ -155,14 +146,4 @@ class ElasticsearchDataAutoConfigurationTests {
}
@Configuration
(
proxyBeanMethods
=
false
)
static
class
CustomEntityMapper
{
@Bean
EntityMapper
elasticsearchEntityMapper
()
{
return
mock
(
ElasticsearchEntityMapper
.
class
);
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchRepositoriesAutoConfigurationTests.java
View file @
d282eb61
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -48,8 +48,8 @@ import static org.assertj.core.api.Assertions.assertThat;
class
ElasticsearchRepositoriesAutoConfigurationTests
{
@Container
static
final
ElasticsearchContainer
elasticsearch
=
new
ElasticsearchContainer
().
withStartupAttempts
(
5
)
.
withStartupTimeout
(
Duration
.
ofMinutes
(
10
));
static
final
ElasticsearchContainer
elasticsearch
=
new
VersionOverridingElasticsearchContainer
(
)
.
withStartup
Attempts
(
5
).
withStartup
Timeout
(
Duration
.
ofMinutes
(
10
));
private
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
()
.
withConfiguration
(
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRepositoriesAutoConfigurationTests.java
View file @
d282eb61
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public
class
ReactiveElasticsearchRepositoriesAutoConfigurationTests
{
@Container
static
ElasticsearchContainer
elasticsearch
=
new
ElasticsearchContainer
().
withStartupAttempts
(
5
)
static
ElasticsearchContainer
elasticsearch
=
new
VersionOverriding
ElasticsearchContainer
().
withStartupAttempts
(
5
)
.
withStartupTimeout
(
Duration
.
ofMinutes
(
10
));
private
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
()
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveRestClientAutoConfigurationTests.java
View file @
d282eb61
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -47,7 +47,7 @@ import static org.mockito.Mockito.mock;
public
class
ReactiveRestClientAutoConfigurationTests
{
@Container
static
ElasticsearchContainer
elasticsearch
=
new
ElasticsearchContainer
().
withStartupAttempts
(
5
)
static
ElasticsearchContainer
elasticsearch
=
new
VersionOverriding
ElasticsearchContainer
().
withStartupAttempts
(
5
)
.
withStartupTimeout
(
Duration
.
ofMinutes
(
10
));
private
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
()
...
...
@@ -83,9 +83,10 @@ public class ReactiveRestClientAutoConfigurationTests {
Map
<
String
,
String
>
source
=
new
HashMap
<>();
source
.
put
(
"a"
,
"alpha"
);
source
.
put
(
"b"
,
"bravo"
);
IndexRequest
index
=
new
IndexRequest
(
"foo"
,
"bar"
,
"1"
).
source
(
source
);
GetRequest
getRequest
=
new
GetRequest
(
"foo"
,
"bar"
,
"1"
);
GetResult
getResult
=
client
.
index
(
index
).
then
(
client
.
get
(
getRequest
)).
block
();
IndexRequest
indexRequest
=
new
IndexRequest
(
"foo"
).
id
(
"1"
).
source
(
source
);
GetRequest
getRequest
=
new
GetRequest
(
"foo"
).
id
(
"1"
);
GetResult
getResult
=
client
.
index
(
indexRequest
).
then
(
client
.
get
(
getRequest
)).
block
();
assertThat
(
getResult
).
isNotNull
();
assertThat
(
getResult
.
isExists
()).
isTrue
();
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/VersionOverridingElasticsearchContainer.java
0 → 100644
View file @
d282eb61
/*
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
autoconfigure
.
data
.
elasticsearch
;
import
org.testcontainers.elasticsearch.ElasticsearchContainer
;
/**
* Extension of {@link ElasticsearchContainer} to override default version.
*
* @author Scott Frederick
*/
public
class
VersionOverridingElasticsearchContainer
extends
ElasticsearchContainer
{
/**
* Elasticsearch Docker base URL
*/
private
static
final
String
ELASTICSEARCH_IMAGE
=
"docker.elastic.co/elasticsearch/elasticsearch"
;
/**
* Elasticsearch version
*/
protected
static
final
String
ELASTICSEARCH_VERSION
=
"7.5.1"
;
public
VersionOverridingElasticsearchContainer
()
{
super
(
ELASTICSEARCH_IMAGE
+
":"
+
ELASTICSEARCH_VERSION
);
}
}
spring-boot-project/spring-boot-dependencies/build.gradle
View file @
d282eb61
...
...
@@ -288,7 +288,7 @@ bom {
]
}
}
library
(
'Elasticsearch'
,
'
6.8.5
'
)
{
library
(
'Elasticsearch'
,
'
7.5.1
'
)
{
group
(
'org.elasticsearch'
)
{
modules
=
[
'elasticsearch'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment