如何识别具有特定数据的throwable(How to identify a throwable with specific data)
我抓住了这个捕获任何未捕获的异常
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { } });
在方法内部,我想以不同于其他异常的方式处理以下异常:
Caused by: java.lang.NullPointerException at com.company.si.stats.Statistics.hashString(Statistics.java:192) at com.company.si.stats.Statistics.sendStatistics(Statistics.java:127)
我想基本上检查它是来自
com.company.si.stats.Statistics.hashString
nullpointer异常我怎样才能做到这一点? 我不确定我应该比较一下throwable中的哪些参数?
抛出异常的代码不是我写的,所以我无法改变它。
重要说明我知道我接近这个问题的方式不正确。 但我无法访问提高异常的库,我需要一个解决方法,直到在库中修复了错误。 选择答案是因为它满足了我的需要,而不是通常应该是什么
I have this caught that catches any uncaught exception
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { } });
Inside the method, I want to deal with following exception differently than other exceptions:
Caused by: java.lang.NullPointerException at com.company.si.stats.Statistics.hashString(Statistics.java:192) at com.company.si.stats.Statistics.sendStatistics(Statistics.java:127)
I want basically to check that it is nullpointer exception coming from
com.company.si.stats.Statistics.hashString
How can I do that? I am not sure what parameters in throwable I should compare against?
The code where exception is thrown was not written by me, so I cannot change anything about it.
Important NOTE I know the way I am approaching this problem is not the right way. But I dont have access to the library raising the exception and I needed a workaround till the bug is fixed in the library. The answer was chosen because it satisfies what I need to, and not what generally should be dne
原文:https://stackoverflow.com/questions/40445610
最满意答案
我记得在邮件列表上看过这个主题......
http://grails.1312388.n4.nabble.com/Incremental-Deployment-td3066617.html
...他们建议使用rsync或xdelta3仅传输更新的文件。 没试过,但它可能对你有所帮助?
I remember seeing this subject on the mailing list...
http://grails.1312388.n4.nabble.com/Incremental-Deployment-td3066617.html
...they recommend using rsync or xdelta3 to only transfer updated files. Haven't tried it, but it might help you?
相关问答
更多-
你不需要SVN下的./plugins/core(Core Grails插件) 在SVN下你不需要./web-app/WEB-INF/下的任何东西。 你通常不需要把文件放在这里。 如果需要提供任何内容,则./conf中的文件将复制到WEB-INF / classes中,以便它们位于类路径中。 以下是更详细描述的文档链接 。 You do not want ./plugins/core (Core Grails plugins) under SVN You do not want anything under ...
-
我不建议在Raspberry Pi上运行任何非“Hello World”样式的Grails应用程序。 通常 ,512MB的RAM是最小的,以便在中小型应用程序上具有良好的性能。 Tomcat内存使用率+ 512MB RAM上的应用程序内存使用量对我来说在Raspberry Pi上看起来不太好...... 请参阅Igor 关于这个相关SO问题的第二个答案。 请考虑其他替代方案Spring MVC或更轻量级的东西(没有太多的代理,Web框架中的反射量少等)。 I would not recommend runn ...
-
它现在正在工作,原始行compile "org.springframework.boot:spring-boot-starter-tomcat" 。 。 。 我只是改变了provided "org.springframework.boot:spring-boot-starter-tomcat" 愚蠢的我,当我应该替换原来的时候,我添加了新的依赖关系! 。 。 。 我喜欢贴纸 dependencies { . . . //compile "org.springframework.boot:sp ...
-
我们通过CloudFoundry运行ShareYourLove.com,它运行良好。 它不会超过标准EC2费用。 最好的选择(如果你还没有收到CF登录)是购买像http://www.linode.com这样的低成本Linux机器,并自己安装tomcat和mysql。 干杯 背风处 We are running ShareYourLove.com via CloudFoundry and it works well. It doesn't cost us any extra over the standard ...
-
Grails WAR部署问题(Grails WAR deployment issues)[2021-07-08]
Grails尝试在您启动tomcat的目录中写入文件stacktrace.log。 “权限被拒绝”错误可能意味着tomcat缺少对该文件夹的写入权限。 也许你从tomcat进程无法访问的文件夹中启动tomcat? 尝试从例如其日志目录(运行../bin/startup.sh )启动tomcat,看看是否有效。 编辑:以上是错误#2。 基本原因看起来是用数据源初始化spring bean的问题。 用户'grails'@'localhost'无法访问localhost上的MySQL数据库 Grails trie ... -
原来这个问题与“熵源”有关,正如Tomcat wiki上关于如何加速启动Tomcat的记录。 因此解决方案是将以下JDK选项添加到Tomcat配置文件中:/ etc / default / tomcat7: -Djava.security.egd=file:/dev/./urandom 现在Tomcat可以在大约20-30秒内可靠地启动。 It turned out this problem was related to the "Entropy Source", as documented on the ...
-
对此的解决方案与此答案几乎相同。 内置属性basedir和
PluginBaseDir区分目标应用程序和插件目录。 The solution to this is almost the same as this answer. The built-in properties basedir and PluginBaseDir differentiate the target app and the plugin directories. -
我记得在邮件列表上看过这个主题...... http://grails.1312388.n4.nabble.com/Incremental-Deployment-td3066617.html ...他们建议使用rsync或xdelta3仅传输更新的文件。 没试过,但它可能对你有所帮助? I remember seeing this subject on the mailing list... http://grails.1312388.n4.nabble.com/Incremental-Deployment ...
-
找到'解决方案',以防其他人在寻找。 如果我将插件的声明从application.properties移动到BuildConfig.groovy,则错误消失。 我不确定它是否真的“修复”它或者它是否导致清理/重新安装可能已经清除它的tomcat插件,但它删除了部署时的错误。 在此之后我遇到了另一个错误,JBoss hibernate libs比Grails 2.1.1依赖项中的更旧: Caused by: java.lang.NoSuchMethodException: org.hibernate.vali ...
-
对于上面提到的警告:安装cloud-foundry插件后: 打开dependencies.groovy文件并更改compile(“:cloud-support:[1.0.7,)”)以编译':cloud-support:1.0.8'。 在plugin.xml version = [1.0.7,)“更改为version ='[1.0.8]'。 现在运行grails cf-info ..不会填充任何警告。 For the above mentioned warning: After installing the ...