Skip to content

Commit f7f7979

Browse files
committed
Merge remote-tracking branch 'origin/main' into 7-in-proccess-transport-testing
2 parents 296653e + ee994e0 commit f7f7979

File tree

53 files changed

+1463
-451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1463
-451
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ Before submitting a PR, please run the following commands to ensure proper forma
1010

1111
The `-Pjavadoc` is a profile that enables Javadoc processing so as to avoid a long build time when developing.
1212

13+
<dl><dt><strong>📌 NOTE</strong></dt><dd>
14+
15+
We use the [Spring JavaFormat](https://github.com/spring-io/spring-javaformat) project to apply code formatting conventions as well as checkstyle rules for many of our code conventions.
16+
17+
The code can also be formatted from your IDE when the formatter plugin [has been installed](https://github.com/spring-projects-experimental/spring-grpc/wiki/Working-with-the-Code#install-the-spring-formatter-plugin).
18+
</dd></dl>
19+
1320
## Contributing a New GRPC Features
1421

1522
To contribute a new feature, adhere to the following steps:

idea/codeStyleConfig.xml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<code_scheme name="Spring gRPC" version="173">
2+
<option name="AUTODETECT_INDENTS" value="false"/>
3+
<option name="OTHER_INDENT_OPTIONS">
4+
<value>
5+
<option name="USE_TAB_CHARACTER" value="true"/>
6+
</value>
7+
</option>
8+
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="50"/>
9+
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500"/>
10+
<option name="IMPORT_LAYOUT_TABLE">
11+
<value>
12+
<package name="java" withSubpackages="true" static="false"/>
13+
<emptyLine/>
14+
<package name="javax" withSubpackages="true" static="false"/>
15+
<emptyLine/>
16+
<package name="" withSubpackages="true" static="false"/>
17+
<emptyLine/>
18+
<package name="org.springframework" withSubpackages="true" static="false"/>
19+
<emptyLine/>
20+
<package name="" withSubpackages="true" static="true"/>
21+
</value>
22+
</option>
23+
<option name="RIGHT_MARGIN" value="90"/>
24+
<option name="ENABLE_JAVADOC_FORMATTING" value="false"/>
25+
<option name="JD_ALIGN_PARAM_COMMENTS" value="false"/>
26+
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false"/>
27+
<option name="JD_KEEP_EMPTY_LINES" value="false"/>
28+
<GroovyCodeStyleSettings>
29+
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500"/>
30+
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500"/>
31+
<option name="IMPORT_LAYOUT_TABLE">
32+
<value>
33+
<emptyLine/>
34+
<package name="javax" withSubpackages="true" static="false"/>
35+
<package name="java" withSubpackages="true" static="false"/>
36+
<emptyLine/>
37+
<package name="" withSubpackages="true" static="false"/>
38+
<emptyLine/>
39+
<package name="org.springframework" withSubpackages="true"
40+
static="false"/>
41+
<emptyLine/>
42+
<package name="" withSubpackages="true" static="true"/>
43+
</value>
44+
</option>
45+
</GroovyCodeStyleSettings>
46+
<JavaCodeStyleSettings>
47+
<option name="CLASS_NAMES_IN_JAVADOC" value="3"/>
48+
<option name="INSERT_INNER_CLASS_IMPORTS" value="true"/>
49+
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="50"/>
50+
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500"/>
51+
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
52+
<value/>
53+
</option>
54+
<option name="IMPORT_LAYOUT_TABLE">
55+
<value>
56+
<package name="" withSubpackages="true" static="true"/>
57+
<emptyLine/>
58+
<package name="java" withSubpackages="true" static="false"/>
59+
<emptyLine/>
60+
<package name="javax" withSubpackages="true" static="false"/>
61+
<emptyLine/>
62+
<package name="org" withSubpackages="true" static="false"/>
63+
<emptyLine/>
64+
<package name="org.springframework" withSubpackages="true" static="false"/>
65+
</value>
66+
</option>
67+
<option name="ENABLE_JAVADOC_FORMATTING" value="false"/>
68+
<option name="JD_ALIGN_PARAM_COMMENTS" value="false"/>
69+
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false"/>
70+
<option name="JD_KEEP_INVALID_TAGS" value="false"/>
71+
<option name="JD_KEEP_EMPTY_LINES" value="false"/>
72+
</JavaCodeStyleSettings>
73+
<JetCodeStyleSettings>
74+
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
75+
<value>
76+
<package name="java.util" withSubpackages="false" static="false"/>
77+
<package name="kotlinx.android.synthetic" withSubpackages="false"
78+
static="false"/>
79+
</value>
80+
</option>
81+
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="20"/>
82+
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="20"/>
83+
</JetCodeStyleSettings>
84+
<XML>
85+
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true"/>
86+
</XML>
87+
<editorconfig>
88+
<option name="ENABLED" value="false"/>
89+
</editorconfig>
90+
<codeStyleSettings language="Groovy">
91+
<indentOptions>
92+
<option name="USE_TAB_CHARACTER" value="true"/>
93+
</indentOptions>
94+
</codeStyleSettings>
95+
<codeStyleSettings language="JAVA">
96+
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1"/>
97+
<option name="BLANK_LINES_AROUND_FIELD" value="1"/>
98+
<option name="BLANK_LINES_AROUND_FIELD_IN_INTERFACE" value="1"/>
99+
<option name="ELSE_ON_NEW_LINE" value="true"/>
100+
<option name="CATCH_ON_NEW_LINE" value="true"/>
101+
<option name="FINALLY_ON_NEW_LINE" value="true"/>
102+
<option name="ALIGN_MULTILINE_PARAMETERS" value="false"/>
103+
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true"/>
104+
<option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true"/>
105+
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true"/>
106+
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true"/>
107+
<option name="KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE" value="true"/>
108+
<indentOptions>
109+
<option name="USE_TAB_CHARACTER" value="true"/>
110+
</indentOptions>
111+
</codeStyleSettings>
112+
<codeStyleSettings language="JSON">
113+
<indentOptions>
114+
<option name="TAB_SIZE" value="2"/>
115+
</indentOptions>
116+
</codeStyleSettings>
117+
<codeStyleSettings language="XML">
118+
<indentOptions>
119+
<option name="USE_TAB_CHARACTER" value="true"/>
120+
</indentOptions>
121+
</codeStyleSettings>
122+
<codeStyleSettings language="kotlin">
123+
<indentOptions>
124+
<option name="USE_TAB_CHARACTER" value="true"/>
125+
</indentOptions>
126+
</codeStyleSettings>
127+
</code_scheme>

pom.xml

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<spring-boot.version>3.3.4</spring-boot.version>
7979
<jackson.version>2.17.2</jackson.version>
8080
<junit.version>5.10.5</junit.version>
81-
81+
<assertj.version>3.26.3</assertj.version>
8282
<!-- documentation dependencies -->
8383
<io.spring.maven.antora-version>0.0.4</io.spring.maven.antora-version>
8484
<asciidoctorj-pdf.version>1.6.2</asciidoctorj-pdf.version> <!-- FIXME build failure with
@@ -103,8 +103,17 @@
103103
<maven-site-plugin.version>4.0.0-M13</maven-site-plugin.version>
104104
<maven-project-info-reports-plugin.version>3.4.5</maven-project-info-reports-plugin.version>
105105
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
106-
<spring-javaformat-maven-plugin.version>0.0.39</spring-javaformat-maven-plugin.version>
107-
106+
<!-- BEGIN format + checkstyle properties -->
107+
<spring-javaformat-maven-plugin.version>0.0.43</spring-javaformat-maven-plugin.version>
108+
<maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
109+
<puppycrawl-tools-checkstyle.version>9.3</puppycrawl-tools-checkstyle.version>
110+
<spring-javaformat-checkstyle.version>0.0.43</spring-javaformat-checkstyle.version>
111+
<disable.format.checks>false</disable.format.checks>
112+
<disable.checkstyle.checks>false</disable.checkstyle.checks>
113+
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError>
114+
<maven-checkstyle-plugin.failOnViolation>true</maven-checkstyle-plugin.failOnViolation>
115+
<maven-checkstyle-plugin.includeTestSourceDirectory>true</maven-checkstyle-plugin.includeTestSourceDirectory>
116+
<!-- END format + checkstyle properties -->
108117
</properties>
109118

110119
<build>
@@ -117,12 +126,53 @@
117126
<execution>
118127
<phase>validate</phase>
119128
<inherited>true</inherited>
129+
<configuration>
130+
<skip>${disable.format.checks}</skip>
131+
</configuration>
120132
<goals>
121133
<goal>validate</goal>
122134
</goals>
123135
</execution>
124136
</executions>
125137
</plugin>
138+
<plugin>
139+
<groupId>org.apache.maven.plugins</groupId>
140+
<artifactId>maven-checkstyle-plugin</artifactId>
141+
<version>${maven-checkstyle-plugin.version}</version>
142+
<dependencies>
143+
<dependency>
144+
<groupId>com.puppycrawl.tools</groupId>
145+
<artifactId>checkstyle</artifactId>
146+
<version>${puppycrawl-tools-checkstyle.version}</version>
147+
</dependency>
148+
<dependency>
149+
<groupId>io.spring.javaformat</groupId>
150+
<artifactId>spring-javaformat-checkstyle</artifactId>
151+
<version>${spring-javaformat-checkstyle.version}</version>
152+
</dependency>
153+
</dependencies>
154+
<executions>
155+
<execution>
156+
<id>checkstyle-validation</id>
157+
<phase>validate</phase>
158+
<inherited>true</inherited>
159+
<configuration>
160+
<configLocation>src/checkstyle/checkstyle.xml</configLocation>
161+
<propertyExpansion>
162+
config_loc=src/checkstyle
163+
</propertyExpansion>
164+
<skip>${disable.checkstyle.checks}</skip>
165+
<includeTestSourceDirectory>${maven-checkstyle-plugin.includeTestSourceDirectory}</includeTestSourceDirectory>
166+
<failsOnError>${maven-checkstyle-plugin.failsOnError}</failsOnError>
167+
<failOnViolation>${maven-checkstyle-plugin.failOnViolation}</failOnViolation>
168+
<consoleOutput>true</consoleOutput>
169+
</configuration>
170+
<goals>
171+
<goal>check</goal>
172+
</goals>
173+
</execution>
174+
</executions>
175+
</plugin>
126176
<plugin>
127177
<groupId>org.apache.maven.plugins</groupId>
128178
<artifactId>maven-site-plugin</artifactId>
@@ -438,6 +488,20 @@
438488
<type>pom</type>
439489
<scope>import</scope>
440490
</dependency>
491+
<dependency>
492+
<groupId>org.junit</groupId>
493+
<artifactId>junit-bom</artifactId>
494+
<version>${junit.version}</version>
495+
<type>pom</type>
496+
<scope>import</scope>
497+
</dependency>
498+
<dependency>
499+
<groupId>org.assertj</groupId>
500+
<artifactId>assertj-bom</artifactId>
501+
<version>${assertj.version}</version>
502+
<type>pom</type>
503+
<scope>import</scope>
504+
</dependency>
441505
</dependencies>
442506
</dependencyManagement>
443507

samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerIntegrationTests.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@ void clientChannelWithSsl(@Autowired GrpcChannelFactory channels) {
119119

120120
}
121121

122+
@Nested
123+
@SpringBootTest(properties = { "spring.grpc.server.port=0", "spring.grpc.server.ssl.client-auth=REQUIRE",
124+
"spring.grpc.server.ssl.secure=false",
125+
"spring.grpc.client.channels.test-channel.address=static://0.0.0.0:${local.grpc.port}",
126+
"spring.grpc.client.channels.test-channel.ssl.bundle=ssltest",
127+
"spring.grpc.client.channels.test-channel.negotiation-type=TLS",
128+
"spring.grpc.client.channels.test-channel.secure=false" })
129+
@ActiveProfiles("ssl")
130+
@DirtiesContext
131+
class ServerWithClientAuth {
132+
133+
@Test
134+
void clientChannelWithSsl(@Autowired GrpcChannelFactory channels) {
135+
assertThatResponseIsServedToChannel(channels.createChannel("test-channel").build());
136+
}
137+
138+
}
139+
122140
private void assertThatResponseIsServedToChannel(ManagedChannel clientChannel) {
123141
SimpleGrpc.SimpleBlockingStub client = SimpleGrpc.newBlockingStub(clientChannel);
124142
HelloReply response = client.sayHello(HelloRequest.newBuilder().setName("Alien").build());

spring-grpc-core/pom.xml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66
<parent>
77
<groupId>org.springframework.grpc</groupId>
@@ -16,8 +16,10 @@
1616

1717
<scm>
1818
<url>https://github.com/spring-projects-experimental/spring-grpc</url>
19-
<connection>git://github.com/spring-projects-experimental/spring-grpc.git</connection>
20-
<developerConnection>git@github.com:spring-projects-experimental/spring-grpc.git</developerConnection>
19+
<connection>git://github.com/spring-projects-experimental/spring-grpc.git
20+
</connection>
21+
<developerConnection>git@github.com:spring-projects-experimental/spring-grpc.git
22+
</developerConnection>
2123
</scm>
2224

2325
<dependencies>
@@ -70,7 +72,11 @@
7072
<dependency>
7173
<groupId>org.junit.jupiter</groupId>
7274
<artifactId>junit-jupiter</artifactId>
73-
<version>${junit.version}</version>
75+
<scope>test</scope>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.assertj</groupId>
79+
<artifactId>assertj-core</artifactId>
7480
<scope>test</scope>
7581
</dependency>
7682

spring-grpc-core/src/main/java/org/springframework/grpc/client/NettyGrpcChannelFactory.java renamed to spring-grpc-core/src/main/java/org/springframework/grpc/client/ChannelCredentialsProvider.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,23 @@
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
15-
*/
16-
package org.springframework.grpc.client;
15+
* */
1716

18-
import java.util.List;
17+
package org.springframework.grpc.client;
1918

20-
import io.grpc.ManagedChannelBuilder;
21-
import io.grpc.netty.NettyChannelBuilder;
19+
import io.grpc.ChannelCredentials;
20+
import io.grpc.InsecureChannelCredentials;
2221

23-
public class NettyGrpcChannelFactory extends DefaultGrpcChannelFactory {
22+
/**
23+
* A provider for obtaining channel credentials for gRPC client.
24+
*
25+
* @author David Syer
26+
*/
27+
public interface ChannelCredentialsProvider {
2428

25-
public NettyGrpcChannelFactory(List<GrpcChannelConfigurer> configurers) {
26-
super(configurers);
27-
}
29+
/** Insecure credentials provider instance. */
30+
ChannelCredentialsProvider INSECURE = path -> InsecureChannelCredentials.create();
2831

29-
protected ManagedChannelBuilder<?> newChannel(String path) {
30-
if (path.startsWith("unix:")) {
31-
return super.newChannel(path);
32-
}
33-
return NettyChannelBuilder.forTarget(path);
34-
}
32+
ChannelCredentials getChannelCredentials(String path);
3533

3634
}

0 commit comments

Comments
 (0)