You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by GitBox <gi...@apache.org> on 2020/09/22 08:31:53 UTC

[GitHub] [ambari] sziszo opened a new pull request #3229: AMBARI-25552 Improve stack-trace disablement on HTTP 500 error response from the server (santal)

sziszo opened a new pull request #3229:
URL: https://github.com/apache/ambari/pull/3229


   ## What changes were proposed in this pull request?
   
   AMBARI-25353 disabling any stack trace output from API HTTP 500 response. The problem is that such response in most cases are no logged to the log file and later on production it would create a problem for customer to report the issue or for developer to investigate.
   
   The proposal is to enable logging for such errors with creating some request id, which would be added to log file and reported back to the user in format like: "Internal server error, please refer the exception by [request id] in the server log file"
   
   ## How was this patch tested?
   
   The patch was tested with unit and manual tests.
   


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



[GitHub] [ambari] sziszo commented on pull request #3229: AMBARI-25552 Improve stack-trace disablement on HTTP 500 error response from the server (santal)

Posted by GitBox <gi...@apache.org>.
sziszo commented on pull request #3229:
URL: https://github.com/apache/ambari/pull/3229#issuecomment-696585004


   @hapylestat could you please review this PR?


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



[GitHub] [ambari] dlysnichenko merged pull request #3229: AMBARI-25552 Improve stack-trace disablement on HTTP 500 error response from the server (santal)

Posted by GitBox <gi...@apache.org>.
dlysnichenko merged pull request #3229:
URL: https://github.com/apache/ambari/pull/3229


   


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



[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)

Posted by GitBox <gi...@apache.org>.
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



[GitHub] [ambari] sziszo commented on pull request #3229: AMBARI-25552 Improve stack-trace disablement on HTTP 500 error response from the server (santal)

Posted by GitBox <gi...@apache.org>.
sziszo commented on pull request #3229:
URL: https://github.com/apache/ambari/pull/3229#issuecomment-696585004


   @hapylestat could you please review this PR?


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



[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)

Posted by GitBox <gi...@apache.org>.
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



[GitHub] [ambari] dlysnichenko merged pull request #3229: AMBARI-25552 Improve stack-trace disablement on HTTP 500 error response from the server (santal)

Posted by GitBox <gi...@apache.org>.
dlysnichenko merged pull request #3229:
URL: https://github.com/apache/ambari/pull/3229


   


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



[GitHub] [ambari] sziszo commented on pull request #3229: AMBARI-25552 Improve stack-trace disablement on HTTP 500 error response from the server (santal)

Posted by GitBox <gi...@apache.org>.
sziszo commented on pull request #3229:
URL: https://github.com/apache/ambari/pull/3229#issuecomment-698147350


   retest


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



[GitHub] [ambari] sziszo commented on a change in pull request #3229: AMBARI-25552 Improve stack-trace disablement on HTTP 500 error response from the server (santal)

Posted by GitBox <gi...@apache.org>.
sziszo commented on a change in pull request #3229:
URL: https://github.com/apache/ambari/pull/3229#discussion_r493804178



##########
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:
       sure, I'll do it




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



[GitHub] [ambari] sziszo commented on pull request #3229: AMBARI-25552 Improve stack-trace disablement on HTTP 500 error response from the server (santal)

Posted by GitBox <gi...@apache.org>.
sziszo commented on pull request #3229:
URL: https://github.com/apache/ambari/pull/3229#issuecomment-775512206


   retest


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



[GitHub] [ambari] sziszo removed a comment on pull request #3229: AMBARI-25552 Improve stack-trace disablement on HTTP 500 error response from the server (santal)

Posted by GitBox <gi...@apache.org>.
sziszo removed a comment on pull request #3229:
URL: https://github.com/apache/ambari/pull/3229#issuecomment-775512206


   retest


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



[GitHub] [ambari] sziszo commented on pull request #3229: AMBARI-25552 Improve stack-trace disablement on HTTP 500 error response from the server (santal)

Posted by GitBox <gi...@apache.org>.
sziszo commented on pull request #3229:
URL: https://github.com/apache/ambari/pull/3229#issuecomment-698147350


   retest


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