From 882004fc9b46e3e0b18cfda240a79d217ccbf58c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 23 Jun 2021 14:22:14 +0200 Subject: [PATCH] Fix bug in SimpleMethodMetadataReadingVisitor.Source.toString() Prior to this commit, the toString() implementation did not separate method argument types with a comma or any form of separator, leading to results such as: org.example.MyClass.myMethod(java.lang.Stringjava.lang.Integer) instead of: org.example.MyClass.myMethod(java.lang.String,java.lang.Integer) Closes gh-27095 --- .../SimpleMethodMetadataReadingVisitor.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMethodMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMethodMetadataReadingVisitor.java index 38ba349999..c9bd5f0258 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMethodMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMethodMetadataReadingVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -32,6 +32,7 @@ import org.springframework.lang.Nullable; * ASM method visitor that creates {@link SimpleMethodMetadata}. * * @author Phillip Webb + * @author Sam Brannen * @since 5.2 */ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor { @@ -144,14 +145,17 @@ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor { if (value == null) { StringBuilder builder = new StringBuilder(); builder.append(this.declaringClassName); - builder.append("."); + builder.append('.'); builder.append(this.methodName); Type[] argumentTypes = Type.getArgumentTypes(this.descriptor); - builder.append("("); - for (Type type : argumentTypes) { - builder.append(type.getClassName()); + builder.append('('); + for (int i = 0; i < argumentTypes.length; i++) { + if (i != 0) { + builder.append(','); + } + builder.append(argumentTypes[i].getClassName()); } - builder.append(")"); + builder.append(')'); value = builder.toString(); this.toStringValue = value; } -- GitLab