ambari-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ambari] dlysnichenko commented on a change in pull request #3229: AMBARI-25552 Improve stack-trace disablement on HTTP 500 error response from the server (santal)
Date Wed, 23 Sep 2020 04:45:40 GMT

dlysnichenko commented on a change in pull request #3229:
URL: https://github.com/apache/ambari/pull/3229#discussion_r492999273



##########
File path: ambari-server/src/main/java/org/apache/ambari/server/api/AmbariViewErrorHandlerProxy.java
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.ambari.server.api;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.http.HttpStatus;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.handler.ErrorHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javassist.util.proxy.MethodHandler;
+
+/**
+ * Wraps the given ErrorHandler to log the error stacks
+ */
+public class AmbariViewErrorHandlerProxy extends ErrorHandler implements MethodHandler {
+
+  private final static Logger LOGGER = LoggerFactory.getLogger(AmbariViewErrorHandlerProxy.class);
+
+  private final ErrorHandler webAppErrorHandler;
+  private final AmbariErrorHandler ambariErrorHandler;
+
+  public AmbariViewErrorHandlerProxy(ErrorHandler webAppErrorHandler, AmbariErrorHandler
ambariErrorHandler) {
+    this.webAppErrorHandler = webAppErrorHandler;
+    this.ambariErrorHandler = ambariErrorHandler;
+  }
+
+
+  @Override
+  public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse
response) throws IOException {
+
+    Throwable th = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
+    if (null != th && response.getStatus() == HttpStatus.SC_INTERNAL_SERVER_ERROR)
{

Review comment:
       looks like implementation is the same as at `doError`, how about extracting common
code so some method?




----------------------------------------------------------------
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.

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



Mime
View raw message