Java, being the oldest and most popular programming language in the world (according to TIOBE Index) has some advantages and disadvantages for using AWS Lambda. One of the biggest problems being slow cold starts, yet it often outperforms other languages in consecutive executions (depending, of course, on what task is performed).
As with any piece of code, it’s important to handle possible failures and to ensure that you get alerted as soon as problems occur. We’re going to go through common failures of Java based AWS Lambda functions and how to handle them with Dashbird.
First off, let’s go through the common failure types that we should acknowledge.
Parsing errors & checked exceptions
Since java applications must be compiled before they can be deployed to AWS, they are immune to a parsing errors happening during their executions – these get picked up while building the standalone jar file. This means you have one less thing to worry about.
An exception is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally, which is not recommended, therefore, these exceptions are to be handled.
Exceptions can be caused either user error, programmer error or by physical resources that have failed. Following are some scenarios where an exception occurs.
- A user has entered an invalid data.
- A file that needs to be opened cannot be found.
- A network connection has been lost in the middle of communications or the JVM has run out of memory.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 at Exceptions.Unchecked_Demo.main(Unchecked_Demo.java:8)Except
AWS Lambda errors
Apart from Java specific errors, programmers have to think about failures that are specific to Lambda functions. In Runtime-agnostic Best Practices we have covered most of the problems that cause headaches to serverless developers.
We aim to improve Dashbird every day and user feedback is extremely important for that, so please let us know if you have any feedback about our features and error handling! We would really appreciate it!
Can’t find what you’re looking for? We’d love to help. Send us a message through the chat bubble or email us.