#fixed code
                                protected void changeRole(Role new_role) {
        final RaftImpl new_impl=new_role == Role.Follower? new Follower(this) : new_role == Role.Candidate? new Candidate(this) : new Leader(this);
        withLockDo(impl_lock, new Callable<Void>() {
            public Void call() throws Exception {
                if(!impl.getClass().equals(new_impl.getClass())) {
                    impl.destroy();
                    new_impl.init();
                    impl=new_impl;
                }
                return null;
            }
        });
    }
#vulnerable code 
                                protected void changeRole(Role new_role) {
        RaftImpl new_impl=null;
        switch(new_role) {
            case Follower:
                new_impl=new Follower(this);
                break;
            case Candidate:
                new_impl=new Follower(this);
                break;
            case Leader:
                new_impl=new Leader(this);
                break;
        }
        impl_lock.lock();
        try {
            if(!impl.getClass().equals(new_impl.getClass())) {
                impl.destroy();
                new_impl.init();
                impl=new_impl;
            }
        }
        finally {
            impl_lock.unlock();
        }
    } 
                            #location 16 
                            #vulnerability type NULL_DEREFERENCE