在Java中处理运行时异常(Handling Runtime exception in Java)
我有以下一段代码
try{//do something } catch (Exception e) { log.error(e, e); if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new RuntimeException(e); } }
findbugs stataic分析工具会对此引发此警告
对于methodX中的所有非空值,instanceof将始终返回true,因为所有RuntimeException都是RuntimeException的实例
我不明白的是它被捕获的异常,而不是RuntimeException,那么为什么这个警告呢?
I have the following piece of code
try{//do something } catch (Exception e) { log.error(e, e); if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new RuntimeException(e); } }
the findbugs stataic analysis tool throws this warning on it
instanceof will always return true for all nonnull values in methodX, since all RuntimeException are instances of RuntimeException
what i dont understand is that its Exception which is being caught and not the RuntimeException, so why this warning ?
原文:https://stackoverflow.com/questions/10717585
最满意答案
至少在使用低于9的IE时,Internet Explorer的Javascript引擎比其他网络浏览器的引擎慢。因此,如果您使用IE 6,7或8,现在您知道原因了。
就像raynjamin说的,尝试使用Sunspider测试IE。
最新的稳定Firefox(3.6)速度很快,但例如Google Chrome甚至更快。 浏览器的Javascript速度取决于其底层实现。
更新 :为了让您了解“快速”IE与其他浏览器的比较,我使用Sunspider 0.9.1在自己的计算机上进行了基准测试。 结果如下:
- Internet Explorer 8: 5039.8ms - Firefox 3.6: 967.9ms (loaded with extensions) - Chrome 9: 276.3ms - Opera 10.6: 293.2ms - Safari 5: 397.0ms
正如您所看到的,至少在使用Sunspider测试时,IE 8比Firefox 3.6慢5倍,比Chrome 9慢20倍。 这是一个巨大的差异,你可以看到,IE 8并不是那么快。
更新2 :有一种方法可以让IE更快。 存在称为Chrome框架的插件。 使用这个插件将使IE更快,因为它会使用Chrome的引擎。 我没有亲自尝试过,但我听到过很多好消息。
Internet Explorer's Javascript engine is slower than that from other web browsers, at least when using IE with versions lower than 9. So, if you're using IE 6, 7 or 8, now you know why.
Like raynjamin said, try testing IE using Sunspider.
The latest stable Firefox (3.6) is fast, but for example, Google Chrome is even faster. A browser's Javascript speed depends on its underlying implementation.
Update: to give you an idea of how "fast" IE is compared to other browsers, I've done a benchmark on my own computer using Sunspider 0.9.1. Here are the results:
- Internet Explorer 8: 5039.8ms - Firefox 3.6: 967.9ms (loaded with extensions) - Chrome 9: 276.3ms - Opera 10.6: 293.2ms - Safari 5: 397.0ms
As you can see, IE 8 is about 5 times slower than Firefox 3.6 and almost 20 times slower than Chrome 9, at least when using Sunspider tests. That is a drastic difference and you can see that IE 8 isn't all that fast.
Update 2: There is one way to make IE faster. A plugin called Chrome frame exists. Using this plugin will make IE faster since it will use Chrome's engine. I haven't tried it personally, but I've heard good things about it.
相关问答
更多-
HTML5 Canvas在Chrome上运行缓慢,但在FireFox上运行得很快(HTML5 Canvas slow on Chrome, but fast on FireFox)[2023-12-06]
编辑 :问题不是在这个答案中提出的问题。 我还编辑了代码以提供更多信息。 BlueMonkMN :从这个比较来看,我认为Chrome的OnHandleInputEvent实现在这里一直在吃。 这是怎么回事? 效果是可见的,即使在更小/更简单的项目上也不明显。 下面是一个只有700K的例子,与30+ MB的项目相比,这是一个更容易管理的测试项目。 如果你点击并拖动,你可以看到滚动略显碎片,但如果你释放鼠标按钮,它将继续滚动更顺畅。 看看你的代码(见下面),我可以看到你的事件处理程序代码调用重绘方法( 这就是为 ... -
ASP.NET从VStudio发送电子邮件运行速度很快,但在IIS中速度很慢(ASP.NET Send email from VStudio is running fast but very slow in IIS)[2021-12-31]
在ASP.NET应用程序中发送电子邮件时,有时您不希望用户体验减慢而只是等待发送电子邮件。 下面的代码示例是如何异步发送System.Net.Mail.MailMessage,以便当辅助线程发送电子邮件时当前线程可以继续。 public static void SendEmail(System.Net.Mail.MailMessage m) { SendEmail(m, true); } public static void SendEmail(System.Net.Mail.MailMess ... -
在IE 8中ajax非常慢,但在firefox和chrome中速度非常快(ajax very slow in IE 8 but very fast in firefox and chrome)[2024-01-10]
尝试这个。 function showDetails(stop){ var t1 = new Date().getTime(); var xmlHttpRequest; if(window.XMLHttpRequest){ xmlHttpRequest = new XMLHttpRequest(); }else{ xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } ... -
问题是Lithium会将对象中的所有数据打包,对于大型查询而言,这些数据可能非常耗费内存,因此速度很慢。 如果您不需要针对该特定查询的任何ActiveRecord功能,则可以将一个选项传递给find() ,该选项将传递给MongoDb::read() (因此请查看MongoDb::read()的文档)返回一个原始数组,或者可以手动迭代的实际数据库游标。 另一个选择是等到我实现流式迭代,这将解决内存问题。 :-) The issue is that Lithium boxes all the data in ...
-
最后能够从我的应用程序本身解决此问题。 在代码中的一个位置,在响应的输出流上调用刷新操作。 super.getOutputStream().flush(); 这只是在请求不是302类型的情况下才有意义,因为302s在响应中没有任何数据。 Chrome很聪明,可以看到并且不会等待任何数据。 但是,firefox和IE一直在等待数据,因此该特定调用的连接未关闭。 这会导致延迟,这可以在我在问题中附加的图像中看到(浏览器尝试下载从未到过的内容)。 我现在已经改变了代码来执行302s调用的刷新操作。 这解决了整个 ...
-
至少在使用低于9的IE时,Internet Explorer的Javascript引擎比其他网络浏览器的引擎慢。因此,如果您使用IE 6,7或8,现在您知道原因了。 就像raynjamin说的,尝试使用Sunspider测试IE。 最新的稳定Firefox(3.6)速度很快,但例如Google Chrome甚至更快。 浏览器的Javascript速度取决于其底层实现。 更新 :为了让您了解“快速”IE与其他浏览器的比较,我使用Sunspider 0.9.1在自己的计算机上进行了基准测试。 结果如下: - I ...
-
正如DanielB所指出的那样 ,Firebug就是其中之一。 As pointed out by DanielB, Firebug was the reason.
-
事实证明,LINQ表达式并不相同。 正确的linq表达式是: _myRepository.AsQueryable() .GroupBy(x => new {x.Foo, x.Bar, x.Baz}) .GroupBy(x => x.Key.Foo) .Select(x => new {x.Key, Count = x.Count()}) .ToDictionary(x => x.Key, x => x.Count); 我错过了一个我没想到的选择,因为在普通的SQL中你只能选 ...
-
不幸的是,我无法弄清楚这个问题的根本原因是什么。 所以,我想我至少会发布我曾经解决的解决方案。 幸运的是,我们有第二台托管服务器。 我迁移到这台服务器并将其安置在那里,似乎工作正常。 更有可能的是,原始服务器的问题可能是它的设置,安装方式或我们遇到的某种类型的防火墙问题。 Unfortunately, I was unable to figure out what the root cause of this problem was. So, I thought I would at least post ...
-
通过资源管理器,Samba读取速度非常慢,但通过Firefox可以正常(Samba read speeds very slow through Explorer, but OK through Firefox)[2022-04-06]
删除smb.conf中的自定义“套接字选项”行(Samba配置文件)为我解决了这个问题。 现在似乎最好将该选项留空,因为它将自己计算最佳值。 Firefox似乎要么使用自己的SMB协议设置,要么忽略Samba服务器设置的设置。 Removing custom "socket options" line in smb.conf (the Samba configuration file) solved it for me. It seems that it's best to leave that optio ...