#vulnerable code 
                                @Restricted(NoExternalUse.class)
    public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
        Plugin plugin = Jenkins.getInstance().getPlugin("swarm");
        if (plugin != null) {
            plugin.doDynamic(req, rsp);
        }
    } 
                            #location 3 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                @Restricted(NoExternalUse.class)
    public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
        Plugin plugin = Jenkins.get().getPlugin("swarm");
        if (plugin != null) {
            plugin.doDynamic(req, rsp);
        }
    }