diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java index 0277bc0a0f..afbb139571 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,9 +98,7 @@ public final class ParseState { for (ParseState.Entry entry : this.state) { if (i > 0) { sb.append('\n'); - for (int j = 0; j < i; j++) { - sb.append('\t'); - } + sb.append("\t".repeat(i)); sb.append("-> "); } sb.append(entry); diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/PatternParseException.java b/spring-web/src/main/java/org/springframework/web/util/pattern/PatternParseException.java index 1e49751da8..ad41a2c80b 100644 --- a/spring-web/src/main/java/org/springframework/web/util/pattern/PatternParseException.java +++ b/spring-web/src/main/java/org/springframework/web/util/pattern/PatternParseException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,9 +68,7 @@ public class PatternParseException extends IllegalArgumentException { public String toDetailedString() { StringBuilder sb = new StringBuilder(); sb.append(this.pattern).append('\n'); - for (int i = 0; i < this.position; i++) { - sb.append(' '); - } + sb.append(" ".repeat(Math.max(0, this.position))); sb.append("^\n"); sb.append(getMessage()); return sb.toString(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ToStringVisitor.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ToStringVisitor.java index 3adb272358..aae2c5086d 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ToStringVisitor.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ToStringVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,9 +81,7 @@ class ToStringVisitor implements RouterFunctions.Visitor, RequestPredicates.Visi } private void indent() { - for (int i = 0; i < this.indent; i++) { - this.builder.append(' '); - } + this.builder.append(" ".repeat(Math.max(0, this.indent))); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ToStringVisitor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ToStringVisitor.java index dbbe254804..5611af3995 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ToStringVisitor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ToStringVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,9 +80,7 @@ class ToStringVisitor implements RouterFunctions.Visitor, RequestPredicates.Visi } private void indent() { - for (int i = 0; i < this.indent; i++) { - this.builder.append(' '); - } + this.builder.append(" ".repeat(Math.max(0, this.indent))); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java index 6fb86f4df4..044a4a7bce 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,9 +59,7 @@ public abstract class AbstractSockJsMessageCodec implements SockJsMessageCodec { if (isSockJsSpecialChar(c)) { result.append('\\').append('u'); String hex = Integer.toHexString(c).toLowerCase(); - for (int i = 0; i < (4 - hex.length()); i++) { - result.append('0'); - } + result.append("0".repeat(Math.max(0, (4 - hex.length())))); result.append(hex); } else {