#fixed code
                                public static void processQuery(MBeanServerConnection mbeanServer, Query query) throws Exception {
        
        List<Result> resList = new ArrayList<Result>();

        ObjectName oName = new ObjectName(query.getObj());

        Set<ObjectName> queryNames = mbeanServer.queryNames(oName, null);
        for (ObjectName queryName : queryNames) {
            MBeanInfo info = mbeanServer.getMBeanInfo(queryName);
            ObjectInstance oi = mbeanServer.getObjectInstance(queryName);

            List<String> queryAttributes = query.getAttr();
            if (queryAttributes == null || queryAttributes.size() == 0) {
                MBeanAttributeInfo[] attrs = info.getAttributes();
                for (MBeanAttributeInfo attrInfo : attrs) {
                    query.addAttr(attrInfo.getName());
                }
            }

            try {
                if (query.getAttr() != null && query.getAttr().size() > 0) {
                    log.debug("Started query: " + query);
                    AttributeList al = mbeanServer.getAttributes(queryName, query.getAttr().toArray(new String[query.getAttr().size()]));
                    for (Attribute attribute : al.asList()) {
                        getResult(resList, info, oi, (Attribute)attribute, query);
                    }
                    if (log.isDebugEnabled()) {
                        log.debug("Finished query.");
                    }

                    query.setResults(resList);

                    // Now run the filters.
                    runFiltersForQuery(query);

                    if (log.isDebugEnabled()) {
                        log.debug("Finished running filters: " + query);
                    }
                }
            } catch (UnmarshalException ue) {
                if (ue.getCause() != null && ue.getCause() instanceof ClassNotFoundException) {
                    log.debug("Bad unmarshall, continuing. This is probably ok and due to something like this: " +
                    		"http://ehcache.org/xref/net/sf/ehcache/distribution/RMICacheManagerPeerListener.html#52", ue.getMessage());
                }
            }
        }
        
    }
#vulnerable code 
                                public static void processQuery(MBeanServerConnection mbeanServer, Query query) throws Exception {
        
        List<Result> resList = new ArrayList<Result>();

        ObjectName oName = new ObjectName(query.getObj());

        Set<ObjectName> queryNames = mbeanServer.queryNames(oName, null);
        for (ObjectName queryName : queryNames) {
            MBeanInfo info = mbeanServer.getMBeanInfo(queryName);
            ObjectInstance oi = mbeanServer.getObjectInstance(queryName);

            List<String> queryAttributes = query.getAttr();
            if (queryAttributes == null || queryAttributes.size() == 0) {
                MBeanAttributeInfo[] attrs = info.getAttributes();
                for (MBeanAttributeInfo attrInfo : attrs) {
                    query.addAttr(attrInfo.getName());
                }
            }
            AttributeList al = mbeanServer.getAttributes(queryName, query.getAttr().toArray(new String[query.getAttr().size()]));
            for (Attribute attribute : al.asList()) {
                getResult(resList, info, oi, (Attribute)attribute, query);
            }
        }
        if (log.isDebugEnabled()) {
            log.debug("Executed query: " + query);
        }
        
        query.setResults(resList);

        // Now run the filters.
        runFiltersForQuery(query);

        if (log.isDebugEnabled()) {
            log.debug("Finished running filters: " + query);
        }
    } 
                            #location 19 
                            #vulnerability type NULL_DEREFERENCE