/*
(non-Javadoc)

@see
edu.umd.cs.findbugs.anttask.AbstractFindBugsTask#configureFindbugsEngine
()
778212
@Override
    protected void configureFindbugsEngine() {
        if (not != null) {
            addArg("-not");
        }
        addBoolOption("-notAProblem", notAProblem);
        addBoolOption("-withSource", withSource);
        addOption("-exclude", exclude);
        addOption("-include", include);
        addOption("-annotation", annotation);
        addOption("-after", after);
        addOption("-before", before);
        addOption("-first", first);
        addOption("-last", last);
        addOption("-fixed", fixed);
        addOption("-present", present);
        addOption("-absent", absent);
        addBoolOption("-active", active);
        addBoolOption("-introducedByChange", introducedByChange);
        addBoolOption("-removedByChange", removedByChange);
        addBoolOption("-newCode", newCode);
        addBoolOption("-removedCode", removedCode);
        addOption("-priority", priority);
        addOption("-maxRank", maxRank);
        addOption("-class", clazz);
        addOption("-bugPattern", bugPattern);
        addOption("-category", category);
        addOption("-designation", designation);
        addBoolOption("-withMessages", withMessages);
        addBoolOption("-applySuppression", applySuppression);
        if (excludeBugs != null) {
            addArg("-excludeBugs");
            addArg(excludeBugs);
        }

        addArg(inputFile.getName());

        addArg(outputFile.getPath());
    }
945691
protected void configureMpJwt(boolean doFeatureCheck) {

        if (doFeatureCheck && !MpJwtHelper.isMpJwtFeatureActive()) {
            return;
        }

        String annoName = "org.eclipse.microprofile.auth.LoginConfig";
        Set<String> annotatedClasses = null;
        InfoStore annosInfo = null;
        try {
            annotatedClasses = configurator.getWebAnnotations().getAnnotationTargets().getAnnotatedClasses(annoName);
            annosInfo = configurator.getWebAnnotations().getInfoStore();
        } catch (UnableToAdaptException e) { // ffdc and return
            return;
        }
        if (annotatedClasses.size() == 0) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(this, tc, "no annotated classes found, return");
            }
            return;
        }
        if (loginConfiguration != null && !loginConfiguration.isAuthenticationMethodDefaulted()) {
            // we already have something from web.xml, annos don't matter.
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(this, tc, "already have auth method determined, return");
            }
            return;
        }
        // we have an annotation and no DD, so check it out
        String className = annotatedClasses.iterator().next();
        ClassInfo ci = annosInfo.getDelayableClassInfo(className);
        boolean isValid = false;
        while (ci != null) {
            if ("javax.ws.rs.core.Application".equals(ci.getSuperclassName())) {
                isValid = true;
                break;
            }
            ci = ci.getSuperclass();
        }
        ci = annosInfo.getDelayableClassInfo(className);
        if (!isValid) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(this, tc, "loginConfig annotation  found, but on wrong class, " + ci.getSuperclassName() + ", return");
            }
            return;
        }
        AnnotationInfo ai = ci.getAnnotation(annoName);
        AnnotationValue authMethod, realmName;
        authMethod = ai.getValue("authMethod");
        realmName = ai.getValue("realmName");
        String authMethodString = authMethod == null ? null : authMethod.getStringValue();
        String realmNameString = realmName == null ? null : realmName.getStringValue();
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "setting authMethod and realm to: "
                               + authMethodString + " " + realmNameString);
        }

        loginConfiguration = new LoginConfigurationImpl(authMethodString, realmNameString, null);
    }
108994
public void configure(Properties props) {
        this.refreshCount.set(0);
        this.overrideProps.clear();
        
        this.originalAsyncAppenderNameMap.clear();
       // First try to load the log4j configuration file from the classpath
        String log4jConfigurationFile = System.getProperty(PROP_LOG4J_CONFIGURATION);
        
        NFHierarchy nfHierarchy = null;
        
        // Make log4j use blitz4j implementations
        if ((!NFHierarchy.class.equals(LogManager.getLoggerRepository().getClass()))) {
            nfHierarchy = new NFHierarchy(new NFRootLogger(org.apache.log4j.Level.INFO));
            org.apache.log4j.LogManager.setRepositorySelector(new NFRepositorySelector(nfHierarchy), guard);
        }
        
        String log4jLoggerFactory = System.getProperty(PROP_LOG4J_LOGGER_FACTORY);
        if (log4jLoggerFactory != null) {
            this.initialProps.setProperty(PROP_LOG4J_LOGGER_FACTORY, log4jLoggerFactory);
            if (nfHierarchy != null) {
                try {
                    LoggerFactory loggerFactory = (LoggerFactory) Class.forName(log4jLoggerFactory).newInstance();
                    nfHierarchy.setLoggerFactory(loggerFactory);
                } catch (Exception e) {
                    System.err.println("Cannot set the logger factory. Hence reverting to default.");
                    e.printStackTrace();
                }
            }
        } else {
            this.initialProps.setProperty(PROP_LOG4J_LOGGER_FACTORY, BLITZ_LOGGER_FACTORY);

        }
        if (log4jConfigurationFile != null) {
            loadLog4jConfigurationFile(log4jConfigurationFile);
            // First configure without async so that we can capture the output
            // of dependent libraries
            clearAsyncAppenderList();
            PropertyConfigurator.configure(this.initialProps);
        }

        this.blitz4jConfig = new DefaultBlitz4jConfig(props);

        if ((log4jConfigurationFile == null) && (blitz4jConfig.shouldLoadLog4jPropertiesFromClassPath())) {
            try {
                URL url = Loader.getResource(LOG4J_PROPERTIES);
                if (url != null) {
                    try (InputStream in = url.openStream()) {
                        this.initialProps.load(in);
                    }
                }
            } catch (Exception t) {
                System.err.println("Error loading properties from " + LOG4J_PROPERTIES);
            } 
        }   
        
        Enumeration enumeration = props.propertyNames();
        while (enumeration.hasMoreElements()) {
            String key = (String) enumeration.nextElement();
            String propertyValue = props.getProperty(key);
            this.initialProps.setProperty(key, propertyValue);
        }
        
        this.blitz4jConfig = new DefaultBlitz4jConfig(this.initialProps);
    
        String[] asyncAppenderArray = blitz4jConfig.getAsyncAppenders();
        if (asyncAppenderArray == null) {
            return;
        }
        for (int i = 0; i < asyncAppenderArray.length; i++) {
            String oneAppenderName = asyncAppenderArray[i];
            if ((i == 0) || (oneAppenderName == null)) {
                continue;
            }
            oneAppenderName = oneAppenderName.trim();
            String oneAsyncAppenderName = oneAppenderName + ASYNC_APPENDERNAME_SUFFIX;
            originalAsyncAppenderNameMap.put(oneAppenderName, oneAsyncAppenderName);
        }
        try {
            convertConfiguredAppendersToAsync(this.initialProps);
        } catch (Exception e) {
            throw new RuntimeException("Could not configure async appenders ",
                    e);
        }
        // Yes second time init required as properties would have been during async appender conversion
        this.blitz4jConfig = new DefaultBlitz4jConfig(this.initialProps);
        clearAsyncAppenderList();
        PropertyConfigurator.configure(this.initialProps);
        closeNonexistingAsyncAppenders();
        this.logger = org.slf4j.LoggerFactory.getLogger(LoggingConfiguration.class);
        ConfigurationManager.getConfigInstance().addConfigurationListener(
                new ExpandedConfigurationListenerAdapter(this));
    }
1028463
private void setFindBugsCommand(IProjectDescription description, ICommand newCommand) throws CoreException {
        ICommand[] oldCommands = description.getBuildSpec();
        ICommand oldFindBugsCommand = getFindBugsCommand(description);
        ICommand[] newCommands;
        if (oldFindBugsCommand == null) {
            // Add the FindBugs build spec AFTER all other builders
            newCommands = new ICommand[oldCommands.length + 1];
            System.arraycopy(oldCommands, 0, newCommands, 0, oldCommands.length);
            newCommands[oldCommands.length] = newCommand;
        } else {
            for (int i = 0, max = oldCommands.length; i < max; i++) {
                if (oldCommands[i] == oldFindBugsCommand) {
                    oldCommands[i] = newCommand;
                    break;
                }
            }
            newCommands = oldCommands;
        }
        // Commit the spec change into the project
        description.setBuildSpec(newCommands);
        getProject().setDescription(description, null);
    }
260785
function (project) {
			if (project) {
				this._projectClient.getProjectLaunchConfigurations(project).then(function(launchConfigurations){
					if (project !== this._project) return;
					this._setLaunchConfigurations(launchConfigurations);
				}.bind(this));
			} else {
				this._setLaunchConfigurations(null);
			}
		}
191947
@Override
	protected void configure(FilterRegistration.Dynamic registration) {
		super.configure(registration);
		EnumSet<DispatcherType> dispatcherTypes = this.dispatcherTypes;
		if (dispatcherTypes == null) {
			dispatcherTypes = EnumSet.of(DispatcherType.REQUEST);
		}
		Set<String> servletNames = new LinkedHashSet<>();
		for (ServletRegistrationBean<?> servletRegistrationBean : this.servletRegistrationBeans) {
			servletNames.add(servletRegistrationBean.getServletName());
		}
		servletNames.addAll(this.servletNames);
		if (servletNames.isEmpty() && this.urlPatterns.isEmpty()) {
			registration.addMappingForUrlPatterns(dispatcherTypes, this.matchAfter,
					DEFAULT_URL_MAPPINGS);
		}
		else {
			if (!servletNames.isEmpty()) {
				registration.addMappingForServletNames(dispatcherTypes, this.matchAfter,
						StringUtils.toStringArray(servletNames));
			}
			if (!this.urlPatterns.isEmpty()) {
				registration.addMappingForUrlPatterns(dispatcherTypes, this.matchAfter,
						StringUtils.toStringArray(this.urlPatterns));
			}
		}
	}
1005901
private void execFindbugs() throws BuildException {

        System.out.println("Executing SpotBugs " + this.getClass().getSimpleName() + " from ant task");
        createFindbugsEngine();
        configureFindbugsEngine();

        beforeExecuteJavaProcess();

        if (getDebug()) {
            log(getFindbugsEngine().getCommandLine().describeCommand());
        }

        /*
         * set property containing return code of child process using a task
         * identifier and a UUID to ensure exit code corresponds to this
         * execution (the base Ant Task won't overwrite return code once it's
         * been set, so unique identifiers must be used for each execution if we
         * want to get the exit code)
         */
        String execReturnCodeIdentifier = execResultProperty + "." + UUID.randomUUID().toString();
        getFindbugsEngine().setResultProperty(execReturnCodeIdentifier);

        /*
         * if the execution fails, we'll report it ourself -- prevent the
         * underlying Ant Java object from throwing an exception
         */
        getFindbugsEngine().setFailonerror(false);
        try {
            getFindbugsEngine().execute();
        } catch (BuildException be) {
            // setFailonerror(false) should ensure that this doesn't happen,
            // but...
            log(be.toString());
        }
        String returnProperty = getFindbugsEngine().getProject().getProperty(execReturnCodeIdentifier);
        int rc = returnProperty == null ? 0 : Integer.parseInt(returnProperty);

        afterExecuteJavaProcess(rc);
    }
312224
public void setBugzillaVersion(final String bugzillaVersion) {
        if (bugzillaVersion == null && this.bugzillaVersion == null) {
            return;
        } else if (bugzillaVersion == null) {
            removeChild(this.bugzillaVersion);
            this.bugzillaVersion = null;
        } else if (this.bugzillaVersion == null) {
            this.bugzillaVersion = new KeyValueNode<String>(CommonConstants.CS_BUGZILLA_VERSION_TITLE, bugzillaVersion);
            appendChild(this.bugzillaVersion, false);
        } else {
            this.bugzillaVersion.setValue(bugzillaVersion);
        }
    }
935801
private void setupIndexMonitor(final DataSchema dataSchema, final GenericDataSource dataSource) {
        logger.log(FINE,"LuceneSearchServiceImpl::setupIndexMonitor Attempting to setup Index monitor...");

        try {
            if(GoogleAppEngineUtil.isGaeEnv()){
                return; // only use for pure lucene tomcat implementation, doesn't work on GAE.
            }
            if (dataSource.getDataSourceType() != GenericDataSource.DataSourceType.ServletRelativeDataSource || dataSource.getLocation() == null) {
                // only able to monitor servlet relative datasources
                return;
            } else {
//                assertFilePathExists(dataSource.getLocation(), "jsonPath invalid:");
//                File json = new File(dataSource.getLocation());
//                try {
//                    fileChangeMonitor = FileChangeMonitor.getInstance();
//                    fileChangeMonitor.init(json.toPath());
//                    if(Log.isDebugEnabled()) Log.debug("LuceneSearchServiceImpl::setupIndexMonitor","Index monitor setup completed.");
//                } catch (IOException e) {
//                    throw new SearchException("Unable to initialize file change monitor",e);
//                }
            }
            fileChangeMonitor = FileChangeMonitor.getInstance();
            fileChangeMonitor.addObserver(new Observer() {
                @Override
                public void update(Observable o, Object arg) {
                    JSONWithMetaData jsonContent;
                    try {
                        logger.log(FINE,"LuceneSearchServiceImpl::setupIndexMonitor", "Index monitor change noted.");
                        jsonContent = getJsonArrayFrom(dataSource);
                    } catch (SearchException e) {
                        throw new IllegalStateException(e);
                    }
                    setupIndex(dataSource, dataSchema, jsonContent);
                }
            });
        } catch (Exception e) {
            logger.log(SEVERE,"LuceneSearchServiceImpl::setupIndexMonitor Failed to setup monitor for indexed file changes", e);
        }
    }
1373143
public static void initPoolConf() throws DevFailed {
        polledDevices.clear();
        final Map<String, String[]> prop = PropertiesUtils.getDeviceProperties(ServerManager.getInstance()
                .getAdminDeviceName());
        if (prop.containsKey(POLLING_THREADS_POOL_CONF)) {
            final String[] pollingThreadsPoolConf = prop.get(POLLING_THREADS_POOL_CONF);
            for (int i = 0; i < pollingThreadsPoolConf.length; i++) {
                if (cacheList.containsKey(pollingThreadsPoolConf[i]) && !pollingThreadsPoolConf[i].isEmpty()
                        && !polledDevices.contains(pollingThreadsPoolConf[i])) {
                    polledDevices.add(pollingThreadsPoolConf[i]);
                }
            }
        }
    }
166385
public final void setGeneratingDebug(boolean generatingDebug)
    {
        if (sealed) onSealedMutation();
        generatingDebugChanged = true;
        if (generatingDebug && getOptimizationLevel() > 0)
            setOptimizationLevel(0);
        this.generatingDebug = generatingDebug;
    }
284850
protected Set<String> configureContentTypeSuffixes(ContentTypeEngines engines) {
        if (null == ClassUtil.getAnnotation(method, ContentTypeBySuffix.class)) {
            return Collections.emptySet();
        }

        Set<String> suffixes = new TreeSet<>();
        for (String suffix : engines.getContentTypeSuffixes()) {
            String contentType = engines.getContentTypeEngine(suffix).getContentType();
            if (declaredProduces.contains(contentType)) {
                suffixes.add(suffix);
            }
        }
        return suffixes;
    }
382222
protected void loadConfiguredSinks(String filename, String bugType) {
        SINKS_LOADER.loadConfiguredSinks(filename, bugType, new SinksLoader.InjectionPointReceiver() {
            @Override
            public void receiveInjectionPoint(String fullMethodName, InjectionPoint injectionPoint) {
                addParsedInjectionPoint(fullMethodName, injectionPoint);
            }
        });
    }
101937
public static void setDebugSettingsForDevelopment(final Application application)
	{
		application.getDebugSettings().setComponentUseCheck(true);
		application.getDebugSettings().setOutputMarkupContainerClassName(true);
		application.getDebugSettings().setLinePreciseReportingOnAddComponentEnabled(true);
		application.getDebugSettings().setLinePreciseReportingOnNewComponentEnabled(true);
		application.getDebugSettings().setAjaxDebugModeEnabled(true);
		application.getDebugSettings().setDevelopmentUtilitiesEnabled(true);
	}
790068
private static IFindBugsEngine createEngine(@Nonnull Project p, BugReporter pcb) {
        FindBugs2 engine = new FindBugs2();
        engine.setBugReporter(pcb);
        engine.setProject(p);

        engine.setDetectorFactoryCollection(DetectorFactoryCollection.instance());

        //
        // Honor -effort option if one was given on the command line.
        //
        engine.setAnalysisFeatureSettings(Driver.getAnalysisSettingList());

        return engine;
    }
134815
private PBXObjectRef addProjectConfigurationList(final Map objects, final String baseDir,
      final List<DependencyDef> dependencies, final CommandLineCompilerConfiguration compilerConfig,
      final CommandLineLinkerConfiguration linkerConfig) {
    //
    // Create a configuration list with
    // two stock configurations: Debug and Release
    //
    final List configurations = new ArrayList();
    final Map<String, Object> debugSettings = new HashMap<>();
    debugSettings.put("GCC_WARN_ABOUT_RETURN_TYPE", "YES");
    debugSettings.put("GCC_WARN_UNUSED_VARIABLE", "YES");
    debugSettings.put("PREBINDING", "NO");
    debugSettings.put("SDKROOT", "/Developer/SDKs/MacOSX10.4u.sdk");

    final PBXObjectRef debugConfig = createXCBuildConfiguration("Debug", debugSettings);
    objects.put(debugConfig.getID(), debugConfig.getProperties());
    configurations.add(debugConfig);

    final Map<String, Object> releaseSettings = new HashMap<>();
    releaseSettings.put("GCC_WARN_ABOUT_RETURN_TYPE", "YES");
    releaseSettings.put("GCC_WARN_UNUSED_VARIABLE", "YES");
    releaseSettings.put("PREBINDING", "NO");
    releaseSettings.put("SDKROOT", "/Developer/SDKs/MacOSX10.4u.sdk");
    final PBXObjectRef releaseConfig = createXCBuildConfiguration("Release", releaseSettings);
    objects.put(releaseConfig.getID(), releaseConfig.getProperties());
    configurations.add(releaseConfig);
    final PBXObjectRef configurationList = createXCConfigurationList(configurations);
    final Map projectConfigurationListProperties = configurationList.getProperties();
    projectConfigurationListProperties.put("defaultConfigurationIsVisible", "0");
    projectConfigurationListProperties.put("defaultConfigurationName", "Debug");
    objects.put(configurationList.getID(), configurationList.getProperties());

    //
    // add include paths to both configurations
    //
    final File[] includeDirs = compilerConfig.getIncludePath();
    if (includeDirs.length > 0) {
      final List<String> includePaths = new ArrayList<>();
      final Map<String, String> includePathMap = new HashMap<>();
      for (final File includeDir : includeDirs) {
        if (!CUtil.isSystemPath(includeDir)) {
          final String absPath = includeDir.getAbsolutePath();
          if (!includePathMap.containsKey(absPath)) {
            if (absPath.startsWith("/usr/")) {
              includePaths.add(CUtil.toUnixPath(absPath));
            } else {
              final String relPath = CUtil.toUnixPath(CUtil.getRelativePath(baseDir, includeDir));
              includePaths.add(relPath);
            }
            includePathMap.put(absPath, absPath);
          }
        }
      }
      includePaths.add("${inherited)");
      debugSettings.put("HEADER_SEARCH_PATHS", includePaths);
      releaseSettings.put("HEADER_SEARCH_PATHS", includePaths);
    }

    //
    // add preprocessor definitions to both configurations
    //
    //
    final String[] preArgs = compilerConfig.getPreArguments();
    final List<String> defines = new ArrayList<>();
    for (final String preArg : preArgs) {
      if (preArg.startsWith("-D")) {
        defines.add(preArg.substring(2));
      }
    }
    if (defines.size() > 0) {
      defines.add("$(inherited)");
      debugSettings.put("GCC_PREPROCESSOR_DEFINITIONS", defines);
      releaseSettings.put("GCC_PREPROCESSOR_DEFINITIONS", defines);
    }

    if (linkerConfig != null) {
      final Map<String, String> librarySearchMap = new HashMap<>();
      final List<String> librarySearchPaths = new ArrayList<>();
      final List<String> otherLdFlags = new ArrayList<>();
      final String[] linkerArgs = linkerConfig.getEndArguments();
      for (final String linkerArg : linkerArgs) {
        if (linkerArg.startsWith("-L")) {
          final String libDir = linkerArg.substring(2);
          if (!librarySearchMap.containsKey(libDir)) {
            if (!libDir.equals("/usr/lib")) {
              librarySearchPaths.add(CUtil.toUnixPath(CUtil.getRelativePath(baseDir, new File(libDir))));
            }
            librarySearchMap.put(libDir, libDir);

          }
        } else if (linkerArg.startsWith("-l")) {
          //
          // check if library is in dependencies list
          //
          final String libName = linkerArg.substring(2);
          boolean found = false;
          for (final DependencyDef dependency : dependencies) {
            if (libName.startsWith(dependency.getName())) {
              final File dependencyFile = dependency.getFile();
              if (dependencyFile != null && new File(dependencyFile.getAbsolutePath() + ".xcodeproj").exists()) {
                found = true;
                break;
              }
            }
          }
          if (!found) {
            otherLdFlags.add(linkerArg);
          }
        }
      }

      debugSettings.put("LIBRARY_SEARCH_PATHS", librarySearchPaths);
      debugSettings.put("OTHER_LDFLAGS", otherLdFlags);
      releaseSettings.put("LIBRARY_SEARCH_PATHS", librarySearchPaths);
      releaseSettings.put("OTHER_LDFLAGS", otherLdFlags);
    }
    return configurationList;
  }
290214
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            stack = new OpcodeStack();
            mapBugs = new ArrayList<>();
            setBugs = new ArrayList<>();
            hasMapComparator = false;
            hasSetComparator = false;
            super.visitClassContext(classContext);
            if (!hasMapComparator) {
                for (BugInstance bi : mapBugs) {
                    bugReporter.reportBug(bi);
                }
            }

            if (!hasSetComparator) {
                for (BugInstance bi : setBugs) {
                    bugReporter.reportBug(bi);
                }
            }
        } finally {
            stack = null;
            mapBugs = null;
            setBugs = null;
        }
    }