auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static void registerDungeons() { if(isLegacy) return; try { Method addDungeonMob = Class.forName("com.evilnotch.dungeontweeks.main.world.worldgen.mobs.DungeonMobs").getMethod("addDungeonMob", ResourceLocation.class,ResourceLocation.class,int.class); for(AS_WorldGenTower.TowerTypes tower : AS_WorldGenTower.TowerTypes.values()) { boolean nether = tower == TowerTypes.Netherrack; addDungeonMob.invoke(null, tower.getId(), new ResourceLocation("cave_spider"), 100); addDungeonMob.invoke(null,tower.getId(), new ResourceLocation("spider"), 90); addDungeonMob.invoke(null,tower.getId(), nether ? new ResourceLocation("wither_skeleton") : new ResourceLocation("skeleton"), 120); addDungeonMob.invoke(null,tower.getId(), new ResourceLocation("zombie"), 120); if(nether) addDungeonMob.invoke(null,tower.getId(), new ResourceLocation("blaze"), 20); } } catch(Exception e) { e.printStackTrace(); } }

Target:
public static void registerDungeons() { if (!isLoaded || isLegacy) { return; } try { Method addDungeonMob = Class.forName("com.evilnotch.dungeontweeks.main.world.worldgen.mobs.DungeonMobs").getMethod("addDungeonMob", ResourceLocation.class, ResourceLocation.class, int.class); for (AS_WorldGenTower.TowerTypes tower : AS_WorldGenTower.TowerTypes.values()) { boolean nether = tower == TowerTypes.Netherrack; addDungeonMob.invoke(null, tower.getId(), new ResourceLocation("cave_spider"), 100); addDungeonMob.invoke(null, tower.getId(), new ResourceLocation("spider"), 90); addDungeonMob.invoke(null, tower.getId(), nether ? new ResourceLocation("wither_skeleton") : new ResourceLocation("skeleton"), 120); addDungeonMob.invoke(null, tower.getId(), new ResourceLocation("zombie"), 120); if (nether) { addDungeonMob.invoke(null, tower.getId(), new ResourceLocation("blaze"), 20); } } } catch (Exception e) { e.printStackTrace(); } }
Source:
public static void checkNumberOfLVsForBlockDomain(Guid storageDomainId) { StorageDomainStatic domain = DbFacade.getInstance().getStorageDomainStaticDao().get(storageDomainId); if (domain.getStorageType().isBlockDomain()) { long numOfLVs = DbFacade.getInstance().getStorageDomainDao().getNumberOfImagesInStorageDomain(storageDomainId); Integer maxNumOfLVs = Config.getValue(ConfigValues.AlertOnNumberOfLVs); if (numOfLVs >= maxNumOfLVs) { AuditLogableBase logable = new AuditLogableBase(); logable.setStorageDomainId(storageDomainId); logable.addCustomValue("maxNumOfLVs", maxNumOfLVs.toString()); AuditLogDirector.log(logable, AuditLogType.NUNBER_OF_LVS_ON_STORAGE_DOMAIN_EXCEEDED_THRESHOLD); } } }

Target:
public static void checkNumberOfLVsForBlockDomain(Guid storageDomainId) { StorageDomainStatic domain = DbFacade.getInstance().getStorageDomainStaticDao().get(storageDomainId); if (domain.getStorageType().isBlockDomain()) { long numOfLVs = DbFacade.getInstance().getStorageDomainDao().getNumberOfImagesInStorageDomain(storageDomainId); Integer maxNumOfLVs = Config.getValue(ConfigValues.AlertOnNumberOfLVs); if (numOfLVs >= maxNumOfLVs) { AuditLogableBase logable = new AuditLogableBase(); logable.addCustomValue("storageDomainName", domain.getStorageName()); logable.addCustomValue("maxNumOfLVs", maxNumOfLVs.toString()); AuditLogDirector.log(logable, AuditLogType.NUNBER_OF_LVS_ON_STORAGE_DOMAIN_EXCEEDED_THRESHOLD); } } }
Source:
public void writeTo(ProtoStreamWriter protoStreamWriter, KObject kObject) throws IOException { protoStreamWriter.writeString(MetaObject.META_OBJECT_ID, kObject.getId()); protoStreamWriter.writeString(MetaObject.META_OBJECT_TYPE, kObject.getType().getName()); protoStreamWriter.writeString(CLUSTER_ID, kObject.getClusterId()); protoStreamWriter.writeString(SEGMENT_ID, kObject.getSegmentId()); protoStreamWriter.writeString(MetaObject.META_OBJECT_KEY, kObject.getKey()); List<KProperty<?>> props = new ArrayList<>(); kObject.getProperties().iterator().forEachRemaining(props::add); props.removeIf(kProperty -> props.stream() .filter(prop -> kProperty.getName().equals(prop.getName())).count() > 1); props.forEach(kProperty -> { try { this.build(toProtobufFormat(kProperty.getName()), kProperty.getValue(), protoStreamWriter); } catch (IOException e) { logger.error("error", e); } }); if (kObject.fullText()) { protoStreamWriter.writeString(MetaObject.META_OBJECT_FULL_TEXT, props.stream() .filter(kProperty -> kProperty.isSearchable() && !(kProperty.getValue() instanceof Boolean)) .map(kProperty -> String.valueOf(kProperty.getValue()).toLowerCase()) .collect(joining("\n"))); } }

Target:
public void writeTo(ProtoStreamWriter protoStreamWriter, KObject kObject) throws IOException { Descriptor descriptor = protoStreamWriter.getSerializationContext().getMessageDescriptor(this.getTypeName()); TreeMap<Integer, KProperty<?>> props = new TreeMap<>(); this.addKProperty(props, descriptor, MetaObject.META_OBJECT_ID, kObject.getId()); this.addKProperty(props, descriptor, MetaObject.META_OBJECT_TYPE, kObject.getType().getName()); this.addKProperty(props, descriptor, CLUSTER_ID, kObject.getClusterId()); this.addKProperty(props, descriptor, SEGMENT_ID, kObject.getSegmentId()); this.addKProperty(props, descriptor, MetaObject.META_OBJECT_KEY, kObject.getKey()); kObject.getProperties() .iterator() .forEachRemaining(kprop -> Optional.ofNullable(descriptor.findFieldByName(toProtobufFormat(kprop.getName()))) .ifPresent(field -> props .putIfAbsent(field.getNumber(), kprop))); if (kObject.fullText()) { this.addKProperty(props, descriptor, MetaObject.META_OBJECT_FULL_TEXT, props.values().stream() .filter(kProperty -> kProperty.isSearchable() && !(kProperty.getValue() instanceof Boolean)) .map(kProperty -> String.valueOf(kProperty.getValue()).toLowerCase()) .collect(joining("\n"))); } props.keySet().forEach((number) -> { try { KProperty<?> kProperty = props.get(number); this.writeField(toProtobufFormat(kProperty.getName()), kProperty.getValue(), protoStreamWriter); } catch (IOException e) { logger.error("error", e); } }); }
Source:
public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final Point point = (Point) o; if (Float.compare(point.xCoordinate, xCoordinate) != 0) return false; return Float.compare(point.yCoordinate, yCoordinate) == 0; }

Target:
public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof Point)) { return false; } final Point point = (Point) o; if (Double.compare(point.xCoordinate, xCoordinate) != 0) { return false; } return Double.compare(point.yCoordinate, yCoordinate) == 0; }
Source:
public Response remove() { return BackendClusterFeatureHelper.disableClusterFeature(this, asGuid(clusterId), asGuid(id)); }

Target:
public Response remove() { Cluster cluster = BackendClusterFeatureHelper.getClusterWithFeatureDisabled(this, asGuid(clusterId), guid); ManagementNetworkOnClusterOperationParameters param = new ManagementNetworkOnClusterOperationParameters(cluster); return performAction(ActionType.UpdateCluster, param); }
Source:
public Cluster getClusterByName(String clusterName) { Collection<Cluster> clusters = listClusters(Lists.newArrayList(new QueryParam("name", clusterName))); if (clusters.size() > 1) { LOG.warn("Multiple Clusters have same name: returning first one.", clusterName); return clusters.iterator().next(); } else if (clusters.size() == 1) { return clusters.iterator().next(); } return null; }

Target:
public Cluster getClusterByName(String clusterName) { Collection<Cluster> clusters = listClusters(Lists.newArrayList(new QueryParam("name", clusterName))); if (clusters.size() > 1) { LOG.warn("Multiple Clusters have same name: returning first match.", clusterName); return clusters.iterator().next(); } else if (clusters.size() == 1) { return clusters.iterator().next(); } return null; }
Source:
public void shouldSetJettyHomeAndBasePropertyIfItsNotSet() { when(systemEnvironment.getPropertyImpl("jetty.home")).thenReturn(""); when(systemEnvironment.getPropertyImpl("user.dir")).thenReturn("junk"); JettyWorkDirValidator jettyWorkDirValidator = new JettyWorkDirValidator(systemEnvironment); Validation val = new Validation(); jettyWorkDirValidator.validate(val); assertThat(val.isSuccessful(), is(true)); verify(systemEnvironment).setProperty("jetty.home", "junk"); }

Target:
public void shouldSetJettyHomeAndBasePropertyIfItsNotSet() { when(systemEnvironment.getPropertyImpl("jetty.home")).thenReturn(""); when(systemEnvironment.getPropertyImpl("user.dir")).thenReturn("junk"); Validation val = new Validation(); jettyWorkDirValidator.validate(val); assertThat(val.isSuccessful(), is(true)); verify(systemEnvironment).getPropertyImpl("user.dir"); verify(systemEnvironment).setProperty("jetty.home", "junk"); }
Source:
public ObserveResponse observe(int resourceid) { return ObserveResponse.notFound(); }

Target:
public ObserveResponse observe(int resourceid) { ReadResponse readResponse = this.read(resourceid); return ObserveResponse.success(readResponse.getContent()); }
Source:
public HttpServiceResponse handle(HttpServiceRequest request) throws Exception { HttpServiceResponse response = new HttpServiceResponse(); if (HttpServer.Method.GET == request.getMethod()) { Collection<BookieSocketAddress> bookies = new ArrayList<BookieSocketAddress>(); Map<String, String> params = request.getParams(); boolean readOnly = (params != null) && params.containsKey("type") && params.get("type").equals("ro"); boolean printHostname = (params != null) && params.containsKey("print_hostnames") && params.get("print_hostnames").equals("true"); ClientConfiguration clientconf = new ClientConfiguration(conf) .setZkServers(conf.getZkServers()); BookKeeperAdmin bka = new BookKeeperAdmin(clientconf); if (readOnly) { bookies.addAll(bka.getReadOnlyBookies()); } else { bookies.addAll(bka.getAvailableBookies()); } Map<String, String> output = Maps.newHashMap(); for (BookieSocketAddress b : bookies) { output.putIfAbsent(b.toString(), printHostname ? b.getHostName() : null); LOG.debug("bookie: " + b.toString() + " hostname:" + b.getHostName()); } String jsonResponse = JsonUtil.toJson(output); response.setBody(jsonResponse); response.setCode(HttpServer.StatusCode.OK); return response; } else { response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Not found method. Should be GET method"); return response; } }

Target:
public HttpServiceResponse handle(HttpServiceRequest request) throws Exception { HttpServiceResponse response = new HttpServiceResponse(); if (HttpServer.Method.GET == request.getMethod()) { Collection<BookieSocketAddress> bookies = new ArrayList<BookieSocketAddress>(); Map<String, String> params = request.getParams(); boolean readOnly = (params != null) && params.containsKey("type") && params.get("type").equals("ro"); boolean printHostname = (params != null) && params.containsKey("print_hostnames") && params.get("print_hostnames").equals("true"); if (readOnly) { bookies.addAll(bka.getReadOnlyBookies()); } else { bookies.addAll(bka.getAvailableBookies()); } Map<String, String> output = Maps.newHashMap(); for (BookieSocketAddress b : bookies) { output.putIfAbsent(b.toString(), printHostname ? b.getHostName() : null); LOG.debug("bookie: " + b.toString() + " hostname:" + b.getHostName()); } String jsonResponse = JsonUtil.toJson(output); response.setBody(jsonResponse); response.setCode(HttpServer.StatusCode.OK); return response; } else { response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Not found method. Should be GET method"); return response; } }
Source:
public void newGlobalEntries(final TmfPieChartViewer context) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { synchronized (context.getMutexLayoutChange()) { if (!context.isDisposed()) { context.updateGlobalPieChart(); context.getGlobalPC().redraw(); } } } }); }

Target:
public void newGlobalEntries(final TmfPieChartViewer context) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { synchronized (context) { if (!context.isDisposed()) { context.updateGlobalPieChart(); context.getGlobalPC().redraw(); } } } }); }
Source:
public void unretireProgram_shouldSetRetireFalseForWorkflowsAndWorkflowStates() { Program program = pws.getAllPrograms().get(0); Date lastModifiedDate = program.getDateChanged(); Program program1 = pws.unretireProgram(program); assertEquals(program.getRetired(), false); for (ProgramWorkflow workflow : program.getAllWorkflows()) { if (lastModifiedDate != null && lastModifiedDate.equals(workflow.getDateChanged())) { assertEquals(workflow.getRetired(), false); for (ProgramWorkflowState state : workflow.getStates()) { if (lastModifiedDate.equals(state.getDateChanged())) { assertEquals(state.getRetired(), false); } } } } }

Target:
public void unretireProgram_shouldSetRetireFalseForWorkflowsAndWorkflowStates() { Program program = pws.getAllPrograms().get(0); Date lastModifiedDate = program.getDateChanged(); assertEquals(program.getRetired(), false); for (ProgramWorkflow workflow : program.getAllWorkflows()) { if (lastModifiedDate != null && lastModifiedDate.equals(workflow.getDateChanged())) { assertEquals(workflow.getRetired(), false); for (ProgramWorkflowState state : workflow.getStates()) { if (lastModifiedDate.equals(state.getDateChanged())) { assertEquals(state.getRetired(), false); } } } } }
Source:
public List<String> getPrivatePackages() { List<String> privatePackagesEntries1 = getEntries(Constants.PRIVATEPACKAGE, listConverter); List<String> privatePackagesEntries2 = getEntries(Constants.PRIVATE_PACKAGE, listConverter); Set<String> privatePackages = Stream.concat(privatePackagesEntries1.stream(), privatePackagesEntries2.stream()) .collect(toSet()); return new ArrayList<>(privatePackages); }

Target:
public List<String> getPrivatePackages() { List<String> privatePackagesEntries1 = getEntries(Constants.PRIVATEPACKAGE, listConverter); List<String> privatePackagesEntries2 = getEntries(Constants.PRIVATE_PACKAGE, listConverter); return Stream.concat(privatePackagesEntries1.stream(), privatePackagesEntries2.stream()) .distinct() .collect(toList()); }
Source:
public RealmObjectSchema removeField(String fieldName) { checkLegalName(fieldName); if (!hasField(fieldName)) { throw new IllegalStateException(fieldName + " does not exist."); } long columnIndex = getColumnIndex(fieldName); if (table.getPrimaryKey() == columnIndex) { table.setPrimaryKey(null); } if (columnIndex < table.getPrimaryKey()) { String pkField = getPrimaryKey(); table.removeColumn(columnIndex); table.setPrimaryKey(pkField); return this; } table.removeColumn(columnIndex); return this; }

Target:
public RealmObjectSchema removeField(String fieldName) { checkLegalName(fieldName); if (!hasField(fieldName)) { throw new IllegalStateException(fieldName + " does not exist."); } long columnIndex = getColumnIndex(fieldName); if (table.getPrimaryKey() == columnIndex) { table.setPrimaryKey(null); } table.removeColumn(columnIndex); return this; }
Source:
private OutputStream addPreSteps(ProcessingStepHandler handler, IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { ArrayList<ProcessingStep> steps = new ArrayList<ProcessingStep>(); if (IArtifactDescriptor.TYPE_ZIP.equals(descriptor.getProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE))) steps.add(new ZipVerifierStep()); List<ChecksumVerifier> checksumVerifiers = ChecksumUtilities.getChecksumVerifiers(descriptor); for (ChecksumVerifier checksumVerifier : checksumVerifiers) { steps.add(checksumVerifier); } if (steps.isEmpty()) return destination; ProcessingStep[] stepArray = steps.toArray(new ProcessingStep[steps.size()]); return handler.link(stepArray, destination, monitor); }

Target:
private OutputStream addPreSteps(ProcessingStepHandler handler, IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { ArrayList<ProcessingStep> steps = new ArrayList<ProcessingStep>(); if (IArtifactDescriptor.TYPE_ZIP.equals(descriptor.getProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE))) steps.add(new ZipVerifierStep()); Iterable<ChecksumVerifier> checksumVerifiers = ChecksumUtilities.getChecksumVerifiers(descriptor); for (ChecksumVerifier checksumVerifier : checksumVerifiers) { steps.add(checksumVerifier); } if (steps.isEmpty()) return destination; ProcessingStep[] stepArray = steps.toArray(new ProcessingStep[steps.size()]); return handler.link(stepArray, destination, monitor); }
Source:
@Override public Schema create(SchemaPlus parentSchema, String name, Map<String, Object> operand) { final Map map = (Map) operand; final ObjectMapper mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); try { List<HttpHost> hosts; if (map.containsKey("hosts")) { final List<String> configHosts = mapper.readValue((String) map.get("hosts"), new TypeReference<List<String>>() { }); hosts = configHosts .stream() .map(host -> HttpHost.create(host)) .collect(Collectors.toList()); } else if (map.containsKey("coordinates")) { final Map<String, Integer> coordinates = mapper.readValue((String) map.get("coordinates"), new TypeReference<Map<String, Integer>>() { }); hosts = coordinates .entrySet() .stream() .map(entry -> new HttpHost(entry.getKey(), entry.getValue())) .collect(Collectors.toList()); LOGGER.warn("Prefer using hosts, coordinates is deprecated."); } else { throw new IllegalArgumentException ("Both 'coordinates' and 'hosts' is missing in configuration. Provide one of them."); } final String pathPrefix = (String) map.get("pathPrefix"); String jdbcUser = (String) map.get("jdbcUser"); String jdbcPassword = (String) map.get("jdbcPassword"); final RestClient client = connect(hosts, pathPrefix, jdbcUser, jdbcPassword); final String index = (String) map.get("index"); return new ElasticsearchSchema(client, new ObjectMapper(), index); } catch (IOException e) { throw new RuntimeException("Cannot parse values from json", e); } }

Target:
@Override public Schema create(SchemaPlus parentSchema, String name, Map<String, Object> operand) { final Map map = (Map) operand; final ObjectMapper mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); try { List<HttpHost> hosts; if (map.containsKey("hosts")) { final List<String> configHosts = mapper.readValue((String) map.get("hosts"), new TypeReference<List<String>>() { }); hosts = configHosts .stream() .map(host -> HttpHost.create(host)) .collect(Collectors.toList()); } else if (map.containsKey("coordinates")) { final Map<String, Integer> coordinates = mapper.readValue((String) map.get("coordinates"), new TypeReference<Map<String, Integer>>() { }); hosts = coordinates .entrySet() .stream() .map(entry -> new HttpHost(entry.getKey(), entry.getValue())) .collect(Collectors.toList()); LOGGER.warn("Prefer using hosts, coordinates is deprecated."); } else { throw new IllegalArgumentException ("Both 'coordinates' and 'hosts' is missing in configuration. Provide one of them."); } final String pathPrefix = (String) map.get("pathPrefix"); String username = (String) map.get("username"); String password = (String) map.get("password"); final RestClient client = connect(hosts, pathPrefix, username, password); final String index = (String) map.get("index"); return new ElasticsearchSchema(client, new ObjectMapper(), index); } catch (IOException e) { throw new RuntimeException("Cannot parse values from json", e); } }
Source:
public void doWork (InputStream is, OutputStream os) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); PrintWriter out = new PrintWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8)); try { String request = in.readLine(); if ("PING".equals(request)) { out.println("PONG"); } else if (RecoveryDriver.isScan(request)) { boolean isAsync = RecoveryDriver.isAsyncScan(request); boolean anyProblems = false; if (!isAsync) { synchronized (this) { doWait = true; } } _periodicRecovery.wakeUp(); tsLogger.i18NLogger.info_recovery_WorkerService_3(); if (!isAsync) { synchronized (this) { if (doWait) { try { wait(); } catch (Exception ex) { tsLogger.i18NLogger.info_recovery_WorkerService_4(); } } } } if (RecoveryDriver.isVerboseScan(request)) { for (final RecoveryModule recoveryModule : RecoveryManager.manager().getModules()) { if (recoveryModule instanceof ExtendedRecoveryModule) { if (!((ExtendedRecoveryModule) recoveryModule).isPeriodicWorkSuccessful()) { anyProblems = true; } break; } } } out.println(anyProblems ? "ERROR" : "DONE"); } else out.println("ERROR"); out.flush(); } catch (IOException ex) { tsLogger.i18NLogger.warn_recovery_WorkerService_2(); } catch ( Exception ex ) { tsLogger.i18NLogger.warn_recovery_WorkerService_1(ex); } }

Target:
public void doWork (InputStream is, OutputStream os) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); PrintWriter out = new PrintWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8)); try { String request = in.readLine(); if ("PING".equals(request)) { out.println("PONG"); } else if (RecoveryDriver.isScan(request)) { boolean isAsync = RecoveryDriver.isAsyncScan(request); boolean anyProblems = false; if (!isAsync) { synchronized (this) { doWait = true; } } _periodicRecovery.wakeUp(); tsLogger.i18NLogger.info_recovery_WorkerService_3(); if (!isAsync) { synchronized (this) { if (doWait && _periodicRecovery.getMode() != PeriodicRecovery.Mode.TERMINATED) { try { wait(); } catch (Exception ex) { if(tsLogger.logger.isTraceEnabled()) { tsLogger.logger.trace("Waiting for recovery scan to complete finished with an exception", ex); } tsLogger.i18NLogger.info_recovery_WorkerService_4(); } } } } if (RecoveryDriver.isVerboseScan(request)) { for (final RecoveryModule recoveryModule : RecoveryManager.manager().getModules()) { if (recoveryModule instanceof ExtendedRecoveryModule) { if (!((ExtendedRecoveryModule) recoveryModule).isPeriodicWorkSuccessful()) { anyProblems = true; } break; } } } out.println(anyProblems ? "ERROR" : "DONE"); } else out.println("ERROR"); out.flush(); } catch (IOException ioe) { tsLogger.i18NLogger.warn_recovery_WorkerService_2(ioe); } catch ( Exception ex ) { tsLogger.i18NLogger.warn_recovery_WorkerService_1(ex); } }
Source:
public void accept(DeploymentProcessorTarget deploymentProcessorTarget) { deploymentProcessorTarget.addDeploymentProcessor(MicroProfileFaultToleranceExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_MICROPROFILE_OPENTRACING + 1, new MicroProfileFaultToleranceDependenciesProcessor()); deploymentProcessorTarget.addDeploymentProcessor(MicroProfileFaultToleranceExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_MICROPROFILE_OPENTRACING + 1, new MicroProfileFaultToleranceDeploymentProcessor()); }

Target:
public void accept(DeploymentProcessorTarget deploymentProcessorTarget) { deploymentProcessorTarget.addDeploymentProcessor(MicroProfileFaultToleranceExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_MICROPROFILE_FAULT_TOLERANCE, new MicroProfileFaultToleranceDependenciesProcessor()); deploymentProcessorTarget.addDeploymentProcessor(MicroProfileFaultToleranceExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_MICROPROFILE_FAULT_TOLERANCE, new MicroProfileFaultToleranceDeploymentProcessor()); }
Source:
public Builder centerCrop() { centerCrop = true; return this; }

Target:
public Builder centerCrop() { if (centerInside) { throw new IllegalStateException("Center crop can not be used after calling centerInside"); } centerCrop = true; return this; }
Source:
public static ZkChildrenCache createCache(final CuratorFramework client, final String key) { try { return executeWithRetry( () -> { final ZkChildrenCache newCache = new ZkChildrenCache(client, key);; try { newCache.start(); return newCache; } catch (final KeeperException.NoNodeException e) { throw e; } catch (final Exception e) { throw new NakadiRuntimeException(e); } }, new RetryForSpecifiedCountStrategy<ZkChildrenCache>(MAX_NUMBER_OF_RETRIES) .withExceptionsThatForceRetry(ImmutableList.of(KeeperException.NoNodeException.class)) .withWaitBetweenEachTry(WAIT_BETWEEN_TRIES_MS)); } catch (final Exception e) { LOG.error("Zookeeper error when creating cache for children", e); throw new NakadiRuntimeException(e); } }

Target:
public static ZkChildrenCache createCache(final CuratorFramework client, final String key) { try { return executeWithRetry( () -> { final ZkChildrenCache newCache = new ZkChildrenCache(client, key); try { newCache.start(); return newCache; } catch (final KeeperException.NoNodeException e) { throw e; } catch (final Exception e) { throw new NakadiRuntimeException(e); } }, new RetryForSpecifiedCountStrategy<ZkChildrenCache>(MAX_NUMBER_OF_RETRIES) .withExceptionsThatForceRetry(ImmutableList.of(KeeperException.NoNodeException.class)) .withWaitBetweenEachTry(WAIT_BETWEEN_TRIES_MS)); } catch (final Exception e) { LOG.error("Zookeeper error when creating cache for children", e); throw new NakadiRuntimeException(e); } }
Source:
private Filter adaptBinaryComparator( CompareOp compareOp, BinaryComparator comparator) { ByteString value = ByteString.copyFrom(comparator.getValue()); switch (compareOp) { case LESS: return range().endOpen(value); case LESS_OR_EQUAL: return range().endClosed(value); case EQUAL: if (comparator.getValue().length == 0) { return FILTERS.value().regex(value); } else { return range().startClosed(value).endClosed(value); } case NOT_EQUAL: if(comparator.getValue().length == 0) { return FILTERS.value().regex(".+"); } else { return FILTERS.interleave().filter(range().endOpen(value)).filter(range().startOpen(value)); } case GREATER_OR_EQUAL: return range().startClosed(value); case GREATER: return range().startOpen(value); case NO_OP: return FILTERS.pass(); default: throw new IllegalStateException( String.format("Cannot handle unknown compare op %s", compareOp)); } }

Target:
private Filter adaptBinaryComparator( CompareOp compareOp, BinaryComparator comparator) { ByteString value = ByteString.copyFrom(comparator.getValue()); switch (compareOp) { case LESS: return range().endOpen(value); case LESS_OR_EQUAL: return range().endClosed(value); case EQUAL: if (comparator.getValue().length == 0) { return FILTERS.value().regex(value); } else { return range().startClosed(value).endClosed(value); } case NOT_EQUAL: if(comparator.getValue().length == 0) { return FILTERS.value().regex(ReaderExpressionHelper.ANY_BYTES); } else { return FILTERS.interleave() .filter(range().endOpen(value)) .filter(range().startOpen(value)); } case GREATER_OR_EQUAL: return range().startClosed(value); case GREATER: return range().startOpen(value); case NO_OP: return FILTERS.pass(); default: throw new IllegalStateException( String.format("Cannot handle unknown compare op %s", compareOp)); } }
Source:
public static String stripTrailingSlash(String str) { if (str.charAt(str.length() - 1) == '/') { return str.substring(0, str.length() - 1); } return str; }

Target:
public static String stripTrailingSlash(String str) { if (isNullOrEmpty(str)) { return str; } if (str.charAt(str.length() - 1) == '/') { return str.substring(0, str.length() - 1); } return str; }
Source:
@Override public <T> T gauge(Id id, T obj, ToDoubleFunction<T> f) { final String name = toMetricName(id); Gauge aggrGauge = this.impl.getGauges().get(name); if (aggrGauge == null) { aggrGauge = new MetricsGaugeAggr(); this.impl.register(name, aggrGauge); } if (aggrGauge instanceof MetricsGaugeAggr) { final MetricsGauge<T> simpleGauge = new MetricsGauge<>(clock(), id, obj, f); register(simpleGauge); ((MetricsGaugeAggr) aggrGauge).addGauge(simpleGauge); } return obj; }

Target:
@Override public <T> T gauge(Id id, T obj, ToDoubleFunction<T> f) { final Gauge aggrGauge = registeredGauges.computeIfAbsent(id, idKey -> { final String name = toMetricName(id); final MetricsGaugeAggr aggr = new MetricsGaugeAggr(); try { this.impl.register(name, aggr); } catch (IllegalArgumentException e) { Throwables.propagate(e); return null; } return aggr; }); if (aggrGauge != null) { final MetricsGauge<T> simpleGauge = new MetricsGauge<>(clock(), id, obj, f); register(simpleGauge); ((MetricsGaugeAggr) aggrGauge).addGauge(simpleGauge); } return obj; }
Source:
private static void seedData(MesosCluster cluster, ElasticsearchSchedulerContainer schedulerContainer) { String taskHttpAddress; try { ESTasks esTasks = new ESTasks(TEST_CONFIG, schedulerContainer.getIpAddress()); new TasksResponse(esTasks, 3, "TASK_RUNNING"); taskHttpAddress = esTasks.getTasks().get(0).getString("http_address"); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } SeedDataContainer seedData = new SeedDataContainer(clusterArchitecture.dockerClient, "http://" + taskHttpAddress); cluster.addAndStartContainer(seedData); LOGGER.info("Elasticsearch node " + taskHttpAddress + " seeded with data"); }

Target:
private static void seedData(MesosCluster cluster, ElasticsearchSchedulerContainer schedulerContainer) { String taskHttpAddress; try { ESTasks esTasks = new ESTasks(TEST_CONFIG, schedulerContainer.getIpAddress()); new TasksResponse(esTasks, TEST_CONFIG.getElasticsearchNodesCount(), "TASK_RUNNING"); taskHttpAddress = esTasks.getTasks().get(0).getString("http_address"); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } SeedDataContainer seedData = new SeedDataContainer(clusterArchitecture.dockerClient, "http://" + taskHttpAddress); cluster.addAndStartContainer(seedData); LOGGER.info("Elasticsearch node " + taskHttpAddress + " seeded with data"); }
Source:
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == RowType.THREAD) { View discussionThreadRow = LayoutInflater. from(parent.getContext()). inflate(R.layout.discussion_responses_thread_row, parent, false); return new DiscussionThreadViewHolder(discussionThreadRow); } if (viewType == RowType.MORE_BUTTON) { View discussionThreadRow = LayoutInflater. from(parent.getContext()). inflate(R.layout.show_more_button_row, parent, false); return new ShowMoreViewHolder(discussionThreadRow); } View discussionResponseRow = LayoutInflater. from(parent.getContext()). inflate(R.layout.discussion_responses_response_row, parent, false); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) discussionResponseRow.getLayoutParams(); params.topMargin -= discussionResponseRow.getPaddingTop(); params.leftMargin -= discussionResponseRow.getPaddingLeft(); params.rightMargin -= discussionResponseRow.getPaddingRight(); discussionResponseRow.setLayoutParams(params); return new DiscussionResponseViewHolder(discussionResponseRow); }

Target:
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == RowType.THREAD) { View discussionThreadRow = LayoutInflater. from(parent.getContext()). inflate(R.layout.discussion_responses_thread_row, parent, false); return new DiscussionThreadViewHolder(discussionThreadRow); } if (viewType == RowType.MORE_BUTTON) { View discussionThreadRow = LayoutInflater. from(parent.getContext()). inflate(R.layout.show_more_button_row, parent, false); return new ShowMoreViewHolder(discussionThreadRow); } View discussionResponseRow = LayoutInflater. from(parent.getContext()). inflate(R.layout.discussion_responses_response_row, parent, false); UiUtil.adjustCardViewMargins(discussionResponseRow); return new DiscussionResponseViewHolder(discussionResponseRow); }
Source:
public MantaObjectResponse(final String path, final MantaHttpHeaders headers, final MantaMetadata metadata) { Validate.notBlank(path, "Path must be not be blank"); Validate.notNull(headers, "Headers must not be null"); this.path = path; this.httpHeaders = headers; this.contentLength = headers.getContentLength(); this.etag = headers.getETag(); this.mtime = headers.getLastModified(); this.requestId = headers.getRequestId(); if (headers.getContentType() != null) { final String contentType = headers.getContentType(); if (contentType == null) { this.type = null; } else if (contentType.equals(DIRECTORY_RESPONSE_CONTENT_TYPE)) { this.type = "directory"; } else if (contentType.equals(BUCKET_RESPONSE_CONTENT_TYPE)) { this.type = "bucket"; } else if (contentType.equals(BUCKETOBJECT_RESPONSE_CONTENT_TYPE)) { this.type = "bucketobject"; } else { this.type = "object"; } } else { this.type = null; } if (metadata != null) { this.metadata = metadata; } else { this.metadata = new MantaMetadata(headers.metadataAsStrings()); } }

Target:
public MantaObjectResponse(final String path, final MantaHttpHeaders headers, final MantaMetadata metadata) { Validate.notBlank(path, "Path must be not be blank"); Validate.notNull(headers, "Headers must not be null"); this.path = path; this.httpHeaders = headers; this.contentLength = headers.getContentLength(); this.etag = headers.getETag(); this.mtime = headers.getLastModified(); this.requestId = headers.getRequestId(); if (headers.getContentType() != null) { final String contentType = headers.getContentType(); if (contentType == null) { this.type = null; } else if (contentType.equals(DIRECTORY_RESPONSE_CONTENT_TYPE)) { this.type = MANTA_OBJECT_TYPE_DIRECTORY; } else if (contentType.equals(BUCKET_RESPONSE_CONTENT_TYPE)) { this.type = MANTA_OBJECT_TYPE_BUCKET; } else if (contentType.equals(BUCKETOBJECT_RESPONSE_CONTENT_TYPE)) { this.type = MANTA_OBJECT_TYPE_BUCKETOBJECT; } else { this.type = MANTA_OBJECT_TYPE_OBJECT; } } else { this.type = null; } if (metadata != null) { this.metadata = metadata; } else { this.metadata = new MantaMetadata(headers.metadataAsStrings()); } }
Source:
public void beforeCreateEncounter(Encounter encounter) { if (encounter.getVisit() != null) return; if (encounter.getLocation() == null) { return; } Date when = encounter.getEncounterDatetime(); if (when == null) { when = new Date(); } List<Patient> patient = Collections.singletonList(encounter.getPatient()); List<Visit> candidates = visitService.getVisits(null, patient, null, null, null, when, null, null, null, true, false); if (candidates != null) { for (Visit candidate : candidates) { if (adtService.isSuitableVisit(candidate, encounter.getLocation(), when)) { candidate.addEncounter(encounter); return; } } } if (StringUtils.isNotBlank(administrationService.getGlobalProperty(EmrApiConstants.GP_VISIT_ASSIGNMENT_HANDLER_ENCOUNTER_TYPE_TO_VISIT_TYPE_MAP))) { EncounterTypetoVisitTypeMapper encounterTypetoVisitTypeMapper = Context.getRegisteredComponents(EncounterTypetoVisitTypeMapper.class).get(0); encounterTypetoVisitTypeMapper.setMappingString(administrationService.getGlobalProperty(EmrApiConstants.GP_VISIT_ASSIGNMENT_HANDLER_ENCOUNTER_TYPE_TO_VISIT_TYPE_MAP)); VisitType visitType = encounterTypetoVisitTypeMapper.getVisitTypeForEncounter(encounter); if (visitType != null) { Visit visit = new Visit(); visit.setStartDatetime(encounter.getEncounterDatetime()); visit.setLocation(encounter.getLocation()); visit.setPatient(encounter.getPatient()); visit.setVisitType(visitType); visit.setStopDatetime(OpenmrsUtil.getLastMomentOfDay(encounter.getEncounterDatetime())); visit.addEncounter(encounter); } } }

Target:
public void beforeCreateEncounter(Encounter encounter) { if (encounter.getVisit() != null) return; if (encounter.getLocation() == null) { return; } Date when = encounter.getEncounterDatetime(); if (when == null) { when = new Date(); } List<Patient> patient = Collections.singletonList(encounter.getPatient()); List<Visit> candidates = visitService.getVisits(null, patient, null, null, null, when, null, null, null, true, false); if (candidates != null) { for (Visit candidate : candidates) { if (adtService.isSuitableVisit(candidate, encounter.getLocation(), when)) { candidate.addEncounter(encounter); return; } } } if (StringUtils.isNotBlank(administrationService.getGlobalProperty(EmrApiConstants.GP_VISIT_ASSIGNMENT_HANDLER_ENCOUNTER_TYPE_TO_VISIT_TYPE_MAP))) { VisitType visitType = getEncounterTypetoVisitTypeMapper().getVisitTypeForEncounter(encounter); if (visitType != null) { Visit visit = new Visit(); visit.setStartDatetime(encounter.getEncounterDatetime()); visit.setLocation(adtService.getLocationThatSupportsVisits(encounter.getLocation())); visit.setPatient(encounter.getPatient()); visit.setVisitType(visitType); if (!DateUtils.isSameDay(encounter.getEncounterDatetime(), new Date())) { visit.setStopDatetime(OpenmrsUtil.getLastMomentOfDay(encounter.getEncounterDatetime())); } visit.addEncounter(encounter); } } }
Source:
public static String chooseDriverType(String metaConnectString) throws InvalidOptionsException { String scheme = metaConnectString; if (scheme.startsWith(JdbcDrivers.MYSQL.getSchemePrefix())) { return JdbcDrivers.MYSQL.getDriverClass(); } else if (scheme.startsWith(JdbcDrivers.POSTGRES.getSchemePrefix())) { return JdbcDrivers.POSTGRES.getDriverClass(); } else if (scheme.startsWith(JdbcDrivers.HSQLDB.getSchemePrefix())) { return JdbcDrivers.HSQLDB.getDriverClass(); } else if (scheme.startsWith(JdbcDrivers.ORACLE.getSchemePrefix())) { return JdbcDrivers.ORACLE.getDriverClass(); } else if (scheme.startsWith(JdbcDrivers.DB2.getSchemePrefix())) { return JdbcDrivers.DB2.getDriverClass(); } else if (scheme.startsWith(JdbcDrivers.SQLSERVER.getSchemePrefix())) { return JdbcDrivers.SQLSERVER.getDriverClass(); } else { throw new InvalidOptionsException("current meta-connect scheme not compatible with metastore"); } }

Target:
private String chooseDriverType(String metaConnectString) throws InvalidOptionsException { for (JdbcDrivers driver : SUPPORTED_DRIVERS) { if (metaConnectString.startsWith(driver.getSchemePrefix())) { return driver.getDriverClass(); } } throw new InvalidOptionsException("current meta-connect scheme not compatible with metastore"); }
Source:
public void onDropItemEvent(DropItemEvent event, EntityRef itemEntity, ItemComponent itemComponent) { for (Component component : itemComponent.pickupPrefab.iterateComponents()) { Component componentCopy = library.getComponentLibrary().copy(component); if (componentCopy instanceof LocationComponent) { ((LocationComponent) componentCopy).setWorldPosition(event.getPosition()); } itemEntity.addOrSaveComponent(componentCopy); } if (!itemEntity.hasComponent(LocationComponent.class)) { itemEntity.addComponent(new LocationComponent(event.getPosition())); } itemEntity.getComponent(ItemComponent.class).pickableUp = false; long timeToPickUp = itemEntity.getComponent(ItemComponent.class).pickUpTime; delayManager.addDelayedAction(itemEntity, DELAYED_PICKUP_ACTION_ID, timeToPickUp); }

Target:
public void onDropItemEvent(DropItemEvent event, EntityRef itemEntity, ItemComponent itemComponent) { for (Component component : itemComponent.pickupPrefab.iterateComponents()) { Component componentCopy = library.getComponentLibrary().copy(component); if (componentCopy instanceof LocationComponent) { ((LocationComponent) componentCopy).setWorldPosition(event.getPosition()); } itemEntity.addOrSaveComponent(componentCopy); } if (!itemEntity.hasComponent(LocationComponent.class)) { itemEntity.addComponent(new LocationComponent(event.getPosition())); } }
Source:
@NonNull private String processLinkTextWithAlphaReferences(@NonNull String linkText) { boolean isLowercase = linkText.contains("lower"); if (linkText.contains("alpha")) { String[] strings = linkText.split(" "); String alphaReference = StringUtil.getAlphaStringForNumber(Integer.valueOf(strings[strings.length - 1].replace("]", ""))); alphaReference = isLowercase ? alphaReference.toLowerCase() : alphaReference; return getContext().getString(R.string.add_square_brackets_to_string, alphaReference); } return linkText; }

Target:
@NonNull private String processLinkTextWithAlphaReferences(@NonNull String linkText) { boolean isLowercase = linkText.contains("lower"); if (linkText.contains("alpha ")) { String[] strings = linkText.split(" "); String alphaReference = StringUtil.getBase26String(Integer.valueOf(strings[strings.length - 1].replace("]", "")) - 1); alphaReference = isLowercase ? alphaReference.toLowerCase() : alphaReference; return getContext().getString(R.string.add_square_brackets_to_string, alphaReference); } return linkText; }
Source:
private StorageDevice getStorageDevices(Map<String, Object> map) { StorageDevice storageDevice = new StorageDevice(); storageDevice.setName(map.get(NAME).toString()); storageDevice.setSize((long) (map.containsKey(SIZE) ? Double.valueOf(map.get(SIZE).toString()) : 0)); storageDevice.setDevPath(map.containsKey(DEV_PATH) ? map.get(DEV_PATH).toString() : null); storageDevice.setCanCreateBrick(map.containsKey(CREATE_BRICK) ? Boolean.valueOf(map.get(CREATE_BRICK).toString()) : Boolean.FALSE); storageDevice.setFsType(map.containsKey(FILE_SYSTEM_TYPE) && !map.get(FILE_SYSTEM_TYPE).toString().isEmpty() ? map.get(FILE_SYSTEM_TYPE) .toString() : null); storageDevice.setMountPoint(map.containsKey(MOUNT_POINT) && !map.get(MOUNT_POINT).toString().isEmpty() ? map.get(MOUNT_POINT) .toString() : null); storageDevice.setDevUuid(map.containsKey(DEV_UUID) && !map.get(DEV_UUID).toString().isEmpty() ? map.get(DEV_UUID) .toString() : null); storageDevice.setFsUuid(map.containsKey(UUID) && !map.get(UUID).toString().isEmpty() ? map.get(UUID) .toString() : null); storageDevice.setDescription(map.containsKey(MODEL) ? map.get(MODEL).toString() : null); storageDevice.setDevType(map.containsKey(BUS) && !map.get(BUS).toString().isEmpty() ? map.get(BUS).toString() : null); return storageDevice; }

Target:
private StorageDevice getStorageDevices(Map<String, Object> map) { StorageDevice storageDevice = new StorageDevice(); storageDevice.setName(map.get(NAME).toString()); storageDevice.setSize((long) (map.containsKey(SIZE) ? Double.valueOf(map.get(SIZE).toString()) : 0)); storageDevice.setDevPath(map.containsKey(DEV_PATH) ? map.get(DEV_PATH).toString() : null); storageDevice.setCanCreateBrick(map.containsKey(CREATE_BRICK) ? Boolean.valueOf(map.get(CREATE_BRICK).toString()) : Boolean.FALSE); storageDevice.setFsType(map.containsKey(FILE_SYSTEM_TYPE) && !StringUtils.isBlank(map.get(FILE_SYSTEM_TYPE).toString()) ? map.get(FILE_SYSTEM_TYPE) .toString() : null); storageDevice.setMountPoint(map.containsKey(MOUNT_POINT) && !StringUtils.isBlank(map.get(MOUNT_POINT).toString()) ? map.get(MOUNT_POINT) .toString() : null); storageDevice.setDevUuid(map.containsKey(DEV_UUID) && !StringUtils.isBlank(map.get(DEV_UUID).toString()) ? map.get(DEV_UUID) .toString() : null); storageDevice.setFsUuid(map.containsKey(UUID) && !StringUtils.isBlank(map.get(UUID).toString()) ? map.get(UUID) .toString() : null); storageDevice.setDescription(map.containsKey(MODEL) ? map.get(MODEL).toString() : null); storageDevice.setDevType(map.containsKey(BUS) && !StringUtils.isBlank(map.get(BUS).toString()) ? map.get(BUS) .toString() : null); return storageDevice; }
Source:
public void onBeforeWrite(RepositoryStreamWriteContext ctx) throws IOException { RepositoryPath repositoryPath = (RepositoryPath) ctx.getPath(); logger.debug(String.format("Writing [%s]", repositoryPath)); if (!RepositoryFiles.isArtifact(repositoryPath)) { return; } RepositoryData repository = repositoryPath.getRepository(); String storageId = repository.getStorage().getId(); String repositoryId = repository.getId(); ArtifactEntry artifactEntry = provideArtifactEntry(repositoryPath); if (!shouldStoreArtifactEntry(artifactEntry)) { return; } artifactEntry.setStorageId(storageId); artifactEntry.setRepositoryId(repositoryId); ArtifactCoordinates coordinates = RepositoryFiles.readCoordinates(repositoryPath); artifactEntry.setArtifactCoordinates(coordinates); Date now = new Date(); artifactEntry.setCreated(now); artifactEntry.setLastUpdated(now); artifactEntry.setLastUsed(now); repositoryPath.artifactEntry = artifactEntry; }

Target:
public void onBeforeWrite(RepositoryStreamWriteContext ctx) throws IOException { RepositoryPath repositoryPath = (RepositoryPath) ctx.getPath(); logger.debug(String.format("Writing [%s]", repositoryPath)); if (!RepositoryFiles.isArtifact(repositoryPath)) { return; } Repository repository = repositoryPath.getRepository(); String storageId = repository.getStorage().getId(); String repositoryId = repository.getId(); ArtifactEntry artifactEntry = provideArtifactEntry(repositoryPath); if (!shouldStoreArtifactEntry(artifactEntry)) { return; } artifactEntry.setStorageId(storageId); artifactEntry.setRepositoryId(repositoryId); ArtifactCoordinates coordinates = RepositoryFiles.readCoordinates(repositoryPath); artifactEntry.setArtifactCoordinates(coordinates); Date now = new Date(); artifactEntry.setCreated(now); artifactEntry.setLastUpdated(now); artifactEntry.setLastUsed(now); repositoryPath.artifactEntry = artifactEntry; }
Source:
protected void executeCommand() { for (Guid templateGuid : getTemplatesList()) { if (getTagId() != null && DbFacade.getInstance().getTagDao().getTagTemplateByTagIdAndByTemplateId(getTagId(), templateGuid) != null) { VmTemplate template = DbFacade.getInstance().getVmTemplateDao().get(templateGuid); if (template != null) { appendCustomValue("TemplatesNames", template.getName(), ", "); } DbFacade.getInstance().getTagDao().detachTemplateFromTag(getTagId(), templateGuid); setSucceeded(true); } } }

Target:
protected void executeCommand() { for (Guid templateGuid : getTemplatesList()) { if (DbFacade.getInstance().getTagDao().getTagTemplateByTagIdAndByTemplateId(getTagId(), templateGuid) != null) { VmTemplate template = DbFacade.getInstance().getVmTemplateDao().get(templateGuid); if (template != null) { appendCustomValue("TemplatesNames", template.getName(), ", "); DbFacade.getInstance().getTagDao().detachTemplateFromTag(getTagId(), templateGuid); } } } setSucceeded(true); }
Source:
public SWTBotTreeItem select(final String... items) { new SWTBotTree(tree).waitForEnabled(); if (items.length > 1) { assertMultiSelect(); } final List<String> nodes = Arrays.asList(items); Assert.isTrue(getNodes().containsAll(nodes)); syncExec(new VoidResult() { public void run() { ArrayList<TreeItem> selection = new ArrayList<TreeItem>(); for (String item : items) { SWTBotTreeItem si = getTreeItem(item); selection.add(si.widget); } tree.setFocus(); tree.setSelection(selection.toArray(new TreeItem[selection.size()])); } }); notifySelect(); return this; }

Target:
public SWTBotTreeItem select(final String... items) { waitForEnabled(); if (items.length > 1) { assertMultiSelect(); } final List<String> nodes = Arrays.asList(items); Assert.isTrue(getNodes().containsAll(nodes)); syncExec(new VoidResult() { public void run() { ArrayList<TreeItem> selection = new ArrayList<TreeItem>(); for (String item : items) { SWTBotTreeItem si = getTreeItem(item); selection.add(si.widget); } tree.setFocus(); tree.setSelection(selection.toArray(new TreeItem[selection.size()])); } }); notifySelect(); return this; }
Source:
public static IProject[] getProjectsContaining(Repository repository, Collection<String> fileList) throws CoreException { Set<IProject> result = new HashSet<IProject>(); Set<File> handledPaths = new TreeSet<File>(); for (String member : fileList) { File file = new File(repository.getWorkTree(), member); if (handledPaths.contains(file)) continue; IContainer container = findContainerFast(file); if (container != null && container instanceof IProject) result.add((IProject) container); handledPaths.add(file); } return result.toArray(new IProject[result.size()]); }

Target:
public static IProject[] getProjectsContaining(Repository repository, Collection<String> fileList) throws CoreException { Set<IProject> result = new LinkedHashSet<IProject>(); File workTree = repository.getWorkTree(); for (String member : fileList) { File file = new File(workTree, member); IContainer container = findContainerFast(file); if (container instanceof IProject) result.add((IProject) container); } return result.toArray(new IProject[result.size()]); }
Source:
public void addToEmitMsgs(long offset) { this.emittedOffsets.add(offset); this.latestEmittedOffset = offset; }

Target:
public void addToEmitMsgs(long offset) { this.emittedOffsets.add(offset); this.latestEmittedOffset = Math.max(latestEmittedOffset, offset); }