Skip to content

Commit 4c3fa64

Browse files
committed
Polish some comments
Signed-off-by: Hyunwoo Jung <[email protected]>
1 parent e621928 commit 4c3fa64

File tree

11 files changed

+62
-84
lines changed

11 files changed

+62
-84
lines changed

spring-cloud-function-adapters/spring-cloud-function-adapter-gcp/src/main/java/org/springframework/cloud/function/adapter/gcp/FunctionInvoker.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,11 @@ else if (result.getHeaders().containsKey("Content-Type")) {
211211
}
212212
}
213213

214-
/*
215-
* This methd get the result from reactor's publisher.
214+
/**
215+
* This method gets the result from reactor's publisher.
216216
*
217217
* For reference:
218-
* https://github.com/spring-cloud/spring-cloud-function/blob/main/spring-cloud-
219-
* function-adapters/spring-cloud-function-adapter-aws/src/main/java/org/
220-
* springframework/cloud/function/adapter/aws/AWSLambdaUtils.java
218+
* https://github.com/spring-cloud/spring-cloud-function/blob/main/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/main/java/org/springframework/cloud/function/adapter/aws/AWSLambdaUtils.java
221219
*/
222220
private Message<byte[]> getResultFromPublisher(Object resultObject) {
223221
List<Object> results = new ArrayList<>();

spring-cloud-function-adapters/spring-cloud-function-serverless-web/src/test/java/org/springframework/cloud/function/serverless/web/RequestResponseTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ public void errorUnexpectedWhitelabel() throws Exception {
147147
public void validatePostWithBody() throws Exception {
148148
ServerlessHttpServletRequest request = new ServerlessHttpServletRequest(null, "POST", "/pets/");
149149
String jsonPet = """
150-
{
151-
"id":"1234",
152-
"breed":"Canish",
153-
"name":"Foo",
154-
"date":"2012-04-23T18:25:43.511Z"
155-
}""";
150+
{
151+
"id":"1234",
152+
"breed":"Canish",
153+
"name":"Foo",
154+
"date":"2012-04-23T18:25:43.511Z"
155+
}""";
156156
request.setContent(jsonPet.getBytes());
157157
request.setContentType("application/json");
158158
ServerlessHttpServletResponse response = new ServerlessHttpServletResponse();

spring-cloud-function-context/src/main/java/org/springframework/cloud/function/cloudevent/CloudEventMessageUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public final class CloudEventMessageUtils {
5656

5757
@Override
5858
public MimeType resolve(@Nullable MessageHeaders headers) {
59-
if (headers.containsKey("content-type")) { // this is temporary workaround for
60-
// RSocket
59+
if (headers.containsKey("content-type")) {
60+
// this is temporary workaround for RSocket
6161
return MimeType.valueOf(headers.get("content-type").toString());
6262
}
6363
return super.resolve(headers);

spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/FunctionRegistration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public FunctionRegistration<T> type(Type type) {
121121
return this;
122122
}
123123
Type discoveredFunctionType = type; // FunctionTypeUtils.discoverFunctionTypeFromClass(this.target.getClass());
124-
if (discoveredFunctionType == null) { // only valid for Kafka Stream KStream[]
125-
// return type.
124+
if (discoveredFunctionType == null) {
125+
// only valid for Kafka Stream KStream[] return type.
126126
return null;
127127
}
128128

spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/FunctionTypeUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,8 @@ public static Type discoverFunctionType(Object function, String functionName,
453453
else if (function instanceof FunctionRegistration) {
454454
return ((FunctionRegistration) function).getType();
455455
}
456-
if (applicationContext.containsBean(functionName + FunctionRegistration.REGISTRATION_NAME_SUFFIX)) { // for
457-
// Kotlin
458-
// primarily
456+
if (applicationContext.containsBean(functionName + FunctionRegistration.REGISTRATION_NAME_SUFFIX)) {
457+
// for Kotlin primarily
459458
FunctionRegistration fr = applicationContext
460459
.getBean(functionName + FunctionRegistration.REGISTRATION_NAME_SUFFIX, FunctionRegistration.class);
461460
return fr.getType();

spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/config/RoutingFunction.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,21 @@ public Object apply(Object input) {
114114

115115
/*
116116
* - Check if `this.routingCallback` is present and if it is use it (only for Message
117-
* input) If NOT - Check if spring.cloud.function.definition is set in header and if
118-
* it is use it.(only for Message input) If NOT - Check if
119-
* spring.cloud.function.routing-expression is set in header and if it is set use it
120-
* (only for Message input) If NOT - Check `spring.cloud.function.definition` is set
121-
* in FunctionProperties and if it is use it (Message and Publisher) If NOT - Check
122-
* `spring.cloud.function.routing-expression` is set in FunctionProperties and if it
123-
* is use it (Message and Publisher) If NOT - Fail
117+
* input)
118+
*
119+
* If NOT - Check if spring.cloud.function.definition is set in header and if it is
120+
* use it.(only for Message input)
121+
*
122+
* If NOT - Check if spring.cloud.function.routing-expression is set in header and if
123+
* it is set use it (only for Message input)
124+
*
125+
* If NOT - Check `spring.cloud.function.definition` is set in FunctionProperties and
126+
* if it is use it (Message and Publisher)
127+
*
128+
* If NOT - Check `spring.cloud.function.routing-expression` is set in
129+
* FunctionProperties and if it is use it (Message and Publisher)
130+
*
131+
* If NOT - Fail
124132
*/
125133
private Object route(Object input, boolean originalInputIsPublisher) {
126134
FunctionInvocationWrapper function = null;

spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/config/SmartCompositeMessageConverter.java

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,10 @@ public Object fromMessage(Message<?> message, Class<?> targetClass, @Nullable Ob
113113
for (Iterator<MessageConverter> iterator = getConverters().iterator(); iterator.hasNext()
114114
&& !isConverted;) {
115115
MessageConverter converter = (MessageConverter) iterator.next();
116-
if (!converter.getClass().getName().endsWith("ApplicationJsonMessageMarshallingConverter")) { // TODO
117-
// Stream
118-
// stuff,
119-
// needs
120-
// to
121-
// be
122-
// removed
123-
Message<?> m = MessageBuilder.withPayload(item).copyHeaders(message.getHeaders()).build(); // TODO
124-
// Message
125-
// creating
126-
// may
127-
// be
128-
// expensive
116+
// TODO Stream stuff, needs to be removed
117+
if (!converter.getClass().getName().endsWith("ApplicationJsonMessageMarshallingConverter")) {
118+
// TODO Message creating may be expensive
119+
Message<?> m = MessageBuilder.withPayload(item).copyHeaders(message.getHeaders()).build();
129120
Object conversionResult = (converter instanceof SmartMessageConverter
130121
& genericItemRawType != genericItemType
131122
? ((SmartMessageConverter) converter).fromMessage(m, genericItemRawType,
@@ -146,13 +137,8 @@ public Object fromMessage(Message<?> message, Class<?> targetClass, @Nullable Ob
146137
}
147138
else {
148139
for (MessageConverter converter : getConverters()) {
149-
if (!converter.getClass().getName().endsWith("ApplicationJsonMessageMarshallingConverter")) { // TODO
150-
// Stream
151-
// stuff,
152-
// needs
153-
// to
154-
// be
155-
// removed
140+
// TODO Stream stuff, needs to be removed
141+
if (!converter.getClass().getName().endsWith("ApplicationJsonMessageMarshallingConverter")) {
156142
result = (converter instanceof SmartMessageConverter
157143
? ((SmartMessageConverter) converter).fromMessage(message, targetClass, conversionHint)
158144
: converter.fromMessage(message, targetClass));

spring-cloud-function-context/src/test/java/org/springframework/cloud/function/cloudevent/CloudEventFunctionTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ public void testStructuredPojoToPojoDefaultOutputAttributeProvider() throws Exce
244244
assertThat(resultMessage.getPayload().getReleaseDate())
245245
.isEqualTo(new SimpleDateFormat("dd-MM-yyyy").parse("01-10-2006"));
246246
assertThat(resultMessage.getPayload().getVersion()).isEqualTo("2.0");
247-
// /*
248-
// * Validates that although user only deals with POJO, the framework recognizes
249-
// * both on input and output that it is dealing with Cloud Event and generates
250-
// * appropriate headers/attributes
251-
// */
247+
/*
248+
* Validates that although user only deals with POJO, the framework recognizes
249+
* both on input and output that it is dealing with Cloud Event and generates
250+
* appropriate headers/attributes
251+
*/
252252
assertThat(CloudEventMessageUtils.isCloudEvent(resultMessage)).isTrue();
253253
assertThat(CloudEventMessageUtils.getType(resultMessage)).isEqualTo(SpringReleaseEvent.class.getName());
254254
assertThat(CloudEventMessageUtils.getSource(resultMessage)).isEqualTo(URI.create("http://spring.io/"));
@@ -282,11 +282,11 @@ public void testStructuredPojoToPojoMessageFunction() throws Exception {
282282
assertThat(resultMessage.getPayload().getReleaseDate())
283283
.isEqualTo(new SimpleDateFormat("dd-MM-yyyy").parse("01-10-2006"));
284284
assertThat(resultMessage.getPayload().getVersion()).isEqualTo("2.0");
285-
// /*
286-
// * Validates that although user only deals with POJO, the framework recognizes
287-
// * both on input and output that it is dealing with Cloud Event and generates
288-
// * appropriate headers/attributes
289-
// */
285+
/*
286+
* Validates that although user only deals with POJO, the framework recognizes
287+
* both on input and output that it is dealing with Cloud Event and generates
288+
* appropriate headers/attributes
289+
*/
290290
assertThat(CloudEventMessageUtils.isCloudEvent(resultMessage)).isTrue();
291291
assertThat(CloudEventMessageUtils.getType(resultMessage)).isEqualTo(SpringReleaseEvent.class.getName());
292292
assertThat(CloudEventMessageUtils.getSource(resultMessage))

spring-cloud-function-context/src/test/java/org/springframework/cloud/function/cloudevent/CloudEventMessageUtilsAndBuilderTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public void testAttributeRecognitionAndCanonicalization() {
8080
Message<String> kafkaMessage = CloudEventMessageBuilder.fromMessage(httpMessage)
8181
.build(CloudEventMessageUtils.KAFKA_ATTR_PREFIX);
8282
attributes = CloudEventMessageUtils.getAttributes(kafkaMessage);
83-
assertThat(attributes.size()).isEqualTo(4); // id will be auto injected, so always
84-
// at least 4 (as tehre are 4 required
85-
// attributes in CE)
83+
// id will be auto injected, so always at least 4 (as there are 4 required
84+
// attributes in CE)
85+
assertThat(attributes.size()).isEqualTo(4);
8686
assertThat(kafkaMessage.getHeaders().get("ce_source")).isNotNull();
8787
assertThat(CloudEventMessageUtils.getSource(kafkaMessage)).isEqualTo(URI.create("https://foo.bar"));
8888
assertThat(kafkaMessage.getHeaders().get("ce_type")).isNotNull();

spring-cloud-function-context/src/test/java/org/springframework/cloud/function/context/catalog/BeanFactoryAwareFunctionRegistryTests.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ public void testImperativeFunction() {
314314
}
315315

316316
@Test
317-
public void testConsumerFunction() { // function that returns Void, effectively a
318-
// Consumer
317+
public void testConsumerFunction() {
318+
// function that returns Void, effectively a Consumer
319319
FunctionCatalog catalog = this.configureCatalog();
320320

321321
Function<String, Void> consumerFunction = catalog.lookup("consumerFunction");
@@ -1436,14 +1436,8 @@ public static class SCF_GH_768ConfigurationAsFunction {
14361436
public Function<Map<String, Date>, String> echoToString() {
14371437
return data -> {
14381438
for (Entry<String, Date> dataEntry : data.entrySet()) {
1439-
assertThat(dataEntry.getValue()).isInstanceOf(Date.class); // would
1440-
// fail if
1441-
// value
1442-
// would
1443-
// not be
1444-
// converted
1445-
// to
1446-
// Person
1439+
// would fail if value would not be converted to Person
1440+
assertThat(dataEntry.getValue()).isInstanceOf(Date.class);
14471441
}
14481442
return data.toString();
14491443
};

0 commit comments

Comments
 (0)