I have this code:
public static class MyWebDriver extends RemoteWebDriver {
    @NotNull
    private final String nodeId;
    public MyRemoteWebDriver(@NotNull String nodeId) {
        super();
        this.nodeId = nodeId;
    }
    @Override
    public void quit() {
        System.out.println("deleting node: " + nodeId);
    }
}
and it's guaranteed that nodeId that is passed into constructor is not null. And because nodeId field is final I expect it to be initialised in my quit() method.
But, in super() constructor there is a try-catch block which in case of exception calls quit() method and throws an exception. And in this case nodeId that I get in my quit() method is not initialised (has null value).
Are there any ways of avoiding it except
@Override
public void quit() {
    if (nodeId != null) {
        System.out.println("deleting node: " + nodeId);
    }
}
this one? Which looks pretty stupid, because nodeId is marked as @NotNull.
 
     
     
     
     
    