Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaMaciaszek committed Oct 19, 2021
2 parents 66f7a84 + 2708581 commit 011b445
Show file tree
Hide file tree
Showing 26 changed files with 271 additions and 111 deletions.
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Spring Cloud is released under the non-restrictive Apache 2.0 license,
and follows a very standard Github development process, using Github
tracker for issues and merging pull requests into master. If you want
tracker for issues and merging pull requests into main. If you want
to contribute even something trivial please do not hesitate, but
follow the guidelines below.

Expand All @@ -17,7 +17,7 @@ given the ability to merge pull requests.

## Code of Conduct
This project adheres to the Contributor Covenant [code of
conduct](https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc). By participating, you are expected to uphold this code. Please report
conduct](https://github.com/spring-cloud/spring-cloud-build/blob/main/docs/src/main/asciidoc/code-of-conduct.adoc). By participating, you are expected to uphold this code. Please report
unacceptable behavior to spring-code-of-conduct@pivotal.io.

## Code Conventions and Housekeeping
Expand All @@ -27,7 +27,7 @@ added after the original pull request but before a merge.
* Use the Spring Framework code format conventions. If you use Eclipse
you can import formatter settings using the
`eclipse-code-formatter.xml` file from the
[Spring Cloud Build](https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml) project. If using IntelliJ, you can use the
[Spring Cloud Build](https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/spring-cloud-dependencies-parent/eclipse-code-formatter.xml) project. If using IntelliJ, you can use the
[Eclipse Code Formatter Plugin](https://plugins.jetbrains.com/plugin/6546) to import the same file.
* Make sure all new `.java` files to have a simple Javadoc class comment with at least an
`@author` tag identifying you, and preferably at least a paragraph on what the class is
Expand All @@ -38,7 +38,7 @@ added after the original pull request but before a merge.
than cosmetic changes).
* Add some Javadocs and, if you change the namespace, some XSD doc elements.
* A few unit tests would help a lot as well -- someone has to do it.
* If no-one else is using your branch, please rebase it against the current master (or
* If no-one else is using your branch, please rebase it against the current main (or
other target branch in the main project).
* When writing a commit message please follow [these conventions](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html),
if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ name: Build

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]


jobs:
build:
Expand All @@ -16,7 +17,7 @@ jobs:

strategy:
matrix:
java: ["8", "15", "16"]
java: ["8", "11", "16"]

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class OkHttpClientConfig {
@Bean
@LoadBalanced
public WebClient.Builder okHttpClientBuilder() {
public WebClient.Builder webClientBuilder() {
return WebClient.builder();
}
}
Expand Down Expand Up @@ -220,10 +220,10 @@ An application interceptor is added to the `OkHttpClient` created by auto-config

By supporting `OkHttpClient`, it enables Square's [Retrofit](https://square.github.io/retrofit/) to use Spring Cloud LoadBalancer as well.

See [`OkHttpLoadBalancerInterceptorTests`](https://github.com/spring-cloud-incubator/spring-cloud-square/blob/master/spring-cloud-square-okhttp/src/test/java/org/springframework/cloud/square/okhttp/loadbalancer/OkHttpLoadBalancerInterceptorTests.java) for Spring Cloud LoadBalancer samples.
See [`OkHttpLoadBalancerInterceptorTests`](https://github.com/spring-cloud-incubator/spring-cloud-square/blob/main/spring-cloud-square-okhttp/src/test/java/org/springframework/cloud/square/okhttp/loadbalancer/OkHttpLoadBalancerInterceptorTests.java) for Spring Cloud LoadBalancer samples.

== Spring WebClient

Support was also added for Spring WebClient. This implements an `okhttp3.Call.Factory` that uses `WebClient` under the covers. This provides a fully non-blocking shim instead of using `okhttp3`.

See [`WebClientRetrofitTests`](https://github.com/spring-cloud-incubator/spring-cloud-square/blob/master/spring-cloud-square-retrofit-webclient/src/test/java/org/springframework/cloud/square/retrofit/webclient/WebClientRetrofitTests.java) for WebClient samples.
See [`WebClientRetrofitTests`](https://github.com/spring-cloud-incubator/spring-cloud-square/blob/main/spring-cloud-square-retrofit-webclient/src/test/java/org/springframework/cloud/square/retrofit/webclient/WebClientRetrofitTests.java) for WebClient samples.
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ An application interceptor is added to the `OkHttpClient` created by auto-config

By supporting `OkHttpClient`, it enables Square's [Retrofit](https://square.github.io/retrofit/) to use Spring Cloud LoadBalancer as well.

See [`OkHttpLoadBalancerInterceptorTests`](https://github.com/spring-cloud-incubator/spring-cloud-square/blob/master/spring-cloud-square-okhttp/src/test/java/org/springframework/cloud/square/okhttp/loadbalancer/OkHttpLoadBalancerInterceptorTests.java) for Spring Cloud LoadBalancer samples.
See [`OkHttpLoadBalancerInterceptorTests`](https://github.com/spring-cloud-incubator/spring-cloud-square/blob/main/spring-cloud-square-okhttp/src/test/java/org/springframework/cloud/square/okhttp/loadbalancer/OkHttpLoadBalancerInterceptorTests.java) for Spring Cloud LoadBalancer samples.

== Spring WebClient

Support was also added for Spring WebClient. This implements an `okhttp3.Call.Factory` that uses `WebClient` under the covers. This provides a fully non-blocking shim instead of using `okhttp3`.

See [`WebClientRetrofitTests`](https://github.com/spring-cloud-incubator/spring-cloud-square/blob/master/spring-cloud-square-retrofit-webclient/src/test/java/org/springframework/cloud/square/retrofit/webclient/WebClientRetrofitTests.java) for WebClient samples.
See [`WebClientRetrofitTests`](https://github.com/spring-cloud-incubator/spring-cloud-square/blob/main/spring-cloud-square-retrofit-webclient/src/test/java/org/springframework/cloud/square/retrofit/webclient/WebClientRetrofitTests.java) for WebClient samples.
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/_attributes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
:docinfo: shared,private

:sc-ext: java
:project-full-name: Spring Cloud Commons
:all: {asterisk}{asterisk}
:project-full-name: Spring Cloud Square
:all: {asterisk}{asterisk}
10 changes: 5 additions & 5 deletions docs/src/main/asciidoc/ghpages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function check_if_anything_to_sync() {
}

function retrieve_current_branch() {
# Code getting the name of the current branch. For master we want to publish as we did until now
# Code getting the name of the current branch. For main we want to publish as we did until now
# https://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch
# If there is a branch already passed will reuse it - otherwise will try to find it
CURRENT_BRANCH=${BRANCH}
Expand Down Expand Up @@ -134,8 +134,8 @@ function add_docs_from_target() {

# Copies the docs by using the retrieved properties from Maven build
function copy_docs_for_current_version() {
if [[ "${CURRENT_BRANCH}" == "master" ]] ; then
echo -e "Current branch is master - will copy the current docs only to the root folder"
if [[ "${CURRENT_BRANCH}" == "main" ]] ; then
echo -e "Current branch is main - will copy the current docs only to the root folder"
for f in docs/target/generated-docs/*; do
file=${f#docs/target/generated-docs/*}
if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then
Expand Down Expand Up @@ -216,7 +216,7 @@ function commit_changes_if_applicable() {
git commit -a -m "Sync docs from ${CURRENT_BRANCH} to gh-pages" && COMMIT_SUCCESSFUL="yes" || echo "Failed to commit changes"

# Uncomment the following push if you want to auto push to
# the gh-pages branch whenever you commit to master locally.
# the gh-pages branch whenever you commit to main locally.
# This is a little extreme. Use with care!
###################################################################
if [[ "${COMMIT_SUCCESSFUL}" == "yes" ]] ; then
Expand Down Expand Up @@ -249,7 +249,7 @@ The idea of this script is to update gh-pages branch with the generated docs. Wi
the script will work in the following manner:
- if there's no gh-pages / target for docs module then the script ends
- for master branch the generated docs are copied to the root of gh-pages branch
- for main branch the generated docs are copied to the root of gh-pages branch
- for any other branch (if that branch is allowed) a subfolder with branch name is created
and docs are copied there
- if the version switch is passed (-v) then a tag with (v) prefix will be retrieved and a folder
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/quickstart.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class OkHttpClientConfig {
@Bean
@LoadBalanced
public WebClient.Builder okHttpClientBuilder() {
public WebClient.Builder webClientBuilder() {
return WebClient.builder();
}
}
Expand Down
8 changes: 5 additions & 3 deletions docs/src/main/asciidoc/spring-cloud-square.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ include::intro.adoc[]
NOTE: Spring Cloud is released under the non-restrictive Apache 2.0 license.
If you want to contribute to this section of the documentation or if you find an error, you can find the source code and issue trackers for the project at {docslink}[github].

Spring Cloud Square provides Spring Cloud LoadBalancer integration for https://square.github.io/okhttp/[OkHttpClient] and https://square.github.io/retrofit/[Retrofit], as well as a WebClient-backed Retrofit clients.

== Quick Start

include::quickstart.adoc[leveloffset=+1]

Spring Cloud Square provides Spring Cloud LoadBalancer integration for https://square.github.io/okhttp/[OkHttpClient] and https://square.github.io/retrofit/[Retrofit], as well as a WebClient-backed Retrofit clients.

== OkHttpClient Spring Cloud LoadBalancer Integration

An interceptor is added to the `OkHttpClient` created by auto-configuration to resolve the scheme, host, and port from Spring Cloud LoadBalancer and rewrite the URL.
Expand Down Expand Up @@ -149,14 +149,16 @@ class OkHttpClientConfig {
@Bean
@LoadBalanced
public WebClient.Builder okHttpClientBuilder() {
public WebClient.Builder webClientBuilder() {
return WebClient.builder();
}
}
----

They are used under the hood to run load-balanced HTTP requests.

NOTE: You can create various instances of `WebClient.Builder` with different setup. If a `@LoadBalanced WebClient.Builder` bean is found with name matching the pattern `[retrofit-context-name]WebClientBuilder`, it will be picked for the Retrofit context in question, otherwise the first found `@LoadBalaced WebClient.Builder` bean will be picked.


=== Retrofit Reactor support

Expand Down
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>3.0.3-SNAPSHOT</version>
<version>3.1.0-SNAPSHOT</version>
<relativePath/>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-cloud-commons.version>3.0.3-SNAPSHOT</spring-cloud-commons.version>
<spring-cloud-commons.version>3.1.0-SNAPSHOT
</spring-cloud-commons.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion spring-cloud-square-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>spring-cloud-dependencies-parent</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>3.0.2</version>
<version>3.1.0-SNAPSHOT</version>
<relativePath/>
</parent>
<artifactId>spring-cloud-square-dependencies</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.cloud.square.retrofit.core;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -66,9 +65,6 @@ public abstract class AbstractRetrofitClientsRegistrar

private ClassLoader classLoader;

public AbstractRetrofitClientsRegistrar() {
}

@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
Expand Down Expand Up @@ -257,26 +253,13 @@ protected ClassPathScanningCandidateComponentProvider getScanner() {

@Override
protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
boolean isCandidate = false;
if (beanDefinition.getMetadata().isIndependent()) {
// TODO until SPR-11711 will be resolved
if (beanDefinition.getMetadata().isInterface()
&& beanDefinition.getMetadata().getInterfaceNames().length == 1
&& Annotation.class.getName().equals(beanDefinition.getMetadata().getInterfaceNames()[0])) {
try {
Class<?> target = ClassUtils.forName(beanDefinition.getMetadata().getClassName(),
AbstractRetrofitClientsRegistrar.this.classLoader);
return !target.isAnnotation();
}
catch (Exception ex) {
this.logger.error(
"Could not load target class: " + beanDefinition.getMetadata().getClassName(), ex);

}
if (!beanDefinition.getMetadata().isAnnotation()) {
isCandidate = true;
}
return true;
}
return false;

return isCandidate;
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.lang.annotation.Target;

import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Indexed;

/**
* Annotation for interfaces declaring that a REST client with that interface should be
Expand All @@ -36,6 +37,7 @@
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Indexed
public @interface RetrofitClient {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public class RetrofitClientSpecification implements NamedContextFactory.Specific
public RetrofitClientSpecification(String name, Class<?>[] configuration) {
this.name = name;
this.configuration = configuration;
}

public RetrofitClientSpecification() {
}

public String getName() {
Expand Down Expand Up @@ -68,7 +66,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(name, configuration);
return Objects.hash(name, Arrays.hashCode(configuration));
}

@Override
Expand Down
5 changes: 5 additions & 0 deletions spring-cloud-square-retrofit-webclient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
/**
* List of classes annotated with @RetrofitClient. If not empty, disables classpath
* scanning.
* @return
* @return an array of {@link RetrofitClient}-annotated classes
*/
Class<?>[] clients() default {};

Expand Down
Loading

0 comments on commit 011b445

Please sign in to comment.