TogetherOS / cicada

🚀 Fast lightweight HTTP service framework.
https://crossoverjie.top/categories/cicada/
Apache License 2.0
953 stars 212 forks source link

HttpDispatcher.responseContent是不是在try中合适? #40

Closed mujianping closed 5 years ago

mujianping commented 5 years ago

image

crossoverJie commented 5 years ago

放在 finally 中可以保证异常时也有响应。

mujianping commented 5 years ago

放在try里的话,异常时应该走exceptionCaught方法了吧,要不出现异常会不会exceptionCaught和responseContent执行重复 @crossoverJie

crossoverJie commented 5 years ago

放在try里的话,异常时应该走exceptionCaught方法了吧,要不出现异常会不会exceptionCaught和responseContent执行重复 @crossoverJie

应该是说反了,只有异常时 exceptionCaughtresponseContent 都会执行,但其实问题也不大;

http 是短连接,在 exceptionCaught 做了响应后,responseContent 的响应对之前的响应并没有影响。

不过这里倒确实可以优化下,没必要响应两次。

mujianping commented 5 years ago

对就这意思,不愧是大jie哥! @crossoverJie

crossoverJie commented 5 years ago

41 已经优化