All Questions
5 questions
1
vote
5
answers
2k
views
Is this an anti pattern or misusing the interface default method?
Instead of checking the null and throwing exception each time we call findByOrderNumber method, I came up with this pattern by taking advantage of a default method, are there any patterns misused here ...
1
vote
2
answers
2k
views
Is it beneficial to throw a caught IOException as an UncheckedIOException in order to prevent NullPointerException?
Not using UncheckedIOException, NullPointerException possible
public void callerMethod() {
Object result = ioMethod();
// call instance method of result
}
public Object ioMethod() {
...
4
votes
3
answers
3k
views
A very basic question about whether I should check for null and throw NPE? [duplicate]
Consider the below method-
public void operationOnList(List<String> list) {
list.add(1);
}
It is obvious that if list is null this method will throw a NullPointerException.
My question is ...
4
votes
2
answers
399
views
Nulls in every type and checked exceptions in Java?
I know that null being added to every type in Java is a source of much frustration regarding the language's type system. At the same time I generally hear complaining about checked exceptions - that ...
11
votes
10
answers
2k
views
Should security restrictions cause a service to return null or throw an exception? [closed]
I'm in a bit of a disagreement with a more experienced developer on this issue, and wondering what others think about it; our environment is Java, EJB 3, services, etc.
The code I wrote calls a ...