Updates to*Case() to use Locale.ROOT

This commit is contained in:
spencergibb
2024-10-18 10:53:24 -04:00
committed by Oleg Zhurakousky
parent b65577d515
commit 900d03f816
83 changed files with 262 additions and 178 deletions

View File

@@ -1,5 +1,6 @@
package example;
import java.util.Locale;
import java.util.function.Function;
import org.springframework.boot.SpringBootConfiguration;
@@ -25,7 +26,7 @@ public class FunctionConfiguration implements ApplicationContextInitializer<Gene
@Override
public void initialize(GenericApplicationContext context) {
Function<String, String> function = (str) -> str + str.toUpperCase();
Function<String, String> function = (str) -> str + str.toUpperCase(Locale.ROOT);
context.registerBean("uppercase", FunctionRegistration.class,
() -> new FunctionRegistration<>(function).type(FunctionTypeUtils.functionType(String.class, String.class)));

View File

@@ -1,6 +1,7 @@
package com.example;
import java.util.Arrays;
import java.util.Locale;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -30,7 +31,7 @@ public class LambdaApplication {
public Function<String, String> uppercase() {
return value -> {
logger.info("UPPERCASING: " + value);
return value.toUpperCase();
return value.toUpperCase(Locale.ROOT);
};
}

View File

@@ -1,5 +1,6 @@
package com.example;
import java.util.Locale;
import java.util.function.Function;
import org.apache.commons.logging.Log;
@@ -24,7 +25,7 @@ public class LambdaApplication
if (value.equals("error")) {
throw new IllegalArgumentException("Intentional");
}
return value.toUpperCase();
return value.toUpperCase(Locale.ROOT);
};
}

View File

@@ -1,5 +1,6 @@
package com.example.demo;
import java.util.Locale;
import java.util.function.Function;
import org.apache.commons.logging.Log;
@@ -35,7 +36,7 @@ public class NativeFunctionApplication {
public Function<String, String> uppercase() {
return v -> {
System.out.println("Uppercasing " + v);
return v.toUpperCase();
return v.toUpperCase(Locale.ROOT);
};
}

View File

@@ -1,5 +1,6 @@
package example;
import java.util.Locale;
import java.util.function.Function;
import org.springframework.boot.SpringApplication;
@@ -19,7 +20,7 @@ public class FunctionConfiguration {
@Bean
public Function<String, String> uppercase() {
return value -> value.toUpperCase();
return value -> value.toUpperCase(Locale.ROOT);
}
@Bean

View File

@@ -1,5 +1,6 @@
package example;
import java.util.Locale;
import java.util.function.Function;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -24,7 +25,7 @@ public class FunctionConfiguration {
throw new RuntimeException("Intentional exception");
}
else {
return value.toUpperCase();
return value.toUpperCase(Locale.ROOT);
}
};
}

View File

@@ -16,6 +16,7 @@
package com.example.azure.di.azureblobtriggerdemo;
import java.util.Locale;
import java.util.function.Function;
import org.springframework.boot.SpringApplication;
@@ -31,6 +32,6 @@ public class AzureBlobTriggerDemoApplication {
@Bean
public Function<byte[], byte[]> uppercase() {
return payload -> new String(payload).toUpperCase().getBytes();
return payload -> new String(payload).toUpperCase(Locale.ROOT).getBytes();
}
}

View File

@@ -1,5 +1,6 @@
package org.scf.azure.gradle;
import java.util.Locale;
import java.util.Optional;
import java.util.function.Function;
@@ -49,11 +50,11 @@ public class GradleDemoApplication {
return message -> {
ExecutionContext context = (ExecutionContext) message.getHeaders().get(AzureFunctionUtil.EXECUTION_CONTEXT);
String updatedPayload = message.getPayload().toUpperCase();
String updatedPayload = message.getPayload().toUpperCase(Locale.ROOT);
context.getLogger().info("Azure Test: " + updatedPayload);
return message.getPayload().toUpperCase();
return message.getPayload().toUpperCase(Locale.ROOT);
};
}

View File

@@ -16,6 +16,7 @@
package com.example.azure.di.httptriggerdemo;
import java.util.Locale;
import java.util.function.Function;
import org.springframework.boot.SpringApplication;
@@ -32,7 +33,7 @@ public class HttpTriggerDemoApplication {
@Bean
public Function<String, String> uppercase() {
return payload -> payload.toUpperCase();
return payload -> payload.toUpperCase(Locale.ROOT);
}
@Bean

View File

@@ -15,6 +15,7 @@
*/
package example;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
@@ -45,7 +46,7 @@ public class KafkaTriggerDemoApplication {
Map<String, Object> valueMap = mapper.fromJson(kafkaEntity.getValue(), Map.class);
if (valueMap != null) {
valueMap.forEach((k, v) -> valueMap.put(k,
v != null && v instanceof String ? ((String) v).toUpperCase() : null));
v != null && v instanceof String ? ((String) v).toUpperCase(Locale.ROOT) : null));
return mapper.toString(valueMap);
}
}

View File

@@ -16,6 +16,7 @@
package com.example.azure.di.timetriggerdemo;
import java.util.Locale;
import java.util.function.Consumer;
import com.microsoft.azure.functions.ExecutionContext;
@@ -40,7 +41,7 @@ public class TimeTriggerDemoApplication {
public Consumer<Message<String>> uppercase() {
return message -> {
String timeInfo = message.getPayload();
String value = timeInfo.toUpperCase();
String value = timeInfo.toUpperCase(Locale.ROOT);
logger.info("Timer is triggered with TimeInfo: " + value);

View File

@@ -16,6 +16,7 @@
package example;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
@@ -54,7 +55,7 @@ public class Config {
Map<String, String> map = mapper.fromJson(value, Map.class);
if(map != null)
map.forEach((k, v) -> map.put(k, v != null ? v.toUpperCase() : null));
map.forEach((k, v) -> map.put(k, v != null ? v.toUpperCase(Locale.ROOT) : null));
if(context != null)
context.getLogger().info(new StringBuilder().append("Function: ")
@@ -73,12 +74,12 @@ public class Config {
@Bean
public Function<Mono<String>, Mono<String>> uppercaseReactive() {
return mono -> mono.map(value -> value.toUpperCase());
return mono -> mono.map(value -> value.toUpperCase(Locale.ROOT));
}
@Bean
public Function<Flux<String>, Flux<String>> echoStream() {
return flux -> flux.map(value -> value.toUpperCase());
return flux -> flux.map(value -> value.toUpperCase(Locale.ROOT));
}
}

View File

@@ -17,6 +17,7 @@
package example;
import java.util.List;
import java.util.Locale;
import com.microsoft.azure.functions.ExecutionContext;
import com.microsoft.azure.functions.HttpMethod;
@@ -54,7 +55,7 @@ public class ReactiveEchoCustomResultHandler extends FunctionInvoker<List<String
) {
functionResult
.doFirst(() -> executionContext.getLogger().info("BEGIN echo post-processing work ..."))
.mapNotNull((v) -> v.toString().toUpperCase())
.mapNotNull((v) -> v.toString().toUpperCase(Locale.ROOT))
.doFinally((signalType) -> executionContext.getLogger().info("END echo post-processing work"))
.subscribe((v) -> executionContext.getLogger().info(" " + v));
return "Kicked off job for " + rawInputs;

View File

@@ -1,5 +1,6 @@
package example;
import java.util.Locale;
import java.util.function.Function;
import org.springframework.boot.SpringApplication;
@@ -23,7 +24,7 @@ public class FunctionConfiguration implements ApplicationContextInitializer<Gene
}
public Function<String, String> uppercase() {
return value -> value.toUpperCase();
return value -> value.toUpperCase(Locale.ROOT);
}
public Function<String, String> reverse() {

View File

@@ -16,6 +16,7 @@
package com.example;
import java.util.Locale;
import java.util.function.Function;
import org.springframework.boot.SpringApplication;
@@ -31,6 +32,6 @@ public class CloudFunctionMain {
@Bean
public Function<String, String> function() {
return value -> value.toUpperCase();
return value -> value.toUpperCase(Locale.ROOT);
}
}

View File

@@ -3,6 +3,7 @@ package com.example.grpc.demo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
@@ -55,7 +56,7 @@ public class DemoGrpcApplication {
@Bean
public Function<Message<String>, Message<String>> uppercase() {
return message -> {
return MessageBuilder.withPayload(message.getPayload().toUpperCase())
return MessageBuilder.withPayload(message.getPayload().toUpperCase(Locale.ROOT))
.copyHeaders(message.getHeaders())
.setHeader("uppercased", "true")
.build();

View File

@@ -17,6 +17,7 @@
package com.example;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -71,11 +72,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() {

View File

@@ -17,6 +17,7 @@
package com.example;
import java.time.Duration;
import java.util.Locale;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -38,17 +39,17 @@ public class SampleApplication {
@Bean
public Function<String, String> uppercase() {
return value -> value.toUpperCase();
return value -> value.toUpperCase(Locale.ROOT);
}
@Bean
public Function<Message<String>, Integer> uppercaseMessage() {
return value -> value.getPayload().toUpperCase().length();
return value -> value.getPayload().toUpperCase(Locale.ROOT).length();
}
@Bean
public Function<Flux<String>, Flux<String>> lowercase() {
return flux -> flux.map(value -> value.toLowerCase());
return flux -> flux.map(value -> value.toLowerCase(Locale.ROOT));
}
@Bean

View File

@@ -1,5 +1,6 @@
package oz.spring.aws.functions;
import java.util.Locale;
import java.util.function.Function;
import org.springframework.context.annotation.Bean;
@@ -10,6 +11,6 @@ public class FunctionConfiguration {
@Bean
public Function<String, String> uppercase() {
return value -> value.toUpperCase();
return value -> value.toUpperCase(Locale.ROOT);
}
}

View File

@@ -1,5 +1,6 @@
package oz.spring.aws.functions;
import java.util.Locale;
import java.util.function.Function;
import org.springframework.context.annotation.Bean;
@@ -10,7 +11,7 @@ public class FunctionRoutingConfiguration {
@Bean
public Function<String, String> lowercase() {
return value -> value.toLowerCase();
return value -> value.toLowerCase(Locale.ROOT);
}
@Bean