{"record":{"id":"cf2d31a342732af4","repo":"theonedev/onedev","slug":"unsupported-message-type-message-getclass-getn","errorCode":null,"errorMessage":"Unsupported message type: {message.getClass().getName()}","messagePattern":"Unsupported message type: (.+?)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java","lineNumber":386,"sourceCode":"\t\telse if (message instanceof ConnectedMessage)\n\t\t{\n\t\t\tpayload = new WebSocketConnectedPayload((ConnectedMessage) message, handler);\n\t\t}\n\t\telse if (message instanceof ClosedMessage)\n\t\t{\n\t\t\tpayload = new WebSocketClosedPayload((ClosedMessage) message, handler);\n\t\t}\n\t\telse if (message instanceof AbortedMessage)\n\t\t{\n\t\t\tpayload = new WebSocketAbortedPayload((AbortedMessage) message, handler);\n\t\t}\n\t\telse if (message instanceof IWebSocketPushMessage)\n\t\t{\n\t\t\tpayload = new WebSocketPushPayload((IWebSocketPushMessage) message, handler);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tthrow new IllegalArgumentException(\"Unsupported message type: \" + message.getClass().getName());\n\t\t}\n\t\treturn payload;\n\t}\n\n\tprotected IKey getRegistryKey()\n\t{\n\t\tIKey key;\n\t\tif (Strings.isEmpty(resourceName))\n\t\t{\n\t\t\tkey = new PageIdKey(pageId);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tkey = new ResourceNameKey(resourceName);\n\t\t}\n\t\treturn key;\n\t}\n","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java#L368-L404","documentation":"createEventPayload converts a broadcast message object into a WebSocket payload, but only a fixed set of message types is supported (e.g. IWebSocketPushMessage, and the other instanceof branches above). Passing any other object type throws IllegalArgumentException with the message's class name, telling you which type is unsupported. This happens when broadcasting via IWebSocketProcessor.broadcastMessage with an object that does not implement one of the recognized interfaces.","triggerScenarios":"Calling AbstractWebSocketProcessor.broadcastMessage(...)/createEventPayload(...) with a plain POJO that implements none of Wicket's IWebSocketMessage interfaces (IWebSocketPushMessage, connected/disconnected message types, etc.).","commonSituations":"Application code broadcasts a custom event object directly instead of wrapping it in a class implementing IWebSocketPushMessage; refactors drop an interface implementation; a third-party event is forwarded raw.","solutions":["Make the broadcast message class implement IWebSocketPushMessage (and implement createPushPayload/serialization as needed)","Or broadcast a supported Wicket message type instead of a raw POJO","Check the else-branch chain in createEventPayload for the full list of accepted types and pick the matching interface"],"exampleFix":"// before\nsession.broadcastMessage(new MyCustomEvent());\n// after\npublic class MyPushMessage implements IWebSocketPushMessage { ... }\nsession.broadcastMessage(new MyPushMessage());","handlingStrategy":"type-guard","validationCode":"if (!(message instanceof IWebSocketPushMessage)) {\n    throw new IllegalStateException(\"Broadcast message must implement IWebSocketPushMessage: \" + message.getClass());\n}","typeGuard":"boolean isBroadcastable(Object m) {\n    return m instanceof IWebSocketPushMessage;\n}","tryCatchPattern":"try {\n    processor.broadcastMessage(message);\n} catch (IllegalArgumentException e) {\n    log.error(\"Unsupported broadcast type: {}\", message == null ? \"null\" : message.getClass(), e);\n}","preventionTips":["Make all broadcast message classes implement IWebSocketPushMessage","Add a unit test broadcasting every message type used in the app","Never forward third-party event POJOs raw"],"tags":["websocket","wicket","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}