You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2025/06/16 17:04:49 UTC
(activemq) branch main updated: AMQ-9503: Add wireFormat.displayStackTrace option on the HTTP transport connector to display or not the full stack trace to the client (#1457)
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/main by this push:
new 45dfc09853 AMQ-9503: Add wireFormat.displayStackTrace option on the HTTP transport connector to display or not the full stack trace to the client (#1457)
45dfc09853 is described below
commit 45dfc098534f988c383e56c58c2b2a1761243229
Author: JB Onofré <jb...@apache.org>
AuthorDate: Mon Jun 16 19:04:44 2025 +0200
AMQ-9503: Add wireFormat.displayStackTrace option on the HTTP transport connector to display or not the full stack trace to the client (#1457)
---
.../activemq/transport/http/HttpTunnelServlet.java | 70 ++++++++++++----------
1 file changed, 40 insertions(+), 30 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 fa694e89ed..3d75ea2afd 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
@@ -40,6 +40,7 @@ import org.apache.activemq.transport.util.TextWireFormat;
import org.apache.activemq.transport.xstream.XStreamWireFormat;
import org.apache.activemq.util.IOExceptionSupport;
import org.apache.activemq.util.ServiceListener;
+import org.apache.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -122,44 +123,53 @@ public class HttpTunnelServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ try {
+ if (wireFormatOptions.get("maxFrameSize") != null && request.getContentLength() > Integer.parseInt(wireFormatOptions.get("maxFrameSize").toString())) {
+ response.setStatus(405);
+ response.setContentType("plain/text");
+ PrintWriter writer = response.getWriter();
+ writer.println("maxFrameSize exceeded");
+ writer.flush();
+ writer.close();
+ return;
+ }
- if (wireFormatOptions.get("maxFrameSize") != null && request.getContentLength() > Integer.parseInt(wireFormatOptions.get("maxFrameSize").toString())) {
- response.setStatus(405);
- response.setContentType("plain/text");
- PrintWriter writer = response.getWriter();
- writer.println("maxFrameSize exceeded");
- writer.flush();
- writer.close();
- return;
- }
+ InputStream stream = request.getInputStream();
+ String contentType = request.getContentType();
+ if (contentType != null && contentType.equals("application/x-gzip")) {
+ stream = new GZIPInputStream(stream);
+ }
- InputStream stream = request.getInputStream();
- String contentType = request.getContentType();
- if (contentType != null && contentType.equals("application/x-gzip")) {
- stream = new GZIPInputStream(stream);
- }
+ // Read the command directly from the reader, assuming UTF8 encoding
+ Command command = (Command) wireFormat.unmarshalText(new InputStreamReader(stream, "UTF-8"));
- // Read the command directly from the reader, assuming UTF8 encoding
- Command command = (Command) wireFormat.unmarshalText(new InputStreamReader(stream, "UTF-8"));
+ if (command instanceof WireFormatInfo) {
+ WireFormatInfo info = (WireFormatInfo) command;
+ if (!canProcessWireFormatVersion(info.getVersion())) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot process wire format of version: "
+ + info.getVersion());
+ }
- if (command instanceof WireFormatInfo) {
- WireFormatInfo info = (WireFormatInfo) command;
- if (!canProcessWireFormatVersion(info.getVersion())) {
- response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot process wire format of version: "
- + info.getVersion());
- }
+ } else {
- } else {
+ BlockingQueueTransport transport = getTransportChannel(request, response);
+ if (transport == null) {
+ return;
+ }
- BlockingQueueTransport transport = getTransportChannel(request, response);
- if (transport == null) {
- return;
+ if (command instanceof ConnectionInfo) {
+ ((ConnectionInfo) command).setTransportContext(request.getAttribute("jakarta.servlet.request.X509Certificate"));
+ }
+ transport.doConsume(command);
}
-
- if (command instanceof ConnectionInfo) {
- ((ConnectionInfo) command).setTransportContext(request.getAttribute("jakarta.servlet.request.X509Certificate"));
+ } catch (Exception e) {
+ // no stack trace
+ if (wireFormatOptions.get("sendStackTrace") != null && Boolean.parseBoolean(wireFormatOptions.get("sendStackTrace").toString()) == false) {
+ LOG.warn(e.getMessage(), e);
+ response.sendError(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ } else {
+ throw e;
}
- transport.doConsume(command);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact