/*
Given a bundle id, finds the correct remote debugger app that is
connected.
333368
function getDebuggerAppKey (bundleId, platformVersion, appDict) {
  let appId;
  if (parseFloat(platformVersion) >= 8) {
    for (const [key, data] of _.toPairs(appDict)) {
      if (data.bundleId === bundleId) {
        appId = key;
        break;
      }
    }
    // now we need to determine if we should pick a proxy for this instead
    if (appId) {
      log.debug(`Found app id key '${appId}' for bundle '${bundleId}'`);
      let proxiedAppIds = [];
      for (const [key, data] of _.toPairs(appDict)) {
        if (data.isProxy && data.hostId === appId) {
          log.debug(`Found separate bundleId '${data.bundleId}' ` +
                    `acting as proxy for '${bundleId}', with app id '${key}'`);
          proxiedAppIds.push(key);
        }
      }
      if (proxiedAppIds.length) {
        // use the last app being proxied
        appId = _.last(proxiedAppIds);
        log.debug(`Using proxied app id '${appId}'`);
      }
    }
  } else {
    if (_.has(appDict, bundleId)) {
      appId = bundleId;
    }
  }

  return appId;
}
1103899
function (debug) {
  this.debug = debug;
  this.config = {};
  this.apps = {};
  this.routes = {};

  util.handleEvents(this);
  this.on('config', function (config) {
    util.mixin(this.config, config);
  }.bind(this));
}
843716
function visitBundle(file) {
        if (visitedIndexes[file]) {
            return;
        }
        visitedIndexes[file] = true;
        // walk deps
        var bundle = manifest.bundles[manifest.indexes[file]];
        bundle.data.forEach(function(module) {
            Object.keys(module.deps).forEach(function(key) {
                var value = module.deps[key];
                if (visitedIndexes.hasOwnProperty(value)) {
                    visitBundle(value);
                }
            });
        });
    }
1284328
function addCachedScanResults(bundle) {
        debugLFDS('In Add Cached Scan Results');
        
        var defered = q.defer();
        var scannedData = bundle.scannedData;
        var cScannedData;
        if(self.cachedScanBundle) {
            if(self.cachedScanBundle.scannedData) {
                cScannedData = self.cachedScanBundle.scannedData;
            } else {
                cScannedData = {};
            }
        } else {
            cScannedData = {};
        }

        debugLFDS('Cached Connection Types:');
        printScannedDataConnectionTypes(cScannedData);
        debugPrintFlatScannedData(cScannedData, debugLFDS);
        debugMACT('!!! In addCachedScanResults');
        debugPrintFlatScannedData(cScannedData, debugMACT);
        // console.log('Current Devices', self.cachedCurrentDevices);
        // console.log('Current bundle', bundle.scannedData);
        

        var cKeys = Object.keys(cScannedData);
        cKeys.forEach(function(cKey) {
            if(scannedData[cKey]) {
                debugLFDS('We already have the key', cKey);
                // If the key exists we need to transfer data about the device
                // connection types.  The only reason why the key would exist
                // already is if the device is open due to no scans having been
                // performed.  

                // The situation that this branch needs to cover is if a currently
                // connected device is found to have valid Ethernet/WiFi connections.
                // Due to no scan having been performed, the types WILL show up
                // as "added by attribute".  If the cached scan had them showing
                // up as 'scan' then that information should be indicated as such.
                /* 
                 * Need to update the following keys:
                 * numConnectionTypes (int) ex: 1
                 * connectionTypeNames (String Array) ex: ['Ethernet']
                 * unverifiedConnectionTypes (Object array) [object]
                 * unverifiedConnectionTypeNames (String Array) ex: ['Ethernet']
                 * verifiedConnectionTypeNames: [],
                 * connectionTypes (object array) [object]
                 */

                 // On second thought, due to this case being run into due to
                 // the device's handle being open.  Lets ignore it.  The previous
                 // scan data may be invalid and we should only use the latest
                 // scan data.  If a user wants re-freshed data, then they should
                 // perform a new scan.
            } else {
                debugLFDS('We dont have the key', cKey);
                // If the key doesn't exist then copy over the data.
                scannedData[cKey] = cScannedData[cKey];
            }
        });

        bundle.scannedData = scannedData;
        // console.log('New bundle', bundle);
        // console.log('Scanned Data', scannedData);
        if(DEBUG_MARKING_ACTIVE_CONNECTION_TYPES) {
            var sDKeys = Object.keys(scannedData);
            var foundActiveConnection = false;
            var activeConnection = {
                'sn': 0,
                'ct': {},
            };

            sDKeys.forEach(function(key) {
                var dev = scannedData[key];
                dev.connectionTypes.forEach(function(ctInfo) {
                    if(ctInfo.isActive) {
                        foundActiveConnection = true;
                        activeConnection.sn = dev.serialNumber;
                        activeConnection.ct = ctInfo;
                    }
                });
                // console.log('Device:',dev.serialNumber,'CTs',dev.connectionTypes);
            });
            if(foundActiveConnection) {
                debugMACT('!!! We found an active CT', activeConnection);
            } else {
                debugMACT('!!! We did not find an active CT');
            }
        }
        defered.resolve(bundle);
        return defered.promise;
    }
1019230
private ShareTarget findShareTarget(String pkg) {
        for (ShareTarget target : mShareTargets) {
            if (pkg.equals(target.packageName)) {
                return target;
            }
        }
        return null;
    }
154995
function handleChange(bundleName) {
	const bundle = module.exports.find(bundleName);

	/* istanbul ignore if: It's rare for `bundle` to be undefined here, but it can happen when using black/whitelisting. */
	if (!bundle) {
		return;
	}

	if (backoffTimer) {
		log.debug('Backoff active, delaying processing of change detected in', bundleName);
		hasChanged[bundleName] = true;
		resetBackoffTimer();
	} else {
		log.debug('Processing change event for', bundleName);
		resetBackoffTimer();

		let reparsedBundle;
		const bundleCfgPath = path.join(root, '/cfg/', bundleName + '.json');
		if (fs.existsSync(bundleCfgPath)) {
			reparsedBundle = parseBundle(bundle.dir, bundleCfgPath);
		} else {
			reparsedBundle = parseBundle(bundle.dir);
		}

		module.exports.add(reparsedBundle);
		emitter.emit('bundleChanged', reparsedBundle);
	}
}
1098062
def with_debug_id(debug_id):
        """"""
        ctx = SpanContext(
            trace_id=None, span_id=None, parent_id=None, flags=None
        )
        ctx._debug_id = debug_id
        return ctx
158099
def find_experiment_export(app_id):
    

    # Check locally first
    cwd = os.getcwd()
    data_filename = "{}-data.zip".format(app_id)
    path_to_data = os.path.join(cwd, "data", data_filename)
    if os.path.exists(path_to_data):
        try:
            Data(path_to_data)
        except IOError:
            from dallinger import logger

            logger.exception(
                "Error reading local data file {}, checking remote.".format(
                    path_to_data
                )
            )
        else:
            return path_to_data

    # Get remote file instead
    path_to_data = os.path.join(tempfile.mkdtemp(), data_filename)

    buckets = [user_s3_bucket(), dallinger_s3_bucket()]

    for bucket in buckets:
        try:
            bucket.download_file(data_filename, path_to_data)
        except botocore.exceptions.ClientError:
            pass
        else:
            return path_to_data
536762
function() {
      var t = this,
          map = {},
          router = Monitor.getRouter(),
          hostName = Monitor.getRouter().getHostName(),
          appName = Monitor.Config.Monitor.appName,
          appInstance = process.env.NODE_APP_INSTANCE;

      // Add this process to the map
      map[hostName] = {};
      map[hostName][appName] = {
        instances: [appInstance],
        probeClasses: _.keys(Probe.classes)
      };

      // Process all known connections
      var connections = router.findConnections();
      connections.forEach(function(connection) {
        hostName = connection.get('hostName') || connection.get('remoteHostName');
        appName = connection.get('remoteAppName') || '';
        appInstance = connection.get('remoteAppInstance') || '';

        // Don't add to the map not yet connected
        if (connection.connecting || !connection.connected) {
          return;
        }

        // Add the hostname to the map
        var host = map[hostName];
        if (!host) {
          host = map[hostName] = {};
        }

        // Add the app to the map
        var app = host[appName];
        if (!app) {
          app = host[appName] = {
            instances: [appInstance],
            probeClasses: connection.get('remoteProbeClasses')
          };
        } else {
          app.instances.push(appInstance);
        }
      });
      log.info('buildMap', map);

      // Set the map if it's changed.  This method is called whenever
      // connections come and go - including firewalled connections which
      // aren't visible in the map.  Only update if the map has changed.
      if (!_.isEqual(map, t.get('map'))) {
        log.info('mapChanged');
        t.set({
          map: map,
          updateSequence: t.updateSequence++
        });
      } else {
        log.info('mapNotChanged');
      }
    }
943342
function getExternalAppOperations(self) {
	var operationToRegisterNames = {
		'pwd': 'FILE_IO_DIR_CURRENT',
	};

    function createOpenDeviceInExtAppBundle(options) {
        var ctStr;
        var preventCloseAndOpen = false;
        var appName = 'NONE';
        var detached = true;

        // Check "connection type"
        if(options.ct) {
            if(options.ct === 'current') {
                ctStr = self.savedAttributes.connectionType;
            } else {
               ctStr = options.ct; 
            }
        } else {
            ctStr = self.savedAttributes.connectionType;
        }

        // Check "preventCloseAndOpen" flag
        if(typeof(options.preventCloseAndOpen) === 'boolean') {
            preventCloseAndOpen = options.preventCloseAndOpen;
        }

        // Check application name option
        if(options.appName) {
            appName = options.appName;
        }

        if(typeof(options.detached) === 'boolean') {
            detached = options.detached;
        }

        var ct = driver_const.connectionTypes[ctStr];

        var bundle = {
            'appName': appName,
            'appWorkingDir': '',
            'openConfigFilePath': '',
            'appExePath': appExePaths[appName],
            'deviceInfo': {
                'dt': self.savedAttributes.deviceType,
                'ct': ct,
                'id': undefined,
            },
            'curDeviceInfo': {
                'dt': self.savedAttributes.deviceType,
                'ct': self.savedAttributes.connectionType,
                'id': undefined,
            },
            'ctName': driver_const.CONNECTION_TYPE_NAMES[ct],
            'availableConnections': [],
            'closeAndOpenDevice': true,
            'preventCloseAndOpen': preventCloseAndOpen,

            'detached': detached,

            'currentAppOpenCFG': '',
            'appExists': false,
            'registryInfo': {},
            'isError': false,
            'errorStep': '',
            'error': undefined
        };
        return bundle;
    }

    function getAvailableConnectionsAndDetermineSharability(bundle) {
        debugOA('in getAvailableConnectionsAndDetermineSharability');
        var defered = q.defer();
        self.cGetAvailableConnectionTypes()
        .then(function(res) {
            bundle.availableConnections = res.connections;
            defered.resolve(bundle);
        }, function(err) {
            // Not a valid case...
            defered.resolve(bundle);
        });
        return defered.promise;
    }
    function determineConnectionSharability(bundle) {
        
        var defered = q.defer();
        var connections = bundle.availableConnections;
        // If the user is requesting a not-found connection type we don't need to close/open the device.
        // aka default value should be True.

        var desiredCTIsActiveCT = false;

        var isConnectable = true; 
        var deviceID = self.savedAttributes.serialNumber.toString();
        connections.forEach(function(connection) {
            if(connection.type === bundle.ctName) {
                isConnectable = connection.isConnectable;
                deviceID = connection.id;
            }
        });

        // save device identifier string.
        bundle.deviceInfo.id = deviceID;
        
        if(isConnectable) {
            bundle.closeAndOpenDevice = false;
        } else {
            bundle.closeAndOpenDevice = true;
        }

        // Check to see if the desired CT is the same as the current CT to 
        // see if opening and closing the CT is even necessary...
        if(bundle.deviceInfo.ct != bundle.curDeviceInfo.ct) {
            bundle.closeAndOpenDevice = false;
        }

        // If user specified to disable this feature than make sure the active
        // device isn't opened/closed.
        if(bundle.preventCloseAndOpen) {
            bundle.closeAndOpenDevice = false;
        }
        
        defered.resolve(bundle);
        return defered.promise;
    }
    function getApplicationWorkingDirectories(bundle) {
        var defered = q.defer();

        getLJAppsRegistryInfo(ljAppNames, function(err, info) {
            bundle.registryInfo = info;
            var appName = bundle.appName;
            if(info[appName]) {
                bundle.appWorkingDir = info[appName].workdir;
                var cfgFilePath = path.join(bundle.appWorkingDir, appOpenConfigFiles[appName]);
                bundle.openConfigFilePath = cfgFilePath;
            } else {
                bundle.isError = true;
                bundle.errorStep = 'getApplicationWorkingDirectories';
            }
            defered.resolve(bundle);
        });

        return defered.promise;
    }
    function getOpenConfigFileData(bundle) {
        var defered = q.defer();
        
        var filePath = bundle.openConfigFilePath;
        debugOA('in getOpenConfigFileData:', filePath);

        fs.readFile(filePath, function(err, data) {
            if(err) {
                fs.readFile(filePath, function(err, data) {
                    if(err) {
                        fs.readFile(filePath, function(err, data) {
                            if(err) {
                                console.error('Error Reading File', err, filePath);
                                bundle.isError = true;
                                bundle.error = err;
                                bundle.errorStep = 'readOpenConfigFile';
                                defered.resolve(bundle);
                            } else {
                                bundle.currentAppOpenCFG = data.toString();
                                defered.resolve(bundle);
                            }
                        });
                    } else {
                        bundle.currentAppOpenCFG = data.toString();
                        defered.resolve(bundle);
                    }
                });
            } else {
                bundle.currentAppOpenCFG = data.toString();
                defered.resolve(bundle);
            }
        });

        return defered.promise;
    }

    function generateOpenDeviceText (deviceInfo) {
        var str = '[Main]\r\n';
        str += 'DeviceType=' + deviceInfo.dt + '\r\n';
        str += 'ConnectionType=' + deviceInfo.ct + '\r\n';
        str += 'Identifier=' + deviceInfo.id + '\r\n';
        return str;
    }

    function editOpenConfigFile(bundle) {
        var defered = q.defer();
        
        var filePath = bundle.openConfigFilePath;
        var data = generateOpenDeviceText(bundle.deviceInfo);
        debugOA('in editOpenConfigFile:', filePath, data);

        fs.writeFile(filePath, data, function(err) {
			if(err) {
				fs.writeFile(filePath, data, function(err) {
					if(err) {
						fs.writeFile(filePath, data, function(err) {
							if(err) {
								console.error('Error Writing File', err, filePath);
                                bundle.isError = true;
                                bundle.error = err;
                                bundle.errorStep = 'editOpenConfigFile';
								defered.resolve(bundle);
							} else {
								defered.resolve(bundle);
							}
						});
					} else {
						defered.resolve(bundle);
					}
				});
			} else {
				defered.resolve(bundle);
			}
		});

        return defered.promise;
    }
    function restoreOpenConfigFileData(bundle) {
        var defered = q.defer();
        
        var filePath = bundle.openConfigFilePath;
        var data = bundle.currentAppOpenCFG;
        debugOA('in restoreOpenConfigFileData:', filePath, data);

        fs.writeFile(filePath, data, function(err) {
            if(err) {
                fs.writeFile(filePath, data, function(err) {
                    if(err) {
                        fs.writeFile(filePath, data, function(err) {
                            if(err) {
                                console.error('Error Writing File', err, filePath);
                                bundle.isError = true;
                                bundle.error = err;
                                bundle.errorStep = 'restoreOpenConfigFileData';
                                defered.resolve(bundle);
                            } else {
                                defered.resolve(bundle);
                            }
                        });
                    } else {
                        defered.resolve(bundle);
                    }
                });
            } else {
                defered.resolve(bundle);
            }
        });

        return defered.promise;
    }
    function verifyAppexists(bundle) {
        var defered = q.defer();
        var filePath = bundle.appExePath;
        debugOA('in verifyAppexists',filePath);

        fs.access(filePath, fs.constants.F_OK, function(err) {
            if(err) {
                bundle.appExists = false;
                bundle.isError = true;
                bundle.error = 'App does not exist at path: '+filePath;
                bundle.errorStep = 'verifyAppexists';

            } else {
                bundle.appExists = true;
            }
            defered.resolve(bundle);
        });

        return defered.promise;
    }
    function suspendDeviceConnection(bundle) {
        var defered = q.defer();

        debugOA('in suspendDeviceConnection');

        if(bundle.closeAndOpenDevice) {
            self.suspendDeviceConnection()
            .then(function() {
                self.savedAttributes.isShared = true;
                self.savedAttributes.sharedAppName = bundle.appName;
                self.emit(events.DEVICE_RELEASED, {
                    attrs: self.savedAttributes,
                    shared: true,
                    appName: bundle.appName,
                });
                // Also emit new saved attributes event.
                self.updateSavedAttributes()
                .then(function() {
                    defered.resolve(bundle);
                });
            }, function(err) {
                bundle.isError = true;
                bundle.error = err;
                bundle.errorStep = 'suspendDeviceConnection';
                defered.resolve(bundle);
            });
        } else {
            defered.resolve(bundle);
        }
        return defered.promise;
    }

    function openExternalApplication(bundle) {
        var defered = q.defer();
        debugOA('in openExternalApplication', bundle);


        
        // console.log('Exec Path...', bundle.appExePath);
        /*
        // Start program using execFile
        var execFile = require('child_process').execFile;
        var child = execFile(bundle.appExePath, function(error, stdout, stderr) {
            debugOA('Finished executing external application');
            if(error) {
                console.log('ERROR!',error);
            }
            defered.resolve(bundle);
        });
        */
        
        var spawn = require('child_process').spawn;
        var child = spawn(bundle.appExePath, [], {
            detached:bundle.detached,
        });
        child.stdout.on('data', function cpStdout(data) {

        });
        child.stderr.on('data', function cpStdErr(data) {

        });
        child.on('close', function cpClose(code) {
            debugOA('Finished executing external application');
            defered.resolve(bundle);
        });
        child.unref();
        // console.log('App-PID:', child.pid);
        
        return defered.promise;
    }

    function resumeDeviceConnection(bundle) {
        var defered = q.defer();
        debugOA('in resumeDeviceConnection');

        if(bundle.closeAndOpenDevice) {
            self.resumeDeviceConnection()
            .then(function() {
                // console.log('Emitting device acquired event', bundle.appName);
                self.savedAttributes.isShared = false;
                self.savedAttributes.sharedAppName = bundle.appName;
                self.emit(events.DEVICE_ACQUIRED, {
                    attrs: self.savedAttributes,
                    shared: false,
                    appName: bundle.appName,
                });
                // Also emit new saved attributes event.
                self.updateSavedAttributes()
                .then(function() {
                    defered.resolve(bundle);
                });
            }, function(err) {
                bundle.isError = true;
                bundle.error = err;
                bundle.errorStep = 'resumeDeviceConnection';
                defered.resolve(bundle);
            });
        } else {
            defered.resolve(bundle);
        }
        return defered.promise;
    }

    function skipOnError(func) {
        return function checkForError(bundle) {
            if(bundle.isError) {
                var defered = q.defer();
                defered.resolve(bundle);
                return defered.promise;
            } else {
                return func(bundle);
            }
        };
    }
    this.openDeviceInExternalApplicationOptions = function(options) {
        var defered = q.defer();

        var bundle = createOpenDeviceInExtAppBundle(options);

        function onSuccess(successBundle) {
            // debugOA('Success Bundle', successBundle);
            defered.resolve(successBundle);
        }
        function onError(errorBundle) {
            defered.reject(errorBundle);
        }
        getAvailableConnectionsAndDetermineSharability(bundle)
        .then(skipOnError(determineConnectionSharability))
        .then(skipOnError(getApplicationWorkingDirectories))
        .then(skipOnError(getOpenConfigFileData))
        .then(skipOnError(verifyAppexists))
        .then(skipOnError(editOpenConfigFile))
        .then(skipOnError(suspendDeviceConnection))
        .then(skipOnError(openExternalApplication))
        .then(skipOnError(resumeDeviceConnection))
        // .then(skipOnError(restoreOpenConfigFileData))
        .then(onSuccess, onError);

        return defered.promise;
    }
	this.openDeviceInExternalApplication = function(ljmApplicationName,ct, pCO) {
        

        var connectionType = 'current';
        if(ct) {
            if(ct === 'current') {
                connectionType = ct;
            } else {
                try {
                    connectionType = driver_const.connectionTypes[ct];
                } catch(err) {
                    // Do nothing.
                }
            }
        }
        var preventCloseAndOpen = false;
        if(typeof(pCO) === 'boolean') {
            preventCloseAndOpen = pCO;
        }

        var options = {
            'appName': ljmApplicationName,
            'ct': connectionType,
            'preventCloseAndOpen': preventCloseAndOpen,
        };
        return this.openDeviceInExternalApplicationOptions(options);
	};
    this.openDeviceInLJLogM = function(ct, pCO) {
        return self.openDeviceInExternalApplication('LJLogM',ct, pCO);
    }
    this.openDeviceInLJStreamM = function(ct, pCO) {
        return self.openDeviceInExternalApplication('LJStreamM',ct, pCO);
    }
}
1075808
private void verifyIfBundleIsModified(JoinableResourceBundleImpl bundle, List<String> mappings,
			PropertiesConfigHelper props) {

		// Retrieves current available variant
		Map<String, VariantSet> variants = new TreeMap<>();
		for (String mapping : mappings) {
			variants = VariantUtils.concatVariants(variants, generatorRegistry.getAvailableVariants(mapping));
		}

		// Checks if the current variant are the same as the stored one
		if (!variants.equals(bundle.getVariants())) {
			bundle.setVariants(variants);
			bundle.setDirty(true);
		} else {

			String bundleName = bundle.getName();

			List<String> fileMappings = props.getCustomBundlePropertyAsList(bundleName,
					PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_FILEPATH_MAPPINGS);
			if (fileMappings != null) {
				List<FilePathMapping> bundleFileMappings = bundle.getFilePathMappings();
				if (bundleFileMappings.size() != fileMappings.size()) {
					bundle.setDirty(true);
				} else {

					Set<FilePathMapping> storedFilePathMapping = new HashSet<>();
					for (String filePathWithTimeStamp : fileMappings) {
						String[] tmp = filePathWithTimeStamp.split(LAST_MODIFIED_SEPARATOR);
						String filePath = tmp[0];
						long storedLastModified = Long.parseLong(tmp[1]);
						storedFilePathMapping.add(new FilePathMapping(bundle, filePath, storedLastModified));
					}

					Set<FilePathMapping> bundleFilePathMappingSet = new HashSet<>(bundleFileMappings);
					if (!bundleFilePathMappingSet.equals(storedFilePathMapping)) {
						bundle.setDirty(true);
					}
				}
			}

			// Checks if the linked resource has been modified
			fileMappings = props.getCustomBundlePropertyAsList(bundleName,
					PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_LINKED_FILEPATH_MAPPINGS);
			for (String filePathWithTimeStamp : fileMappings) {
				int idx = filePathWithTimeStamp.lastIndexOf(LAST_MODIFIED_SEPARATOR);

				if (idx != -1) {
					String filePath = filePathWithTimeStamp.substring(0, idx);
					long storedLastModified = Long.parseLong(filePathWithTimeStamp.substring(idx + 1));
					long currentLastModified = rsReaderHandler.getLastModified(filePath);
					FilePathMapping fPathMapping = new FilePathMapping(bundle, filePath, currentLastModified);
					bundle.getLinkedFilePathMappings().add(fPathMapping);
					if (storedLastModified != currentLastModified) {
						bundle.setDirty(true);
					}
				}
			}
		}

	}
28747
def bump_ipa(sftp, local, appcode)
      remote = get_remote_ipa_path(local, appcode)
      FastlaneCore::UI.message('Checking remote IPA')
      begin
        sftp.stat!(remote) do |response|
          if response.ok?
            begin
              sftp.rename!(remote, remote + '.bak')
            rescue
              begin
                sftp.remove(remote + '.bak') # may fail if not existent
                FastlaneCore::UI.message('Removed ' + remote + '.bak')
              rescue
                sftp.rename!(remote, remote + '.bak')
                FastlaneCore::UI.message('Bumped to ' + remote + '.bak')
              end
            end
          end
        end
      rescue
        FastlaneCore::UI.message('No previous IPA found.')
      end
    end
1301484
private static Method getNewGetBundleMethod() {

        Class   clazz;
        Class[] args;

        clazz = ResourceBundle.class;
        args  = new Class[] {
            String.class, Locale.class, ClassLoader.class
        };

        try {
            return clazz.getMethod("getBundle", args);
        } catch (Exception e) {
            return null;
        }
    }
1284883
private void showNewDebugger(EnhancedDebugger debugger) {
        if (frame == null) {
            createDebug();
        }
        debugger.tabbedPane.setName("XMPPConnection_" + tabbedPane.getComponentCount());
        tabbedPane.add(debugger.tabbedPane, tabbedPane.getComponentCount() - 1);
        tabbedPane.setIconAt(tabbedPane.indexOfComponent(debugger.tabbedPane), connectionCreatedIcon);
        frame.setTitle(
                "Smack Debug Window -- Total connections: " + (tabbedPane.getComponentCount() - 1));
        // Keep the added debugger for later access
        debuggers.add(debugger);
    }
554471
static Library getSharedLibrary(String id) {

        if (bundleContext == null) {
            return null;
        }

        // Filter the SharedLibrary service references by ID.
        String filter = "(" + "id=" + id + ")";
        Collection<ServiceReference<Library>> refs = null;
        try {
            refs = bundleContext.getServiceReferences(Library.class, filter);
        } catch (InvalidSyntaxException e) {
            if (tc.isErrorEnabled()) {
                Tr.error(tc, "cls.library.id.invalid", id, e.toString());
            }
            return null;
        }

        if (refs.isEmpty())
            return null;

        return bundleContext.getService(getHighestRankedService(refs));
    }
682357
async function bundleProgram (dirPath, destFile) {
  await validateDirPathForCLI(dirPath);
  return collecticonsBundle({
    dirPath,
    destFile
  });
}
1247580
public Bundle findBundle(Object objResource, Object bundleContext, String packageName, String versionRange)
    {
        if (bundleContext == null)
            bundleContext = this.bundleContext;
        if (bundleContext == null)
            return null;
        if (objResource == null)
            return BaseClassFinderService.findBundle((BundleContext)bundleContext, packageName, versionRange);
        Bundle[] bundles = ((BundleContext)bundleContext).getBundles();
        for (Bundle bundle : bundles)
        {
            if (objResource != null)
            {
                if (this.isResourceBundleMatch(objResource, bundle))
                    return bundle;               
            }
        }
        return null;
    }