Skip to content
Advertisement

Tag: exception

Can an assignment statement cause a null-pointer exception?

This code snippet is reading camera picture Exif metadata using ExifInterface: Apparently, one particular picture has no or invalid datetime and .getDateTime() is returning null. In the code I assign it to a long, dt, and that results in the exception that is shown below. Of course, if I un-comment the null-check just prior to the assignment, all is well.

Why list.contains(null) throwing null pointer exception?

I have List<Long> countriesList which contains Long values which are country ids. Now I am iterating over some List<UserRequests> list by using streams. I tried to debug by evaluating individual statements. I have made sure countriesList have some data First part CollectionUtils.isNotEmpty(countriesList) is returning true. userRequest is also not null but userRequest.getCountryId() is null. And when I evaluated countriesList.contains(userRequest.getCountryId()), I

Can you change the Type of Java Exception’s error message?

I’m writing an Internal-Facing tool with a very slow runtime. Because of this runtime I’m trying to validate the input for errors and send a JSON object with a detailed list of every missing or failing element to the client before actually running the tool. I was wondering if there was a way to modify java Exception’s error message return

Stop ExecutorService on thread failure and exception handling

This is a simplified example I did to expose my problem. I have some task doSomeWork() that I handle in a multihreading fashion using ExecutorService (4 threads at a time max). However, if any of the threads/tasks generates an exception, I would like to: Stop any further tasks from being processed. Catch the exception at the main thread level. Currently,

Advertisement