activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [activemq] branch activemq-5.15.x updated: [AMQ-7419] Return 405 error code instead of 500 in case of maxFrameSize exceeded on HTTP connector
Date Fri, 28 Feb 2020 06:34:34 GMT
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch activemq-5.15.x
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/activemq-5.15.x by this push:
     new 5a93c34  [AMQ-7419] Return 405 error code instead of 500 in case of maxFrameSize
exceeded on HTTP connector
5a93c34 is described below

commit 5a93c3482603188ee8c76a7bb50d87e2e87e7c0d
Author: jbonofre <jbonofre@apache.org>
AuthorDate: Mon Feb 24 14:54:42 2020 +0100

    [AMQ-7419] Return 405 error code instead of 500 in case of maxFrameSize exceeded on HTTP
connector
    
    (cherry picked from commit 0245a3d5c4595ddab2da38463ca7948b98d95c8f)
---
 .../apache/activemq/transport/http/HttpTunnelServlet.java | 15 +++++++++------
 .../activemq/transport/http/HttpMaxFrameSizeTest.java     |  2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java
b/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java
index 5c474bd..a7285da 100644
--- a/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java
+++ b/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java
@@ -16,17 +16,14 @@
  */
 package org.apache.activemq.transport.http;
 
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.*;
 import java.util.HashMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 import java.util.zip.GZIPInputStream;
+import javax.jms.JMSException;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -121,7 +118,13 @@ public class HttpTunnelServlet extends HttpServlet {
     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
 
         if (wireFormatOptions.get("maxFrameSize") != null && request.getContentLength()
> Integer.parseInt(wireFormatOptions.get("maxFrameSize").toString())) {
-            throw new ServletException("maxFrameSize exceeded");
+            response.setStatus(405);
+            response.setContentType("plain/text");
+            PrintWriter writer = response.getWriter();
+            writer.println("maxFrameSize exceeded");
+            writer.flush();
+            writer.close();
+            return;
         }
 
         InputStream stream = request.getInputStream();
diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpMaxFrameSizeTest.java
b/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpMaxFrameSizeTest.java
index 53c24ef..28e4ebb 100644
--- a/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpMaxFrameSizeTest.java
+++ b/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpMaxFrameSizeTest.java
@@ -56,7 +56,7 @@ public class HttpMaxFrameSizeTest {
         try {
             send(5000);
         } catch (JMSException jmsException) {
-            Assert.assertTrue(jmsException.getMessage().contains("500 Server Error"));
+            Assert.assertTrue(jmsException.getMessage().contains("405 Method Not Allowed"));
         }
     }
 


Mime
View raw message