-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Applied design & implementation level refactoring techniques to improve code readability & maintainability #2517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@Taran05 Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@Taran05 Thank you for signing the Contributor License Agreement! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR does not fix anything or add value to the code. It rather removes some compiler safety and reverts previous changes.
Don't commit formatting changes that are not aligned with the linked code style rules.
When running the tests, InetSocketAddressParserUnitTests
fails.
And, before submitting a pull request, create an issue explaining the problem that you want to address and how you plan to solve it.
* @return the function for configuring a WebClient. | ||
*/ | ||
Function<WebClient, WebClient> getWebClientConfigurer(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reverts the change from #2513 reintroducing the since 4.3 unused method for configuring the WebClient. Why?
@@ -329,7 +335,7 @@ default TerminalClientConfigurationBuilder withSocketTimeout(long millis) { | |||
* @param proxy a proxy formatted as String {@literal host:port}. | |||
* @return the {@link TerminalClientConfigurationBuilder}. | |||
*/ | |||
TerminalClientConfigurationBuilder withProxy(String proxy); | |||
TerminalClientConfigurationBuilder setProxy(String proxy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the methods on this builder class (and probably almost all builders in this project) use the with...()
naming. Why should this be changed?
@@ -71,7 +73,6 @@ | |||
public MaybeSecureClientConfigurationBuilder connectedTo(String... hostAndPorts) { | |||
|
|||
Assert.notEmpty(hostAndPorts, "At least one host is required"); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We separate the Assert.*
blocks with a newline from the rest of the code. One leading and one trailing. There might be places where such a newline is missing, but here the formatting is alright.
@@ -59,6 +60,7 @@ | |||
private @Nullable String password; | |||
private @Nullable String pathPrefix; | |||
private @Nullable String proxy; | |||
private final Function<WebClient, WebClient> webClientConfigurer = Function.identity(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reintroducing removed code
@@ -91,7 +92,7 @@ public MaybeSecureClientConfigurationBuilder connectedTo(InetSocketAddress... en | |||
} | |||
|
|||
@Override | |||
public MaybeSecureClientConfigurationBuilder withProxy(String proxy) { | |||
public MaybeSecureClientConfigurationBuilder setProxy(String proxy) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my other comment in ClientConfiguration
|
||
TransportOptions.Builder transportOptionsBuilder = transportOptions != null ? transportOptions.toBuilder() | ||
: new RestClientOptions(RequestOptions.DEFAULT).toBuilder(); | ||
|
||
ContentType jsonContentType = Version.VERSION == null ? ContentType.APPLICATION_JSON | ||
: ContentType.create("application/vnd.elasticsearch+json", | ||
new BasicNameValuePair("compatible-with", String.valueOf(Version.VERSION.major()))); | ||
new BasicNameValuePair("compatible-with", String.valueOf(Version.VERSION.major()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting change not compatible with code formatting guidelines
|
||
/** | ||
* Provides the {@link ElasticsearchClient} to be used. | ||
* | ||
* @param restClient the low level RestClient to use | ||
* @return ElasticsearchClient instance | ||
*/ | ||
@Bean | ||
public static ElasticsearchClient elasticsearchClient(RestClient restClient) { | ||
|
||
Assert.notNull(restClient, "restClient must not be null"); | ||
|
||
return ElasticsearchClients.createImperative(restClient, transportOptions()); | ||
} | ||
|
||
public static TransportOptions transportOptions() { | ||
return new RestClientOptions(RequestOptions.DEFAULT); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
putting a @Bean
method here makes no sense, as this is a final utility class containing static methods and not a Spring configuration class that could provide beans. Bean setup of all relevant beans is done in the org.springframework.data.elasticsearch.client.elc.ElasticsearchConfiguration
derived classes.
Assert.notNull(restClient, "restClient must not be null"); | ||
|
||
return ElasticsearchClients.createImperative(restClient, transportOptions()); | ||
return ElasticsearchClients.elasticsearchClient(restClient); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comment in ElasticsearchClients
about creation of beans. In addition to that, we cannot remove the transportOptions()
method from this abstract class, as it might be overridden by the user in a derived implementation.
@@ -81,7 +79,7 @@ public ElasticsearchClient elasticsearchClient(RestClient restClient) { | |||
*/ | |||
@Bean(name = { "elasticsearchOperations", "elasticsearchTemplate" }) | |||
public ElasticsearchOperations elasticsearchOperations(ElasticsearchConverter elasticsearchConverter, | |||
ElasticsearchClient elasticsearchClient) { | |||
ElasticsearchClient elasticsearchClient) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting change not compatible with code formatting guidelines
@@ -159,7 +160,6 @@ public <T> List<MultiGetItem<T>> multiGet(Query query, Class<T> clazz, IndexCoor | |||
.collect(Collectors.toList()); | |||
} | |||
|
|||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should we remove the @Override
annotations on these methods? This would remove the ability of the compiler to check if we are really implementing or overloading a method instead of overloading it.
Otherwise only irrelevant formatting changes
com/spring-projects/spring-data-elasticsearch/issues). Add the issue number to the Closes #issue-number line below
Closes #issue-number