Top 4 Java exceptions Raygun can help fix

Top 4 Java exceptions Raygun can help fix

Provider RelatedResourceTech Stuff Callum Gavin April 20, 2015 Leave a comment

There are a bunch of Java exceptions that are common to all code bases, and frequently occur at both compile time when implementing, and runtime when your application is in the wild. This last case is crucial to have visibility around – most developers may use a logging framework, or perhaps a hand-rolled notification system. The advantage of using a real error tracking service is huge. Here are some of the most common Java exceptions, and how Raygun can capture these at runtime and help you find the source of the bug, leading to reliable software and happy end users.

NullPointerException

Tony Hoare’s billion-dollar mistake of including ‘null’ in a modification to the Algol language must still be taken into account when dealing with the type system in Java (you will of course note that it’s a legit failure state, which can be handled in safer ways in languages like Rust). The act of accessing an uninitialized variable, or one that has been deliberately set to null, blows up strongly-typed code at runtime as the type system can’t provide any guarantees for the object (by design). Knowing when your code attempts to use null variables is crucial. If you’re in a web context, frequently a third-party API may return some error state in response to a request, and the variables which would have otherwise been set would be null.


(I know – it’s Knuth, not Hoare, but close enough. The hat sells it.)

Seriously though, Raygun will capture every instance of your code attempting to use null objects, and report the stack trace so you can pinpoint the issue. The Raygun4Java provider also allows you to set custom data, so you can provide the state of relevant variables, allowing you to easily diagnose NullPointerExceptions on your production hardware from your local machine.

IOException

This exception type (and others in its family) can be thrown when invalid file access occurs, which is most likely to occur when implementing a local application when debugging is easier. Networking errors can also result in this exception being thrown, which is more critical when this happens in production web applications or services.

It is particularly interesting how often connections can fall down at the network layer – for instance, database query timeouts. These can be quite frequent, especially if your code is running in a public cloud with noisy neighbours, or in general if resource contention is a factor. Raygun will capture instances of these exceptions, giving you insights as to how often these are occurring over time, which would be very difficult to see from view log files.

Concurrent (threading) exceptions

Exceptions like InterruptedException are raised when your thread receives an interrupt while it is executing. You must catch this or return it to be handled higher up (depending on whether it makes sense for the current method to do so). These and similar concurrent exceptions may only start to appear under heavy load in production when contention for threading resources becomes a factor. It is important to use a tool like Raygun that can track and group these sensibly, so you can see how often and when these are occurring as their transient nature can be quite difficult to reproduce locally.

IllegalArgumentException

This is one you should be throwing in your own code, so that at runtime when a method receives invalid input you can throw an appropriately typed exception. Raygun can show instances of these, and as in the null pointer case, you can attach custom data to see the particular invalid arguments that were passed in (for instance, zero as the denominator for a Divide() method). This would be invaluable when developing anything that accepts user input, for instance a web API or service, mobile app, or desktop application.

Get started with Raygun now

Interested in trying professional-grade error tracking? All of these insights and more are available with Raygun, so start your free 30-day trial now, no credit card needed. Happy exception blasting!

时间: 2024-10-12 00:19:32

Top 4 Java exceptions Raygun can help fix的相关文章

6 Java Exceptions that Haunts a Newbie Java Developer(Java菜鸟6种常见的异常)

Every now and then, I come across various newbies Java developers who are found to get stuck with some of the following common exceptions where I need to explain them all over again. I do believe that this is same with many other senior Java develope

Top 10 Java Debugging Tips with Eclipse

In this tutorial we will see about debugging java applications using Eclipse. Debugging helps us to identify and fix defects in the application. We will focus on run-time issues and not compile time errors. There are command line debuggers like gdb a

Hunting for top class Java developers

Requirement: You MUST have excellent communication skills in English (both verbal and oral) Real talent programmer (make sure you understand word talent) Solid experience on common Java tech stacks Java core technology Any MVC framework (Spring MVC/P

Java Exceptions

1. 常见错误分类 一般的,errors可以分为以下几类: user input errors device errors or physical limitations code errors 2. 常用错误处理方式 2.1 error code 一种常用的错误处理方法是返回error code,由calling method根据error code做不同处理. 但是有些情形下error code并不方便使用,比如如何取分错误码和与错误码相同的有效值. 2.2 exception handli

Top 15 Java Utility Classes

In Java, a utility class is a class that defines a set of methods that perform common functions. This post shows the most frequently used Java utility classes and their most commonly used methods. Both the class list and their method list are ordered

Thinking in Java,Fourth Edition(Java 编程思想,第四版)学习笔记(十二)之Error Handling with Exceptions

The ideal time to catch an error is at compile time, before you even try to run the program. However, not all errors can be detected at compile time. To create a robust system, each component must be robust. By providing a consistent error-reporting

Top 10 Questions about Java Exceptions--reference

reference from:http://www.programcreek.com/2013/10/top-10-questions-about-java-exceptions/ This article summarizes the top 10 frequently asked questions about Java exceptions. 1. Checked vs. Unchecked In brief, checked exceptions must be explicitly c

2016 年排名 Top 100 的 Java 类库

我们分析了GitHub中47,251个依赖,从中找出了排名前一百的Java类库,让我们看看谁在前面,谁在后面. 我们在漫长的周末的消遣方式就是浏览GitHub并且搜索流行的Java类库.我们决定把其中的乐趣与结果分享给你. 我们分析了GitHub中排名前3,862个项目中的47,251个导入语句,其中有12,059个Java类库被依赖.我们从这个列表中提取出前一百并把结果分享给你. 最受欢迎的前20个Java类库 和上次分析结果一致,junit依旧是GitHub中最受欢迎的类库.Java中的日志

java异常面试常见题目

在Java核心知识的面试中,你总能碰到关于 处理Exception和Error的面试题.Exception处理是Java应用开发中一个非常重要的方面,也是编写强健而稳定的Java程序的关键,这自然使它成为面试题中的常客.关于Java中Error和Exception的面试题目多是关于Exception和Error的概念,如何处理Exception,以及 处理Exception时需要遵守的最佳实践等等.尽管关于多线程.垃圾回收.JVM概念和面向对象设计等方面的问题依然主宰着这类面试,你仍然需要为回答