Skip to content

Commit 882004f

Browse files
committed
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
1 parent 1bc2367 commit 882004f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMethodMetadataReadingVisitor.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
* ASM method visitor that creates {@link SimpleMethodMetadata}.
3333
*
3434
* @author Phillip Webb
35+
* @author Sam Brannen
3536
* @since 5.2
3637
*/
3738
final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
@@ -144,14 +145,17 @@ public String toString() {
144145
if (value == null) {
145146
StringBuilder builder = new StringBuilder();
146147
builder.append(this.declaringClassName);
147-
builder.append(".");
148+
builder.append('.');
148149
builder.append(this.methodName);
149150
Type[] argumentTypes = Type.getArgumentTypes(this.descriptor);
150-
builder.append("(");
151-
for (Type type : argumentTypes) {
152-
builder.append(type.getClassName());
151+
builder.append('(');
152+
for (int i = 0; i < argumentTypes.length; i++) {
153+
if (i != 0) {
154+
builder.append(',');
155+
}
156+
builder.append(argumentTypes[i].getClassName());
153157
}
154-
builder.append(")");
158+
builder.append(')');
155159
value = builder.toString();
156160
this.toStringValue = value;
157161
}

0 commit comments

Comments
 (0)