When using route("process.{id}.log", "deadbeef") I'd expect the route to be expanded to process.deadbeef.log but to my suprise it's expanded to process.deadbeef.

Affected version: spring-messaging 5.2.4.RELEASE

I could track down the error to the org.springframework.messaging.rsocket.MetadataEncoder. This minimal sample illustrates the bug (sorry for the reflection hackery):

public static void main(String[] args) throws Exception {
   Class<?> clazz = Class.forName("org.springframework.messaging.rsocket.MetadataEncoder");
    Method expandMethod = clazz.getDeclaredMethod("expand", String.class, Object[].class);
    expandMethod.setAccessible(true);
    String route = (String) expandMethod.invoke(null, "process.{id}.log", new Object[]{"deadbeef"});
    System.out.println(route);
}

Comment From: joshiste

If you need a more complete sample:

@SpringBootApplication
@Controller
public class DemoApplication {

    public static void main(String[] args) throws ClassNotFoundException {
        SpringApplication.run(DemoApplication.class, args);
    }

    @MessageMapping("hello.{id}.name")
    public Mono<Void> names(@DestinationVariable String id, @Payload Flux<String> message) {
        return message.doOnNext(m -> System.out.println("Name " + id + ": " + m)).then();
    }

    @Bean
    ApplicationRunner runner(RSocketRequester.Builder requester) {
        return args -> {
            requester.connectTcp("localhost", 7878)
                    .flatMap(r -> r.route("hello.{id}.name", "cafebabe").data(Flux.just("Bob", "Alice", "Kare")).retrieveFlux(Void.class).then())
                    .block();
        };
    }
}