You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "jbertram (via GitHub)" <gi...@apache.org> on 2023/05/31 14:13:55 UTC

[GitHub] [activemq-artemis] jbertram opened a new pull request, #4493: ARTEMIS-4294 support text-encoded WebSocket frames

jbertram opened a new pull request, #4493:
URL: https://github.com/apache/activemq-artemis/pull/4493

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] jbertram commented on pull request #4493: ARTEMIS-4294 support text-encoded WebSocket frames

Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on PR #4493:
URL: https://github.com/apache/activemq-artemis/pull/4493#issuecomment-1570324051

   Something weird happened on `WebSocketFrameEncoder.java` with the EOLs so the whole file got changed. I think it originally used CRLF instead of just LF.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] tabish121 commented on a diff in pull request #4493: ARTEMIS-4294 support text-encoded WebSocket frames

Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #4493:
URL: https://github.com/apache/activemq-artemis/pull/4493#discussion_r1211906696


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/protocol/websocket/WebSocketFrameEncoderType.java:
##########
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.core.server.protocol.websocket;
+
+public enum WebSocketFrameEncoderType {
+   BINARY, TEXT;
+
+   public static WebSocketFrameEncoderType valueOfType(String type) {
+      switch (type) {
+         case "binary":
+            return BINARY;
+         case "text":
+            return TEXT;
+         default:
+            return null;

Review Comment:
   Instead of returning null here why not just throw an exception that indicates that this is an invalid argument here to avoid any chance of NPE later



##########
artemis-server/src/test/java/org/apache/activemq/artemis/core/server/protocol/websocket/WebSocketFrameEncoderTest.java:
##########
@@ -60,11 +61,22 @@ public class WebSocketFrameEncoderTest {
 
    @Before
    public void setUp() throws Exception {
-      spy = spy(new WebSocketFrameEncoder(maxFramePayloadLength));
+      binarySpy = spy(new WebSocketFrameEncoder(maxFramePayloadLength, WebSocketFrameEncoderType.BINARY));
+      textSpy = spy(new WebSocketFrameEncoder(maxFramePayloadLength, WebSocketFrameEncoderType.TEXT));
    }
 
    @Test
-   public void testWriteNonByteBuf() throws Exception {
+   public void testWriteNonByteBufBinary() throws Exception {
+      testWriteNonByteBuf(binarySpy);
+   }
+
+

Review Comment:
   Extra newline 



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ProtocolHandler.java:
##########
@@ -158,7 +160,12 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
                }
                stompMaxFramePayloadLength = stompMaxFramePayloadLength != -1 ? stompMaxFramePayloadLength : TransportConstants.DEFAULT_WEB_SOCKET_MAX_FRAME_PAYLOAD_LENGTH;
                int webSocketMaxFramePayloadLength = ConfigurationHelper.getIntProperty(TransportConstants.WEB_SOCKET_MAX_FRAME_PAYLOAD_LENGTH, -1, nettyAcceptor.getConfiguration());
-               ctx.pipeline().addLast("websocket-handler", new WebSocketServerHandler(websocketSubprotocolIds, webSocketMaxFramePayloadLength != -1 ? webSocketMaxFramePayloadLength : stompMaxFramePayloadLength));
+               String encoderConfigType = ConfigurationHelper.getStringProperty(TransportConstants.WEB_SOCKET_ENCODER_TYPE, TransportConstants.DEFAULT_WEB_SOCKET_ENCODER_TYPE, nettyAcceptor.getConfiguration());
+               WebSocketFrameEncoderType encoderType = WebSocketFrameEncoderType.valueOfType(encoderConfigType);
+               if (encoderType == null) {

Review Comment:
   As noted below I'd just have the 'valuefType' method validate and throw instead of needing to check here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] jbertram merged pull request #4493: ARTEMIS-4294 support text-encoded WebSocket frames

Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram merged PR #4493:
URL: https://github.com/apache/activemq-artemis/pull/4493


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org