【发布时间】:2018-10-31 20:58:21
【问题描述】:
与服务器端的Java Exceptions 和500 的http 错误代码Internal Server Error 是否有任何相关性。发生这种情况是因为 catch 块中的 unhandled exceptions 或者可能是因为在 runtime 上引发的 unchecked 异常
我怎么能得出结论,对我来说,它是 Apache Camel 项目,它具有 spring-boot-starter-parent 并在内部配置了 Spring Quartz。基本上REST 通过OAuth 1.0 身份验证进行调用。
我正在通过Swagger 测试我的应用程序。我无法得出结论,
-
OAuth 1.0认证成功与否 - Error Handler Routines 无法捕获具体的,- 项目中的
error code,因为它基本上是unhandled和runtime exception
Swagger 给出以下响应,错误代码为 500。
"<Error><Message>An error has occurred.</Message><ExceptionMessage>Object reference not set to an instance of an object.</ExceptionMessage><ExceptionType>System.NullReferenceException</ExceptionType><StackTrace> at API.ExecutionTimeFilterAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
\n at System.Web.Http.Filters.ActionFilterAttribute.OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
\n--- End of stack trace from previous location where exception was thrown ---
\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
\n--- End of stack trace from previous location where exception was thrown ---
\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
\n--- End of stack trace from previous location where exception was thrown ---
\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
\n--- End of stack trace from previous location where exception was thrown ---
\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()
\n--- End of stack trace from previous location where exception was thrown ---
\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()</StackTrace></Error>"
即使是错误的secret key、consumer key,也是一样的情况。
我认为这两种情况的键都不合适。
不过我想知道,
is 500 错误代码对于未处理的异常和未检查的异常很常见 运行时异常,否则我们将有 400 系列
如果出现 http (500) 错误代码而不是在代码中处理并作为 REST 调用的响应字符串的一部分被响应的自定义 java 错误代码,我如何判断测试场景。
【问题讨论】:
-
发布处理 400 系列的 try catch 块?
-
代码被混淆了,所以
try..catch处理400系列就是它。万一unchecked exceptions,是400系列还是怎么样? -
http 500 也会在内存泄漏时遇到,所以你的服务器会在那个时候没有元空间,如果是这种情况,那么它会在每个休息请求上发生
标签: java rest spring-boot oauth swagger