{"record":{"id":"c166e892bf2d5fa9","repo":"quarkusio/quarkus","slug":"should-be-virtual-server-channel","errorCode":null,"errorMessage":"Should be virtual server channel: ","messagePattern":"Should be virtual server channel: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/netty/runtime/src/main/java/io/quarkus/netty/runtime/virtual/VirtualClientConnection.java","lineNumber":120,"sourceCode":"\n    /**\n     * Establish a virtual intra-JVM connection\n     *\n     * @param remoteAddress\n     * @param clientAddress\n     * @return\n     */\n    public static VirtualClientConnection connect(VirtualResponseHandler handler, VirtualAddress remoteAddress,\n            SocketAddress clientAddress) {\n        if (clientAddress == null)\n            clientAddress = remoteAddress;\n\n        Channel boundChannel = VirtualChannelRegistry.get(remoteAddress);\n        if (boundChannel == null) {\n            throw new RuntimeException(\"No virtual channel available\");\n        }\n        if (!(boundChannel instanceof VirtualServerChannel)) {\n            throw new RuntimeException(\"Should be virtual server channel: \" + boundChannel.getClass().getName());\n        }\n\n        VirtualServerChannel serverChannel = (VirtualServerChannel) boundChannel;\n        VirtualClientConnection conn = new VirtualClientConnection(clientAddress, handler);\n        conn.peer = serverChannel.serve(conn);\n        return conn;\n    }\n}\n","sourceCodeStart":102,"sourceCodeEnd":129,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/netty/runtime/src/main/java/io/quarkus/netty/runtime/virtual/VirtualClientConnection.java#L102-L129","documentation":"VirtualClientConnection.connect() looks up a server-side channel registered in VirtualChannelRegistry for the given remote address and requires it to be a VirtualServerChannel. If the bound object is a different Channel implementation, the registry contents are inconsistent with the virtual transport's expectations, so a RuntimeException is thrown naming the offending class.","triggerScenarios":"Calling VirtualClientConnection.connect(...) with a remoteAddress that maps in VirtualChannelRegistry to a Channel that is not a VirtualServerChannel (e.g. a VirtualClientChannel or a real Netty channel registered under the same address).","commonSituations":"Tests or custom code registering the wrong channel type in VirtualChannelRegistry; reusing an address that was bound by a client connection rather than a VirtualServerChannel.bind(); stale registry entries across test cases.","solutions":["Ensure the address bound in VirtualChannelRegistry was created via VirtualServerChannel bind/registration, not a client channel","Inspect the class name in the message to find what actually got registered under that address","Clear or reset VirtualChannelRegistry between tests so stale client channels are not reused"],"exampleFix":"// before\nVirtualChannelRegistry.register(remoteAddress, someVirtualClientChannel);\n// after\nVirtualServerChannel server = ...; // create via virtual server bootstrap\nserver.bind(remoteAddress).sync();\nVirtualClientConnection.connect(bootstrap, remoteAddress, clientAddress, handler);","handlingStrategy":"validation","validationCode":"Channel boundChannel = VirtualChannelRegistry.get(remoteAddress);\nif (!(boundChannel instanceof VirtualServerChannel)) {\n    throw new IllegalStateException(\"Address not bound to a VirtualServerChannel: \" + remoteAddress);\n}","typeGuard":"static boolean isVirtualServerBound(SocketAddress addr) {\n    Channel ch = VirtualChannelRegistry.get(addr);\n    return ch instanceof VirtualServerChannel;\n}","tryCatchPattern":"try {\n    VirtualClientConnection conn = VirtualClientConnection.connect(bootstrap, remoteAddress, clientAddress, handler);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Should be virtual server channel\")) { /* re-register correct server channel */ }\n}","preventionTips":["Only register VirtualServerChannel instances in VirtualChannelRegistry","Reset the registry between tests","Log the registered channel type when binding"],"tags":["netty","virtual-transport","testing"],"backgroundTag":"virtual-channel-type-mismatch","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}