auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void onEvent(CordovaEvent event) { if (listener != null) { if (event.getEventType().equals(CordovaEvent.CordovaEventType.PAGE_STARTED)) { listener.onPageStarted(); } else if (event.getEventType().equals(CordovaEvent.CordovaEventType.PAGE_FINISHED)) { listener.onPageFinished(event.getParam()); } else if (event.getEventType().equals(CordovaEvent.CordovaEventType.ERROR)) { listener.onPageError(new Exception(event.getParam())); } } }

Target:
public void onEvent(CordovaEvent event) { if (listener != null) { CordovaEvent.CordovaEventType eventType = event.getEventType(); if (CordovaEvent.CordovaEventType.PAGE_STARTED.equals(eventType)) { listener.onPageStarted(); } else if (CordovaEvent.CordovaEventType.PAGE_FINISHED.equals(eventType)) { listener.onPageFinished(event.getParam()); } else if (CordovaEvent.CordovaEventType.ERROR.equals(eventType)) { listener.onPageError(new Exception(event.getParam())); } } }
Source:
private List<ProblemMarkerFilterDesc> findEnabledFilters(IProject project) { List<ProblemMarkerFilterDesc> result = filtersCache.get(project); if (result == null) { result = new ArrayList<ProblemMarkerFilterDesc>(); for (ProblemMarkerFilterDesc filterDesc: filters) { if ( filterDesc.matches(project) ) { result.add(filterDesc); } } filtersCache.put(project, result); } return result; }

Target:
private List<ProblemMarkerFilterDesc> findEnabledFilters(IProject project) { synchronized (filtersCache) { List<ProblemMarkerFilterDesc> result = filtersCache.get(project); if (result == null) { result = new ArrayList<ProblemMarkerFilterDesc>(); for (ProblemMarkerFilterDesc filterDesc: filters) { if ( filterDesc.matches(project) ) { result.add(filterDesc); } } filtersCache.put(project, result); } return result; } }
Source:
public void run(BatchActionContext batchActionContext) throws Exception { conf.substituteMacros(batchActionContext); if (!conf.shouldRun(batchActionContext)) { return; } int retries = 0; Exception exception = null; do { HttpURLConnection conn = null; Map<String, List<String>> headers = conf.parseRequestProperties(); try { URL url = new URL(conf.url); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(conf.method); conn.setConnectTimeout(conf.connectTimeoutMillis); for (Map.Entry<String, List<String>> propertyEntry : headers.entrySet()) { String propertyKey = propertyEntry.getKey(); for (String propertyValue : propertyEntry.getValue()) { conn.addRequestProperty(propertyKey, propertyValue); } } if (conf.body != null) { conn.setDoOutput(true); try (OutputStream outputStream = conn.getOutputStream()) { outputStream.write(conf.body.getBytes(Charsets.UTF_8)); } } LOG.info("Request to resulted in response code {}.", conf.url, conn.getResponseCode()); break; } catch (MalformedURLException | ProtocolException e) { throw new IllegalStateException("Error opening url connection. Reason: " + e.getMessage(), e); } catch (Exception e) { LOG.warn("Error making request to url with headers {}.", conf.method, conf.url, headers); exception = e; } finally { if (conn != null) { conn.disconnect(); } } retries++; } while (retries < conf.numRetries); if (exception != null) { throw exception; } }

Target:
public void run(BatchActionContext batchActionContext) throws Exception { if (!conf.shouldRun(batchActionContext)) { return; } conf.substituteMacros(batchActionContext); int retries = 0; Exception exception = null; do { HttpURLConnection conn = null; Map<String, List<String>> headers = conf.parseRequestProperties(); try { URL url = new URL(conf.url); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(conf.method); conn.setConnectTimeout(conf.connectTimeoutMillis); for (Map.Entry<String, List<String>> propertyEntry : headers.entrySet()) { String propertyKey = propertyEntry.getKey(); for (String propertyValue : propertyEntry.getValue()) { conn.addRequestProperty(propertyKey, propertyValue); } } if (conf.body != null) { conn.setDoOutput(true); try (OutputStream outputStream = conn.getOutputStream()) { outputStream.write(conf.body.getBytes(Charsets.UTF_8)); } } LOG.info("Request to resulted in response code {}.", conf.url, conn.getResponseCode()); break; } catch (MalformedURLException | ProtocolException e) { throw new IllegalStateException("Error opening url connection. Reason: " + e.getMessage(), e); } catch (Exception e) { LOG.warn("Error making request to url with headers {}.", conf.method, conf.url, headers); exception = e; } finally { if (conn != null) { conn.disconnect(); } } retries++; } while (retries < conf.numRetries); if (exception != null) { throw exception; } }
Source:
public void eventFilterApplied(TmfFilterAppliedSignal signal) { if (signal.getSource() == this) { return; } Display.getDefault().syncExec(() -> { ITmfFilter eventFilter = signal.getFilter().getEventFilter(); if (eventFilter == null) { fTable.setData(Key.SEARCH_OBJ, null); fTable.refresh(); } else { fTable.setData(Key.SEARCH_OBJ, eventFilter); fTable.refresh(); searchNext(); } }); }

Target:
public void eventFilterApplied(TmfFilterAppliedSignal signal) { if (signal.getSource() == this) { return; } Runnable runnable = () -> { ITmfFilter eventFilter = signal.getFilter().getEventFilter(); if (eventFilter == null) { fTable.setData(Key.SEARCH_OBJ, null); fTable.refresh(); } else { fTable.setData(Key.SEARCH_OBJ, eventFilter); fTable.refresh(); searchNext(); } }; Display display = PlatformUI.getWorkbench().getDisplay(); if (display == Display.getCurrent()) { runnable.run(); } else { Display.getDefault().asyncExec(runnable); } }
Source:
private void handleSchedWakeup(ITmfEvent event) { String host = event.getTrace().getHostId(); Integer cpu = NonNullUtils.checkNotNull(TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(), TmfCpuAspect.class, event)); IKernelAnalysisEventLayout eventLayout = getProvider().getEventLayout(event.getTrace()); LttngSystemModel system = getProvider().getSystem(); Integer tid = EventField.getInt(event, eventLayout.fieldTid()); HostThread targetHt = new HostThread(host, tid); LttngWorker target = system.findWorker(targetHt); LttngWorker current = system.getWorkerOnCpu(host, cpu); System.out.println("wakeup tid=" + tid); if (target == null) { String name = EventField.getOrDefault(event, eventLayout.fieldComm(), NonNullUtils.checkNotNull(Messages.TraceEventHandlerSched_UnknownThreadName)); target = new LttngWorker(targetHt, name, event.getTimestamp().getValue()); system.addWorker(target); target.setStatus(ProcessStatus.WAIT_BLOCKED); } ProcessStatus status = target.getStatus(); if ((current != null && target.getHostThread().equals(current.getHostThread())) || status == ProcessStatus.WAIT_CPU) { return; } if (status == ProcessStatus.WAIT_BLOCKED || status == ProcessStatus.WAIT_FORK || status == ProcessStatus.UNKNOWN) { target.setStatus(ProcessStatus.WAIT_CPU); return; } }

Target:
private void handleSchedWakeup(ITmfEvent event) { String host = event.getTrace().getHostId(); Integer cpu = NonNullUtils.checkNotNull(TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(), TmfCpuAspect.class, event)); IKernelAnalysisEventLayout eventLayout = getProvider().getEventLayout(event.getTrace()); LttngSystemModel system = getProvider().getSystem(); Integer tid = EventField.getInt(event, eventLayout.fieldTid()); HostThread targetHt = new HostThread(host, tid); LttngWorker target = system.findWorker(targetHt); LttngWorker current = system.getWorkerOnCpu(host, cpu); if (target == null) { String name = EventField.getOrDefault(event, eventLayout.fieldComm(), NonNullUtils.checkNotNull(Messages.TraceEventHandlerSched_UnknownThreadName)); target = new LttngWorker(targetHt, name, event.getTimestamp().getValue()); system.addWorker(target); target.setStatus(ProcessStatus.WAIT_BLOCKED); } ProcessStatus status = target.getStatus(); if ((current != null && target.getHostThread().equals(current.getHostThread())) || status == ProcessStatus.WAIT_CPU) { return; } if (status == ProcessStatus.WAIT_BLOCKED || status == ProcessStatus.WAIT_FORK || status == ProcessStatus.UNKNOWN) { target.setStatus(ProcessStatus.WAIT_CPU); return; } }
Source:
public void readComments(HttpServletRequest request, HttpServletResponse response, @PathVariable("doi") String doi) throws IOException { ArticleIdentifier id = ArticleIdentifier.create(DoiEscaping.resolve(doi)); commentCrudService.readComments(id).respond(request, response, entityGson); }

Target:
public void readComments(HttpServletRequest request, HttpServletResponse response, @PathVariable("doi") String doi) throws IOException { ArticleIdentifier id = ArticleIdentifier.create(DoiEscaping.unescape(doi)); commentCrudService.readComments(id).respond(request, response, entityGson); }
Source:
protected void populateEntities(List<GuestId> entities, List<String> guestIds) { if (entities == null) { throw new IllegalArgumentException("the guestId model entity is null"); } if (guestIds == null) { throw new IllegalArgumentException("the list of guestId is null"); } for (String guestId : guestIds) { if (guestId == null) { continue; } GuestIdDTO guestIdDTO = new GuestIdDTO().guestId(guestId); GuestId guestIdEntity = new GuestId(); populateEntity(guestIdEntity, guestIdDTO); entities.add(guestIdEntity); } }

Target:
protected void populateEntities(List<GuestId> entities, List<String> guestIds) { if (entities == null) { throw new IllegalArgumentException("the guestId model entity is null"); } if (guestIds == null) { throw new IllegalArgumentException("the list of guestId is null"); } for (String guestId : guestIds) { if (guestId == null) { continue; } entities.add(new GuestId(guestId)); } }
Source:
public CacheConfig putCacheConfigIfAbsent(CacheConfig config) { CacheConfig cacheConfig = asCacheConfig(config); CacheConfigFuture future = new CacheConfigFuture(nodeEngine, cacheConfig); CacheConfigFuture localConfigFuture = configs.putIfAbsent(cacheConfig.getNameWithPrefix(), future); CacheConfig localConfig = localConfigFuture == null ? null : localConfigFuture.join(); if (localConfigFuture == null) { try { if (cacheConfig.isStatisticsEnabled()) { setStatisticsEnabled(cacheConfig, cacheConfig.getNameWithPrefix(), true); } if (cacheConfig.isManagementEnabled()) { setManagementEnabled(cacheConfig, cacheConfig.getNameWithPrefix(), true); } logger.info("Added cache config: " + cacheConfig); additionalCacheConfigSetup(null, config); } finally { future.complete(); } } else { additionalCacheConfigSetup(localConfig, config); } return localConfig; }

Target:
public CacheConfig putCacheConfigIfAbsent(CacheConfig config) { CacheConfig cacheConfig = asCacheConfig(config); CacheConfigFuture future = new CacheConfigFuture(nodeEngine, cacheConfig); CacheConfigFuture localConfigFuture = configs.putIfAbsent(cacheConfig.getNameWithPrefix(), future); CacheConfig localConfig = localConfigFuture == null ? null : localConfigFuture.join(); if (localConfigFuture == null) { try { if (cacheConfig.isStatisticsEnabled()) { setStatisticsEnabled(cacheConfig, cacheConfig.getNameWithPrefix(), true); } if (cacheConfig.isManagementEnabled()) { setManagementEnabled(cacheConfig, cacheConfig.getNameWithPrefix(), true); } logger.info("Added cache config: " + cacheConfig); additionalCacheConfigSetup(config, false); future.complete(); } catch (Throwable e) { configs.remove(cacheConfig.getNameWithPrefix(), future); future.complete(e); throw rethrow(e); } } else { additionalCacheConfigSetup(localConfig, true); } return localConfig; }
Source:
private static Stream<Class<?>> getClasses(String packageName) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); assert classLoader != null; String path = packageName.replace('.', '/'); Enumeration<URL> resources; try { resources = classLoader.getResources(path); } catch (IOException e) { return Stream.empty(); } List<File> dirs = new ArrayList<>(); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); dirs.add(new File(resource.getFile())); } List<Class<?>> classes = new ArrayList<>(); for (File directory : dirs) { addClasses(classes, directory, packageName); } return classes.stream(); }

Target:
private static Stream<Class<?>> getClasses(String packageName) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); assert classLoader != null; Enumeration<URL> resources; try { String path = packageName.replace('.', '/'); resources = classLoader.getResources(path); } catch (IOException e) { return Stream.empty(); } final List<Class<?>> result = new ArrayList<>(); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); try { Files.walkFileTree(new File(resource.getFile()).toPath(), EnumSet.noneOf(FileVisitOption.class), 1, getClassFileVisitor(packageName, result)); } catch (IOException e) { e.printStackTrace(); } } return result.stream(); }
Source:
protected Map<String, Object> createDefaultContext(Object root, ClassResolver classResolver) { ClassResolver resolver = classResolver; if (resolver == null) { resolver = container.getInstance(CompoundRootAccessor.class); } SecurityMemberAccess memberAccess = new SecurityMemberAccess(allowStaticMethodAccess, allowStaticFieldAccess); if (devMode) { LOG.warn("Working in devMode, ignoring internal security"); } else { memberAccess.setExcludedClasses(excludedClasses); memberAccess.setExcludedPackageNamePatterns(excludedPackageNamePatterns); memberAccess.setExcludedPackageNames(excludedPackageNames); memberAccess.setDisallowProxyMemberAccess(disallowProxyMemberAccess); } return Ognl.createDefaultContext(root, memberAccess, resolver, defaultConverter); }

Target:
protected Map<String, Object> createDefaultContext(Object root, ClassResolver classResolver) { ClassResolver resolver = classResolver; if (resolver == null) { resolver = container.getInstance(CompoundRootAccessor.class); } SecurityMemberAccess memberAccess = new SecurityMemberAccess(allowStaticMethodAccess, allowStaticFieldAccess); memberAccess.setDisallowProxyMemberAccess(disallowProxyMemberAccess); if (devMode) { LOG.warn("Working in devMode, using devMode excluded classes and packages!"); memberAccess.setExcludedClasses(devModeExcludedClasses); memberAccess.setExcludedPackageNamePatterns(devModeExcludedPackageNamePatterns); memberAccess.setExcludedPackageNames(devModeExcludedPackageNames); } else { memberAccess.setExcludedClasses(excludedClasses); memberAccess.setExcludedPackageNamePatterns(excludedPackageNamePatterns); memberAccess.setExcludedPackageNames(excludedPackageNames); } return Ognl.createDefaultContext(root, memberAccess, resolver, defaultConverter); }
Source:
public static ByteRange getByteRangeFromKey(MutableObject<String> keyHolder) { String key = keyHolder.getValue(); int j = key.lastIndexOf(BYTE_RANGE_SEP); int i = key.lastIndexOf(BYTE_RANGE_SEP, j - 1); if (j > 0) { try { long start = Long.parseLong(key.substring(i + 1, j)); long end = Long.parseLong(key.substring(j + 1)); keyHolder.setValue(key.substring(0, i)); return ByteRange.inclusive(start, end); } catch (NumberFormatException e) { log.debug(e, e); } } return null; }

Target:
public static ByteRange getByteRangeFromKey(MutableObject<String> keyHolder) { String key = keyHolder.getValue(); int j = key.lastIndexOf(BYTE_RANGE_SEP); int i = key.lastIndexOf(BYTE_RANGE_SEP, j - 1); if (j > 0) { try { long start = Long.parseLong(key.substring(i + 1, j)); long end = Long.parseLong(key.substring(j + 1)); keyHolder.setValue(key.substring(0, i)); return ByteRange.inclusive(start, end); } catch (NumberFormatException e) { log.debug("Cannot parse byte range in key: {}", key, e); } } return null; }
Source:
protected void buildVmWatchdog() { List<VmDevice> watchdogs = DbFacade.getInstance() .getVmDeviceDao() .getVmDeviceByVmIdAndType(vm.getId(), VmDeviceType.WATCHDOG.getName()); for(VmDevice watchdog : watchdogs) { HashMap struct = new HashMap(); struct.put(VdsProperties.Type, watchdog.getType()); struct.put(VdsProperties.Device, watchdog.getDevice()); Map<String, Object> specParams = watchdog.getSpecParams(); if (specParams == null) { specParams = new HashMap<String, Object>(); } struct.put(VdsProperties.SpecParams, specParams); addDevice(struct, watchdog, null); } }

Target:
protected void buildVmWatchdog() { List<VmDevice> watchdogs = DbFacade.getInstance() .getVmDeviceDao() .getVmDeviceByVmIdAndType(vm.getId(), VmDeviceType.WATCHDOG.getName()); for(VmDevice watchdog : watchdogs) { HashMap watchdogFromRpc = new HashMap(); watchdogFromRpc.put(VdsProperties.Type, watchdog.getType()); watchdogFromRpc.put(VdsProperties.Device, watchdog.getDevice()); Map<String, Object> specParams = watchdog.getSpecParams(); if (specParams == null) { specParams = new HashMap<String, Object>(); } watchdogFromRpc.put(VdsProperties.SpecParams, specParams); addDevice(watchdogFromRpc, watchdog, null); } }
Source:
public <T> T build(Class<T> serviceClass, String userAgent, List<String> uris) { Preconditions.checkArgument(!uris.isEmpty()); List<String> sanitizedUris = addTrailingSlashes(uris); okhttp3.OkHttpClient client = createOkHttpClient(userAgent, sanitizedUris); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(sanitizedUris.get(0)) .addConverterFactory(new CborConverterFactory( JacksonConverterFactory.create(OBJECT_MAPPER), ObjectMappers.newCborClientObjectMapper())) .addConverterFactory(OptionalObjectToStringConverterFactory.INSTANCE) .build(); return retrofit.create(serviceClass); }

Target:
public <T> T build(Class<T> serviceClass, String userAgent, List<String> uris) { Preconditions.checkArgument(!uris.isEmpty()); List<String> sanitizedUris = addTrailingSlashes(uris); okhttp3.OkHttpClient client = createOkHttpClient(userAgent, sanitizedUris); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(sanitizedUris.get(0)) .addConverterFactory(new CborConverterFactory( JacksonConverterFactory.create(OBJECT_MAPPER), CBOR_OBJECT_MAPPER)) .addConverterFactory(OptionalObjectToStringConverterFactory.INSTANCE) .build(); return retrofit.create(serviceClass); }
Source:
private String getDownloadedFileContent(String testFileName) throws IOException { try { return downloadedFileUtil.getDownloadedFileContent( seleniumWebDriver.getSessionId(), testFileName); } catch (IOException e) { WaitUtils.sleepQuietly(2); return downloadedFileUtil.getDownloadedFileContent( seleniumWebDriver.getSessionId(), testFileName); } }

Target:
private String getDownloadedFileContent(String testFileName) throws IOException { IOException lastException = null; for (int i = 0; i < MAX_ATTEMPTS; i++) { try { return downloadedFileUtil.getDownloadedFileContent( seleniumWebDriver.getSessionId(), testFileName); } catch (IOException e) { lastException = e; sleepQuietly(TestTimeoutsConstants.MINIMUM_SEC); } } throw lastException; }
Source:
public void run() { char[] charBuffer = new char[BUF_SIZE]; try { while (true) { int readCount = mReader.read(charBuffer, 0, charBuffer.length); if (readCount < 0) { break; } String newRead = new String(charBuffer, 0, readCount); int newLineLen = 0; if (newRead.endsWith("\r\n")) { newLineLen = 2; } else if (newRead.endsWith("\n")) { newLineLen = 1; } String newReadPrint = newRead.substring(0, newRead.length() - newLineLen); if (mOutputType == TYPE_STDOUT) { CLog.i(newReadPrint); } else if (mOutputType == TYPE_STDERR) { CLog.e(newReadPrint); } mBuffer.append(newRead); } } catch (IOException e) { CLog.e("%s: %s", getName(), e.toString()); } }

Target:
public void run() { char[] charBuffer = new char[BUF_SIZE]; try { while (true) { int readCount = mReader.read(charBuffer, 0, charBuffer.length); if (readCount < 0) { break; } String newRead = new String(charBuffer, 0, readCount); int newLineLen = 0; if (newRead.endsWith("\r\n")) { newLineLen = 2; } else if (newRead.endsWith("\n")) { newLineLen = 1; } String newReadPrint = newRead.substring(0, newRead.length() - newLineLen); switch (mLogType) { case STDOUT: CLog.i(newReadPrint); break; case STDERR: CLog.e(newReadPrint); break; } mBuffer.append(newRead); } } catch (IOException e) { CLog.e("%s: %s", getName(), e.toString()); } }
Source:
private List<String> getSchemaNames(ConnectorSession session, Optional<String> schemaName) { if (!schemaName.isPresent()) { return listSchemaNames(session); } else if (schemaNameToScaleFactor(schemaName.get()) > 0) { return ImmutableList.of(schemaName.get()); } return ImmutableList.of(); }

Target:
private List<String> getSchemaNames(ConnectorSession session, Optional<String> schemaName) { if (!schemaName.isPresent()) { return listSchemaNames(session); } if (schemaNameToScaleFactor(schemaName.get()) > 0) { return ImmutableList.of(schemaName.get()); } return ImmutableList.of(); }
Source:
private StringBuilder validateParameters() { final StringBuilder err = new StringBuilder(); if (createProjectArgs.getProjectName() == null || createProjectArgs.getProjectName().isEmpty()) { err.append("fatal: Argument NAME is required"); } if (createProjectArgs.getProjectName().contains(" ")) { err.append("project name should not contain whitespaces"); } if (createProjectArgs.getProjectName().endsWith(Constants.DOT_GIT_EXT)) { createProjectArgs.setProjectName(createProjectArgs.getProjectName() .substring( 0, createProjectArgs.getProjectName().length() - Constants.DOT_GIT_EXT.length())); } if (createProjectArgs.getNewParent() != null && !createProjectArgs.getNewParent().getProject().getName().isEmpty()) { final ProjectState state = projectCache.get(new Project.NameKey(createProjectArgs.getNewParent() .getProject().getName())); if (state == null) { err.append("fatal: '" + createProjectArgs.getNewParent() + "': not a Gerrit project"); return err; } } if (!currentUser.getCapabilities().canCreateProject()) { err.append("fatal: Not permitted to create " + createProjectArgs.getProjectName()); return err; } if (createProjectArgs.getOwnerIds() != null && !createProjectArgs.getOwnerIds().isEmpty()) { createProjectArgs.setOwnerIds(new ArrayList<AccountGroup.UUID>( new HashSet<AccountGroup.UUID>(createProjectArgs.getOwnerIds())));; } else { createProjectArgs.setOwnerIds(new ArrayList<AccountGroup.UUID>( projectOwnerGroups)); } while (createProjectArgs.getBranch().startsWith("/")) { createProjectArgs.setBranch(createProjectArgs.getBranch().substring(1)); } if (!createProjectArgs.getBranch().startsWith(Constants.R_HEADS)) { createProjectArgs.setBranch(Constants.R_HEADS + createProjectArgs.getBranch()); } if (!Repository.isValidRefName(createProjectArgs.getBranch())) { err.append("branch \"" + createProjectArgs.getBranch() + "\" is not a valid name"); } return err; }

Target:
private void validateParameters() throws ProjectCreationFailedException { if (createProjectArgs.getProjectName() == null || createProjectArgs.getProjectName().isEmpty()) { throw new ProjectCreationFailedException( "fatal: project name is required"); } if (createProjectArgs.getProjectName().endsWith(Constants.DOT_GIT_EXT)) { createProjectArgs.setProjectName(createProjectArgs.getProjectName() .substring( 0, createProjectArgs.getProjectName().length() - Constants.DOT_GIT_EXT.length())); } if (!currentUser.getCapabilities().canCreateProject()) { throw new ProjectCreationFailedException(String.format( "%s does not have \"Create Project\" capability.", currentUser.getUserName())); } if (createProjectArgs.ownerIds == null && createProjectArgs.ownerIds.isEmpty()) { createProjectArgs.ownerIds = new ArrayList<AccountGroup.UUID>(projectOwnerGroups); } while (createProjectArgs.branch.startsWith("/")) { createProjectArgs.branch = createProjectArgs.branch.substring(1); } if (!createProjectArgs.branch.startsWith(Constants.R_HEADS)) { createProjectArgs.branch = Constants.R_HEADS + createProjectArgs.branch; } if (!Repository.isValidRefName(createProjectArgs.branch)) { throw new ProjectCreationFailedException(String.format( "Branch \"%s\" is not a valid name.", createProjectArgs.branch)); } }
Source:
private IncrementalProjectBuilder getBuilder(IBuildConfiguration buildConfiguration, ICommand command, int buildSpecIndex, MultiStatus status) throws CoreException { BuildCommand buildCommand = (BuildCommand) command; InternalBuilder result = buildCommand.getBuilder(buildConfiguration); String builderName = command.getBuilderName(); IProject project = buildConfiguration.getProject(); if (result == null) { BuilderPersistentInfo info = null; synchronized (builderInitializationLock) { BuilderPersistentInfo builderInitInProgress = getBuilderInitInfo(project, builderName); if (builderInitInProgress != null) { info = builderInitInProgress; } else { info = removePersistentBuilderInfo(builderName, buildConfiguration, buildSpecIndex); setBuilderInitInfo(project, builderName, info); } } result = buildCommand.getBuilder(buildConfiguration); if (result == null) { result = initializeBuilder(command, builderName, buildConfiguration, info, status); } synchronized (builderInitializationLock) { InternalBuilder other = buildCommand.getBuilder(buildConfiguration); if (other == null) { buildCommand.addBuilder(buildConfiguration, (IncrementalProjectBuilder) result); } else { result = other; } setBuilderInitInfo(project, builderName, null); } } if (result == null) { return null; } result.setBuildConfig(buildConfiguration); if (!validateNature(result, builderName)) { result.setLastBuiltTree(null); return null; } return (IncrementalProjectBuilder) result; }

Target:
private IncrementalProjectBuilder getBuilder(IBuildConfiguration buildConfiguration, ICommand command, int buildSpecIndex, MultiStatus status) throws CoreException { BuildCommand buildCommand = (BuildCommand) command; InternalBuilder result = buildCommand.getBuilder(buildConfiguration); String builderName = command.getBuilderName(); IProject project = buildConfiguration.getProject(); if (result == null) { BuilderPersistentInfo info; synchronized (builderInitializationLock) { BuilderPersistentInfo builderInitInProgress = getBuilderInitInfo(project, builderName); if (builderInitInProgress != null) { info = builderInitInProgress; } else { info = removePersistentBuilderInfo(builderName, buildConfiguration, buildSpecIndex); setBuilderInitInfo(project, builderName, info); } } result = buildCommand.getBuilder(buildConfiguration); if (result == null) { result = initializeBuilder(command, builderName, buildConfiguration, info, status); } synchronized (builderInitializationLock) { InternalBuilder other = buildCommand.getBuilder(buildConfiguration); if (other == null) { buildCommand.addBuilder(buildConfiguration, (IncrementalProjectBuilder) result); } else { result = other; } setBuilderInitInfo(project, builderName, null); } } result.setBuildConfig(buildConfiguration); if (!validateNature(result, builderName)) { result.setLastBuiltTree(null); return null; } return (IncrementalProjectBuilder) result; }
Source:
public Token login(String username, String password, HttpServletRequest request) throws AuthException { String project = request.getHeader(HEADER_X_AUTH_PROJECT); if (StringUtils.isEmpty(project)) { project = this.config.tenantName(); if (StringUtils.isEmpty(project)) { throw new InvalidCredentialsException("Project missing"); } } KeystoneAuthCredentials credentials; try { credentials = new KeystoneAuthCredentials( username, password, project); } catch (Exception ex) { log.debug("Failed to get credentials: "+ex.getMessage()); throw new InvalidCredentialsException("Invalid credentials for user: "+username); } KeystoneAccess access = client.createToken(credentials); return getToken(access); }

Target:
public Token login(String username, String password, HttpServletRequest request) throws AuthException { String project = request.getHeader(HEADER_X_AUTH_PROJECT); if (StringUtils.isEmpty(project)) { project = this.config.tenantName(); if (StringUtils.isEmpty(project)) { throw new InvalidCredentialsException("Project missing"); } } KeystoneAuthCredentials credentials = new KeystoneAuthCredentials( username, password, project); KeystoneAccess access = null; try { access = client.createToken(credentials); } catch (KeystoneConnectionException kex) { log.debug("Authentication connection failed: "+kex.getMessage()); } catch (KeystoneServerException ex) { log.debug("Failed to get credentials: "+ex.getMessage()); throw new InvalidCredentialsException("Invalid credentials for user: "+username); } return getToken(access); }
Source:
public JSONObject toJSON() { JSONObject ret = new JSONObject(); String formattedDate = null; if (xmlDate == null || xmlDate.isEmpty()) { try { final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.US); formattedDate = sdf.format(date); } catch (Exception e){ } } JSONHelper.putValue(ret, "date", formattedDate != null ? formattedDate : xmlDate); JSONHelper.putValue(ret, "dateType", dateType != null ? dateType : ""); return ret; }

Target:
public JSONObject toJSON() { JSONObject ret = new JSONObject(); String formattedDate = null; if (xmlDate == null || xmlDate.isEmpty()) { try { formattedDate = date.format(DATE_FORMATTER); } catch (Exception e){ } } JSONHelper.putValue(ret, "date", formattedDate != null ? formattedDate : xmlDate); JSONHelper.putValue(ret, "dateType", dateType != null ? dateType : ""); return ret; }
Source:
private void parseMemoryOffHeap(XMLExtendedStreamReader reader, ModelNode cache, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress offHeapAddress = PathAddress.pathAddress(cache.get(OP_ADDR)).append(MemoryOffHeapConfigurationResource.PATH); ModelNode offHeap = Util.createAddOperation(offHeapAddress); for (int i = 0; i < reader.getAttributeCount(); i++) { String value = reader.getAttributeValue(i); Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case EVICTION: { MemoryOffHeapConfigurationResource.EVICTION.parseAndSetParameter(value, offHeap, reader); break; } case SIZE: { MemoryOffHeapConfigurationResource.SIZE.parseAndSetParameter(value, offHeap, reader); break; } case STRATEGY: { MemoryOffHeapConfigurationResource.STRATEGY.parseAndSetParameter(value, offHeap, reader); break; } case ADDRESS_COUNT: { if (namespace.since(11, 0)) { throw ParseUtils.unexpectedElement(reader); } break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); operations.put(offHeapAddress, offHeap); }

Target:
private void parseMemoryOffHeap(XMLExtendedStreamReader reader, ModelNode cache, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress offHeapAddress = PathAddress.pathAddress(cache.get(OP_ADDR)).append(MemoryOffHeapConfigurationResource.PATH); ModelNode offHeap = Util.createAddOperation(offHeapAddress); for (int i = 0; i < reader.getAttributeCount(); i++) { String value = reader.getAttributeValue(i); Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case EVICTION: { MemoryOffHeapConfigurationResource.EVICTION.parseAndSetParameter(value, offHeap, reader); break; } case SIZE: { MemoryOffHeapConfigurationResource.SIZE.parseAndSetParameter(value, offHeap, reader); break; } case STRATEGY: { MemoryOffHeapConfigurationResource.STRATEGY.parseAndSetParameter(value, offHeap, reader); break; } case ADDRESS_COUNT: { if (namespace.since(11, 0)) { throw ParseUtils.unexpectedElement(reader); } ROOT_LOGGER.deprecatedAttribute(attribute.getLocalName()); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); operations.put(offHeapAddress, offHeap); }
Source:
private long getDiskUsage(File dir) throws IOException { final MutableLong size = new MutableLong(); Files.walkFileTree(dir.toPath(), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { if (attrs.isRegularFile()) { size.add(attrs.size()); } return FileVisitResult.CONTINUE; } }); return size.longValue(); }

Target:
private static long getDiskUsage(File dir) throws IOException { final MutableLong size = new MutableLong(); Files.walkFileTree(dir.toPath(), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { if (attrs.isRegularFile()) { size.add(attrs.size()); } return FileVisitResult.CONTINUE; } }); return size.longValue(); }
Source:
public void findByJugmentId_CommonCourtJudgment() { int judgmentId = 123; List<JudgmentCorrection> unsortedJc = Lists.newArrayList(); unsortedJc.add(createJcJudgeDelete(ccJudgment)); unsortedJc.add(createJcCommonCourtJudgment()); List<JudgmentCorrection> expectedJc = Lists.newArrayList(); expectedJc.add(createJcCommonCourtJudgment()); expectedJc.add(createJcJudgeDelete(ccJudgment)); when(judgmentCorrectionRepository.findAllByJudgmentId(judgmentId)).thenReturn(unsortedJc); judgmentCorrectionService.setJudgmentCorrectionRepository(judgmentCorrectionRepository); List<JudgmentCorrection> actualJc = judgmentCorrectionService.findByJugmentId(judgmentId); assertEquals(expectedJc, actualJc); }

Target:
public void findByJugmentId_CommonCourtJudgment() { int judgmentId = 123; List<JudgmentCorrection> unsortedJc = Lists.newArrayList(); unsortedJc.add(createJcJudgeDelete(ccJudgment)); unsortedJc.add(createJcCommonCourtJudgment()); unsortedJc.add(createJcJudgeUpdate(ccJudgment)); List<JudgmentCorrection> expectedJc = Lists.newArrayList(); expectedJc.add(createJcCommonCourtJudgment()); expectedJc.add(createJcJudgeUpdate(ccJudgment)); expectedJc.add(createJcJudgeDelete(ccJudgment)); when(judgmentCorrectionRepository.findAllByJudgmentId(judgmentId)).thenReturn(unsortedJc); List<JudgmentCorrection> actualJc = judgmentCorrectionService.findAllByJudgmentIdSorted(judgmentId); assertEquals(expectedJc, actualJc); }
Source:
private void addGlusterWebhook(VDS vds) { try { backend.runInternalAction(ActionType.AddGlusterWebhookInternal, new VdsActionParameters(vds.getId())); } catch (EngineException e) { log.error("Could not add gluster webhook for gluster host '{}'", vds.getName()); } catch (Exception e) { log.error("Could not add gluster webhook for gluster host '{}'", vds.getName()); } }

Target:
private void addGlusterWebhook(VDS vds) { try { backend.runInternalAction(ActionType.AddGlusterWebhookInternal, new VdsActionParameters(vds.getId())); } catch (RuntimeException e) { log.error("Could not add gluster webhook for gluster host '{}'", vds.getName()); log.debug("Exception", e); } }
Source:
public int getExecutionIndex() { return super.getExecutionIndex() + 1; }

Target:
public int getExecutionIndex() { return 53; }
Source:
public static SqlExpression create(String name, String op, Nesting value) { op = Strings.trim(op.toUpperCase()); if (value == null) { throw Lang.makeThrow("nesting sql can not be null'"); } else if ("LIKE".equals(op) || "NOT LIKE".equals(op)) { return like(name, value).setNot(op.startsWith("NOT")); } else if ("=".equals(op)) { return eq(name, value); } else if ("!=".equals(op) || "<>".equals(op)) { return notEq(name, value); } else if ("IN".equals(op) || "NOT IN".equals(op)) { return inSql(name, value).setNot(op.startsWith("NOT")); } else if ("EXISTS".equals(op) || "NOT EXISTS".equals(op)) { return exusts(value).setNot(op.startsWith("NOT")); } return otherSymbol(name, op, value); }

Target:
public static SqlExpression create(String name, String op, Nesting value) { op = Strings.trim(op.toUpperCase()); if (value == null) { throw Lang.makeThrow("nesting sql can not be null'"); } else if ("LIKE".equals(op) || "NOT LIKE".equals(op)) { return like(name, value).setNot(op.startsWith("NOT")); } else if ("=".equals(op)) { return eq(name, value); } else if ("!=".equals(op) || "<>".equals(op)) { return notEq(name, value); } else if ("IN".equals(op) || "NOT IN".equals(op)) { return inSql(name, value).setNot(op.startsWith("NOT")); } else if ("EXISTS".equals(op) || "NOT EXISTS".equals(op)) { return exists(value).setNot(op.startsWith("NOT")); } return otherSymbol(name, op, value); }
Source:
protected void commandProcessing() { boolean longPollingActivated = false; while (connectedFlag.get()) { try { final List<CommandAndHandler> toProcess = commandBatcher.getWaitingBatches().getVal(); List<Command> commands = new ArrayList<>(); for (CommandAndHandler c : toProcess) { commands.add(c.getCommand()); } if (LOG.isDebugEnabled()) { StringBuffer buffer = new StringBuffer(); for (Command command : commands) { buffer.append(command.getClass().getSimpleName()); buffer.append(", "); } LOG.trace("Sending commands to server: {}", commands.size(), buffer.substring(0, buffer.length() - 2)); } else { LOG.trace("Sending commands to server", commands.size()); } final List<? extends Command> answers = transmit(commands); uiExecutor.execute(new Runnable() { @Override public void run() { processResults(answers, toProcess); } }); } catch (Exception e) { if (connectedFlag.get()) { handleError(e); } else { LOG.debug("Remoting error based on broken connection in parallel request", e); } } if(!longPollingActivated && useLongPolling.get()) { uiExecutor.execute(new Runnable() { @Override public void run() { listen(); } }); longPollingActivated = true; } } }

Target:
protected void commandProcessing() { boolean longPollingActivated = false; while (connectedFlag.get()) { try { final List<CommandAndHandler> toProcess = commandBatcher.getWaitingBatches().getVal(); List<Command> commands = new ArrayList<>(); for (CommandAndHandler c : toProcess) { commands.add(c.getCommand()); } if (LOG.isDebugEnabled()) { StringBuffer buffer = new StringBuffer(); for (Command command : commands) { buffer.append(command.getClass().getSimpleName()); buffer.append(", "); } LOG.trace("Sending commands to server: {}", commands.size(), buffer.substring(0, buffer.length() - 2)); } else { LOG.trace("Sending commands to server", commands.size()); } final List<? extends Command> answers = transmit(commands); uiExecutor.execute(new Runnable() { @Override public void run() { processResults(answers, toProcess); } }); } catch (Exception e) { if (connectedFlag.get()) { handleError(e); } else { LOG.warn("Remoting error based on broken connection in parallel request", e); } } if(!longPollingActivated && useLongPolling.get()) { uiExecutor.execute(new Runnable() { @Override public void run() { listen(); } }); longPollingActivated = true; } } }
Source:
public static String buildSearchUrl(String url) { return UriBuilder.fromUri(url). path("rest") .path("api") .path("latest") .path("search") .build().toString(); }

Target:
public static String buildSearchUrl(String url) { return UriBuilder.fromUri(url).path(SEARCH_URI_PATH).build().toString(); }
Source:
public static List<ObjectModelResolver> getResolvers() { if (resolvers == null) { synchronized (serviceLoader) { if (resolvers == null) { List<ObjectModelResolver> foundResolvers = new ArrayList<ObjectModelResolver>(); for (ObjectModelResolver reolver : serviceLoader) { foundResolvers.add(reolver); } resolvers = foundResolvers; } } } return resolvers; }

Target:
public static List<ObjectModelResolver> getResolvers() { if (resolvers == null) { synchronized (serviceLoader) { if (resolvers == null) { List<ObjectModelResolver> foundResolvers = new ArrayList<ObjectModelResolver>(); for (ObjectModelResolver resolver : serviceLoader) { foundResolvers.add(resolver); } resolvers = foundResolvers; } } } return resolvers; }
Source:
public String getLeadingImageEditLang() { return isTranslation ? captionTargetPageTitle == null ? null : captionTargetPageTitle.getWikiSite().languageCode() : captionSourcePageTitle == null ? null : captionSourcePageTitle.getWikiSite().languageCode(); }

Target:
public String getLeadingImageEditLang() { if (isTranslation ? (targetSummary == null || sourceSummary == null) : sourceSummary == null) { return null; } return isTranslation ? targetSummary.getPageTitle().getWikiSite().languageCode() : sourceSummary.getPageTitle().getWikiSite().languageCode(); }
Source:
public BasicDocumentRevision getDocument(String id, String rev) { Preconditions.checkState(this.isOpen(), "Database is closed"); Preconditions.checkArgument(!Strings.isNullOrEmpty(id), "DocumentRevisionTree id can not be empty"); Cursor cursor = null; try { String[] args = (rev == null) ? new String[]{id} : new String[]{id, rev}; String sql = (rev == null) ? GET_DOCUMENT_CURRENT_REVISION : GET_DOCUMENT_GIVEN_REVISION; cursor = this.sqlDb.rawQuery(sql, args); if (cursor.moveToFirst()) { return SQLDatabaseUtils.getFullRevisionFromCurrentCursor(cursor, attachmentManager); } else { return null; } } catch (SQLException e) { throw new SQLRuntimeException("Error getting document with id: " + id + "and rev" + rev, e); } finally { DatabaseUtils.closeCursorQuietly(cursor); } }

Target:
public BasicDocumentRevision getDocument(String id, String rev) { Preconditions.checkState(this.isOpen(), "Database is closed"); Preconditions.checkArgument(!Strings.isNullOrEmpty(id), "DocumentRevisionTree id can not be empty"); Cursor cursor = null; try { String[] args = (rev == null) ? new String[]{id} : new String[]{id, rev}; String sql = (rev == null) ? GET_DOCUMENT_CURRENT_REVISION : GET_DOCUMENT_GIVEN_REVISION; cursor = this.sqlDb.rawQuery(sql, args); if (cursor.moveToFirst()) { long sequence = cursor.getLong(3); List<? extends Attachment> atts = attachmentManager.attachmentsForRevision(sequence); return getFullRevisionFromCurrentCursor(cursor, atts); } else { return null; } } catch (SQLException e) { throw new SQLRuntimeException("Error getting document with id: " + id + "and rev" + rev, e); } finally { DatabaseUtils.closeCursorQuietly(cursor); } }
Source:
private static void writeTilesToBlockBuilder(OGCGeometry geometry, int zoomLevel, BingTile tile, BlockBuilder blockBuilder) { int tileZoomLevel = tile.getZoomLevel(); checkArgument(tile.getZoomLevel() <= zoomLevel); OGCGeometry polygon = tileToPolygon(tile); if (tileZoomLevel == zoomLevel) { if (!geometry.disjoint(polygon)) { BIGINT.writeLong(blockBuilder, tile.encode()); } return; } if (geometry.contains(polygon)) { int subTileCount = 1 << (zoomLevel - tileZoomLevel); int minX = subTileCount * tile.getX(); int minY = subTileCount * tile.getY(); for (int x = minX; x < minX + subTileCount; x++) { for (int y = minY; y < minY + subTileCount; y++) { BIGINT.writeLong(blockBuilder, BingTile.fromCoordinates(x, y, zoomLevel).encode()); } } return; } if (geometry.disjoint(polygon)) { return; } int minX = 2 * tile.getX(); int minY = 2 * tile.getY(); int nextZoomLevel = tileZoomLevel + 1; for (int x = minX; x < minX + 2; x++) { for (int y = minY; y < minY + 2; y++) { writeTilesToBlockBuilder( geometry, zoomLevel, BingTile.fromCoordinates(x, y, nextZoomLevel), blockBuilder); } } }

Target:
private static void writeTilesToBlockBuilder( OGCGeometry geometry, int zoomLevel, BingTile tile, BlockBuilder blockBuilder) { int tileZoomLevel = tile.getZoomLevel(); checkArgument(tile.getZoomLevel() <= zoomLevel); OGCGeometry polygon = tileToPolygon(tile); if (tileZoomLevel == zoomLevel) { if (!geometry.disjoint(polygon)) { BIGINT.writeLong(blockBuilder, tile.encode()); } return; } if (geometry.contains(polygon)) { int subTileCount = 1 << (zoomLevel - tileZoomLevel); int minX = subTileCount * tile.getX(); int minY = subTileCount * tile.getY(); for (int x = minX; x < minX + subTileCount; x++) { for (int y = minY; y < minY + subTileCount; y++) { BIGINT.writeLong(blockBuilder, BingTile.fromCoordinates(x, y, zoomLevel).encode()); } } return; } if (geometry.disjoint(polygon)) { return; } int minX = 2 * tile.getX(); int minY = 2 * tile.getY(); int nextZoomLevel = tileZoomLevel + 1; Verify.verify(nextZoomLevel <= MAX_ZOOM_LEVEL); for (int x = minX; x < minX + 2; x++) { for (int y = minY; y < minY + 2; y++) { writeTilesToBlockBuilder( geometry, zoomLevel, BingTile.fromCoordinates(x, y, nextZoomLevel), blockBuilder); } } }
Source:
private void initValidEmails() { if (validEmails == null) { validEmails = state().getEmailAddresses(); } }

Target:
private void initValidEmails() { if (validEmails == null) { validEmails = Sets.newHashSetWithExpectedSize(4); } }
Source:
public UserIdentity getUserIdentityByToken(String token) throws AuthException { log.debug("KeystoneService: entered getUserIdentityByToken. Token={}", token); if (StringUtils.isEmpty(token)) { throw new InvalidCredentialsException("No token was passed in."); } KeystoneAccess access = null; try { access = client.getToken(token); } catch (KeystoneConnectionException kex) { log.debug("Authentication connection failed: "+kex.getMessage()); } catch (KeystoneServerException ex) { log.debug("Authentication failed: "+ex.getMessage()); throw new InvalidCredentialsException("Invalid token"); } return (access == null) ? null : getUserIdentity(access); }

Target:
public UserIdentity getUserIdentityByToken(String token) throws AuthException { log.debug("KeystoneService: entered getUserIdentityByToken. Token={}", token); if (StringUtils.isEmpty(token)) { throw new InvalidCredentialsException("No token was passed in."); } KeystoneAccess access = null; try { access = client.getToken(token); } catch (KeystoneConnectionException kex) { log.warn("Authentication connection failed: "+ kex.getMessage()); } catch (KeystoneServerException ex) { log.debug("Authentication failed: " + ex.getMessage()); throw new InvalidCredentialsException("Problems with the token: " + ex.getMessage()); } return (access == null) ? null : getUserIdentity(access); }
Source:
public Path getResourceManagerRootPath() { return Paths.get(getResourceManagerRoot().getAbsolutePath()); }

Target:
public Path getResourceManagerRootPath() { return getResourceManagerRoot().toPath(); }
Source:
private XceiverClientSpi getClient(Pipeline pipeline, boolean forRead) throws IOException { HddsProtos.ReplicationType type = pipeline.getType(); try { String key = pipeline.getId().getId().toString() + type; if (topologyAwareRead && forRead) { key += pipeline.getClosestNode().getHostName(); } key = isSecurityEnabled ? key + UserGroupInformation.getCurrentUser().getShortUserName() : key; return clientCache.get(key, new Callable<XceiverClientSpi>() { @Override public XceiverClientSpi call() throws Exception { XceiverClientSpi client = null; switch (type) { case RATIS: client = XceiverClientRatis.newXceiverClientRatis(pipeline, conf); client.connect(); break; case STAND_ALONE: client = new XceiverClientGrpc(pipeline, conf); break; case CHAINED: default: throw new IOException("not implemented" + pipeline.getType()); } return client; } }); } catch (Exception e) { throw new IOException( "Exception getting XceiverClient: " + e.toString(), e); } }

Target:
private XceiverClientSpi getClient(Pipeline pipeline, boolean forRead) throws IOException { HddsProtos.ReplicationType type = pipeline.getType(); try { String key = getPipelineCacheKey(pipeline, forRead); key = isSecurityEnabled ? key + UserGroupInformation.getCurrentUser().getShortUserName() : key; return clientCache.get(key, new Callable<XceiverClientSpi>() { @Override public XceiverClientSpi call() throws Exception { XceiverClientSpi client = null; switch (type) { case RATIS: client = XceiverClientRatis.newXceiverClientRatis(pipeline, conf); client.connect(); break; case STAND_ALONE: client = new XceiverClientGrpc(pipeline, conf); break; case CHAINED: default: throw new IOException("not implemented" + pipeline.getType()); } return client; } }); } catch (Exception e) { throw new IOException( "Exception getting XceiverClient: " + e.toString(), e); } }
Source:
public void cancel() { final PublishSubject<Integer> pp = PublishSubject.create(); final CompletableSubject cs = CompletableSubject.create(); TestObserver<Integer> ts = pp.mergeWith(cs).test(); assertTrue(pp.hasObservers()); assertTrue(cs.hasObservers()); ts.cancel(); assertFalse(pp.hasObservers()); assertFalse(cs.hasObservers()); }

Target:
public void cancel() { final PublishSubject<Integer> ps = PublishSubject.create(); final CompletableSubject cs = CompletableSubject.create(); TestObserver<Integer> to = ps.mergeWith(cs).test(); assertTrue(ps.hasObservers()); assertTrue(cs.hasObservers()); to.cancel(); assertFalse(ps.hasObservers()); assertFalse(cs.hasObservers()); }