Un-mangle Kotlin method names in PartTree.
Due to shortcomings with value classes mangling and the impossible usage of JvmName on Kotlin interfaces, we're inspecting now the method name if it contains a dash (-). If so, then we truncate the method name to be able to parse it. Closes #2965
This commit is contained in:
@@ -87,6 +87,12 @@ public class PartTree implements Streamable<OrPart> {
|
||||
Assert.notNull(source, "Source must not be null");
|
||||
Assert.notNull(domainClass, "Domain class must not be null");
|
||||
|
||||
// Kotlin name mangling, @JvmName cannot be used with interfaces
|
||||
int dash = source.indexOf('-');
|
||||
if (dash > -1) {
|
||||
source = source.substring(0, dash);
|
||||
}
|
||||
|
||||
Matcher matcher = PREFIX_TEMPLATE.matcher(source);
|
||||
|
||||
if (!matcher.find()) {
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.domain.Limit;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
@@ -657,6 +656,14 @@ class PartTreeUnitTests {
|
||||
assertThat(tree.getSort()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test // GH-2965
|
||||
void unmangleKotlinMethodName() {
|
||||
|
||||
var tree = new PartTree("findById-u1QWhUI", Order.class);
|
||||
|
||||
assertThat(tree.getParts()).hasSize(1);
|
||||
}
|
||||
|
||||
private static void assertLimiting(String methodName, Class<?> entityType, boolean limiting, Integer maxResults) {
|
||||
assertLimiting(methodName, entityType, limiting, maxResults, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user