Skip to content

Commit

Permalink
Updates to*Case() to use Locale.ROOT
Browse files Browse the repository at this point in the history
  • Loading branch information
spencergibb committed Oct 18, 2024
1 parent 8f9c17f commit d120eb0
Show file tree
Hide file tree
Showing 83 changed files with 262 additions and 178 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.cloud.function.adapter.aws;

import java.util.Locale;
import java.util.function.Function;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -219,7 +220,7 @@ public void test_definitionLookupAndComposition() throws Exception {
protected static class SingleFunctionConfiguration {
@Bean
public Function<String, String> uppercase() {
return v -> v.toUpperCase();
return v -> v.toUpperCase(Locale.ROOT);
}
}

Expand All @@ -236,7 +237,7 @@ public Function<Flux<String>, Flux<String>> uppercase() {
protected static class MultipleFunctionConfiguration {
@Bean
public Function<String, String> uppercase() {
return v -> v.toUpperCase();
return v -> v.toUpperCase(Locale.ROOT);
}

@Bean
Expand All @@ -246,7 +247,7 @@ public Function<String, String> toPersonJson() {

@Bean
public Function<Person, Person> uppercasePerson() {
return p -> new Person(p.getName().toUpperCase());
return p -> new Person(p.getName().toUpperCase(Locale.ROOT));
}

@Bean
Expand All @@ -267,7 +268,7 @@ public PersonFunction() {

@Override
public Person apply(Person input) {
return new Person(input.getName().toUpperCase());
return new Person(input.getName().toUpperCase(Locale.ROOT));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Base64;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
Expand Down Expand Up @@ -1492,7 +1493,7 @@ public static class BasicConfiguration {
@Bean
public Function<Message<String>, Message<String>> uppercase() {
return v -> {
return MessageBuilder.withPayload(v.getPayload().toUpperCase()).build();
return MessageBuilder.withPayload(v.getPayload().toUpperCase(Locale.ROOT)).build();
};
}
}
Expand Down Expand Up @@ -1525,7 +1526,7 @@ public Function<String, String> echoString() {

@Bean
public Function<String, String> uppercase() {
return v -> v.toUpperCase();
return v -> v.toUpperCase(Locale.ROOT);
}

@Bean
Expand Down Expand Up @@ -1784,7 +1785,7 @@ public Consumer<String> consume() {

@Bean
public Function<String, String> uppercase() {
return v -> v.toUpperCase();
return v -> v.toUpperCase(Locale.ROOT);
}

@Bean
Expand All @@ -1795,15 +1796,15 @@ public Function<Mono<String>, Mono<Void>> reactiveWithVoidReturn() {
@Bean
public Function<Person, String> uppercasePojo() {
return v -> {
return v.getName().toUpperCase();
return v.getName().toUpperCase(Locale.ROOT);
};
}

@Bean
public Function<Person, Person> uppercasePojoReturnPojo() {
return v -> {
Person p = new Person();
p.setName(v.getName().toUpperCase());
p.setName(v.getName().toUpperCase(Locale.ROOT));
return p;
};
}
Expand All @@ -1812,7 +1813,7 @@ public Function<Person, Person> uppercasePojoReturnPojo() {
public Function<Flux<Person>, Flux<Person>> uppercasePojoReturnPojoReactive() {
return flux -> flux.map(v -> {
Person p = new Person();
p.setName(v.getName().toUpperCase());
p.setName(v.getName().toUpperCase(Locale.ROOT));
return p;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -184,7 +185,7 @@ static class TestFunctionsConfig {

@Bean
public Function<String, String> imperativeUppercase() {
return (s) -> s.toUpperCase();
return (s) -> s.toUpperCase(Locale.ROOT);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
Expand Down Expand Up @@ -195,7 +196,7 @@ public Function<Flux<String>, Flux<String>> echoStream() {

@Bean
public Function<Mono<String>, Mono<String>> uppercaseMono() {
return f -> f.map(v -> v.toUpperCase());
return f -> f.map(v -> v.toUpperCase(Locale.ROOT));
}

}
Expand Down Expand Up @@ -241,7 +242,7 @@ protected static class BareConfig {

@Bean("uppercase")
public Function<Flux<Foo>, Flux<Bar>> function() {
return foos -> foos.map(foo -> new Bar(foo.getValue().toUpperCase()));
return foos -> foos.map(foo -> new Bar(foo.getValue().toUpperCase(Locale.ROOT)));
}

}
Expand All @@ -256,7 +257,7 @@ public Function<Message<Foo>, Bar> uppercase() {
Foo foo = message.getPayload();
ExecutionContext targetContext = (ExecutionContext) message.getHeaders().get("executionContext");
targetContext.getLogger().info("Invoking 'uppercase' on " + foo.getValue());
return new Bar(foo.getValue().toUpperCase());
return new Bar(foo.getValue().toUpperCase(Locale.ROOT));
};
}

Expand All @@ -269,7 +270,7 @@ protected static class ListConfig {
@Bean
public Function<List<Foo>, List<Bar>> uppercase() {
return foos -> {
List<Bar> bars = foos.stream().map(foo -> new Bar(foo.getValue().toUpperCase()))
List<Bar> bars = foos.stream().map(foo -> new Bar(foo.getValue().toUpperCase(Locale.ROOT)))
.collect(Collectors.toList());
return bars;
};
Expand All @@ -283,7 +284,7 @@ protected static class CollectConfig {

@Bean
public Function<List<Foo>, Bar> uppercase() {
return foos -> new Bar(foos.stream().map(foo -> foo.getValue().toUpperCase())
return foos -> new Bar(foos.stream().map(foo -> foo.getValue().toUpperCase(Locale.ROOT))
.collect(Collectors.joining(",")));
}

Expand All @@ -300,7 +301,7 @@ public Function<Message<Foo>, Bar> uppercase() {
ExecutionContext context = (ExecutionContext) message.getHeaders().get("executionContext");
Foo foo = message.getPayload();
context.getLogger().info("Executing uppercase function");
return new Bar(foo.getValue().toUpperCase());
return new Bar(foo.getValue().toUpperCase(Locale.ROOT));
};
}

Expand All @@ -310,7 +311,7 @@ public Function<Message<Bar>, Foo> lowercase() {
ExecutionContext context = (ExecutionContext) message.getHeaders().get("executionContext");
Bar bar = message.getPayload();
context.getLogger().info("Executing lowercase function");
return new Foo(bar.getValue().toLowerCase());
return new Foo(bar.getValue().toLowerCase(Locale.ROOT));
};
}

Expand All @@ -330,11 +331,11 @@ class Foo {
}

public String lowercase() {
return this.value.toLowerCase();
return this.value.toLowerCase(Locale.ROOT);
}

public String uppercase() {
return this.value.toUpperCase();
return this.value.toUpperCase(Locale.ROOT);
}

public String getValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
Expand Down Expand Up @@ -122,7 +123,7 @@ public Function<Message<Foo>, Message<Bar>> function() {
return (foo -> {
Map<String, Object> headers = new HashMap<>();
return new GenericMessage<>(
new Bar(foo.getPayload().getValue().toUpperCase()), headers);
new Bar(foo.getPayload().getValue().toUpperCase(Locale.ROOT)), headers);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.cloud.function.adapter.azure.injector;

import java.util.Locale;
import java.util.Optional;
import java.util.function.Function;

Expand Down Expand Up @@ -106,7 +107,7 @@ public Function<Message<String>, String> uppercaseBean() {
Assertions.assertThat(context).isNotNull();
Assertions.assertThat(context.getFunctionName()).isEqualTo("hello");

return message.getPayload().toUpperCase();
return message.getPayload().toUpperCase(Locale.ROOT);
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.cloud.function.adapter.azure.injector;

import java.util.Iterator;
import java.util.Locale;
import java.util.Optional;
import java.util.ServiceLoader;
import java.util.function.Function;
Expand Down Expand Up @@ -108,7 +109,7 @@ public Function<Message<String>, String> uppercase() {
.get(AzureFunctionUtil.EXECUTION_CONTEXT);
Assertions.assertThat(context).isNotNull();
Assertions.assertThat(context.getFunctionName()).isEqualTo("hello");
return message.getPayload().toUpperCase();
return message.getPayload().toUpperCase(Locale.ROOT);
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.cloud.function.adapter.gcp.integration;

import java.io.IOException;
import java.util.Locale;
import java.util.function.Function;
import java.util.function.Supplier;

Expand Down Expand Up @@ -98,7 +99,7 @@ static class CloudFunctionMainSingular {

@Bean
Function<String, String> uppercase() {
return input -> input.toUpperCase();
return input -> input.toUpperCase(Locale.ROOT);
}

}
Expand All @@ -109,7 +110,7 @@ static class CloudFunctionMain {

@Bean
Function<String, String> uppercase() {
return input -> input.toUpperCase();
return input -> input.toUpperCase(Locale.ROOT);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.function.Function;

Expand Down Expand Up @@ -323,17 +324,17 @@ public static class SampleConfiguration {

@Bean
public Function<String, String> uppercase() {
return v -> v.toUpperCase();
return v -> v.toUpperCase(Locale.ROOT);
}

@Bean
public Function<String, Mono<String>> uppercaseMonoReturn() {
return v -> Mono.just(v.toUpperCase());
return v -> Mono.just(v.toUpperCase(Locale.ROOT));
}

@Bean
public Function<String, Flux<String>> uppercaseFluxReturn() {
return v -> Flux.just(v.toUpperCase(), v.toUpperCase() + "-1", v.toUpperCase() + "-2");
return v -> Flux.just(v.toUpperCase(Locale.ROOT), v.toUpperCase(Locale.ROOT) + "-1", v.toUpperCase(Locale.ROOT) + "-2");
}

@Bean
Expand All @@ -343,7 +344,7 @@ public Function<String, String> reverse() {

@Bean
public Function<Flux<String>, Flux<String>> uppercaseReactive() {
return flux -> flux.map(v -> v.toUpperCase());
return flux -> flux.map(v -> v.toUpperCase(Locale.ROOT));
}

@Bean
Expand All @@ -360,7 +361,7 @@ public Function<Flux<String>, String> streamInStringOut() {

@Bean
public Function<String, Flux<String>> stringInStreamOut() {
return value -> Flux.just(value, value.toUpperCase());
return value -> Flux.just(value, value.toUpperCase(Locale.ROOT));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.function.Consumer;

Expand Down Expand Up @@ -157,7 +158,7 @@ private Banner printBanner(ConfigurableEnvironment environment) {
ResourceLoader resourceLoader = (this.getResourceLoader() != null) ? this.getResourceLoader()
: new DefaultResourceLoader(null);
Banner.Mode bannerMode = environment.containsProperty("spring.main.banner-mode")
? Banner.Mode.valueOf(environment.getProperty("spring.main.banner-mode").trim().toUpperCase())
? Banner.Mode.valueOf(environment.getProperty("spring.main.banner-mode").trim().toUpperCase(Locale.ROOT))
: Banner.Mode.CONSOLE;

if (bannerMode == Banner.Mode.OFF) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.cloud.function.actuator;

import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
Expand Down Expand Up @@ -72,10 +73,10 @@ else if (function.isConsumer()) {


private String toSimplePolyOut(FunctionInvocationWrapper function) {
return FunctionTypeUtils.getRawType(function.getItemType(function.getOutputType())).getSimpleName().toLowerCase();
return FunctionTypeUtils.getRawType(function.getItemType(function.getOutputType())).getSimpleName().toLowerCase(Locale.ROOT);
}

private String toSimplePolyIn(FunctionInvocationWrapper function) {
return FunctionTypeUtils.getRawType(function.getItemType(function.getInputType())).getSimpleName().toLowerCase();
return FunctionTypeUtils.getRawType(function.getItemType(function.getInputType())).getSimpleName().toLowerCase(Locale.ROOT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -908,7 +909,7 @@ private String contentTypeHeaderValue(Message<?> msg) {
if (contentType == null) {
contentType = msg.getHeaders().get(HttpHeaders.CONTENT_TYPE);
if (contentType == null) {
contentType = msg.getHeaders().get(HttpHeaders.CONTENT_TYPE.toLowerCase());
contentType = msg.getHeaders().get(HttpHeaders.CONTENT_TYPE.toLowerCase(Locale.ROOT));
}
}
return Objects.toString(contentType);
Expand Down
Loading

0 comments on commit d120eb0

Please sign in to comment.