auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void setup() throws Exception { super.setup(); final DB dbx = db; dbx.createCollection(COLL_NAME, null); controller = new MongoCRUDController(null, new DBResolver() { @Override public DB get(MongoDataStore store) { return dbx; } @Override public MongoConfiguration getConfiguration(MongoDataStore store) { return null; } @Override public List<MongoConfiguration> getConfigurations() { return null; } }); }

Target:
public void setup() throws Exception { super.setup(); final DB dbx = db; dbx.createCollection(COLL_NAME, null); controller = new MongoCRUDController(null, new DBResolver() { @Override public DB get(MongoDataStore store) { return dbx; } @Override public MongoConfiguration getConfiguration(MongoDataStore store) { return null; } @Override public Collection<MongoConfiguration> getConfigurations() { return null; } }); }
Source:
protected List<String> getHostNames(Label label) { ArrayList<String> hostNames = new ArrayList<>(); if (!entitiesNameMap.isEmpty() && !label.getHosts().isEmpty()) { label.getHosts().forEach(id -> { String hostName = entitiesNameMap.get(id); if (hostName != null && !hostName.isEmpty()) { hostNames.add(hostName); } }); Collections.sort(hostNames); } return hostNames; }

Target:
protected List<String> getHostNames(Label label) { List<String> hostNames = new ArrayList<>(); if (!entitiesNameMap.isEmpty() && !label.getHosts().isEmpty()) { label.getHosts().forEach(id -> { String hostName = entitiesNameMap.get(id); if (hostName != null && !hostName.isEmpty()) { hostNames.add(hostName); } }); Collections.sort(hostNames); } return hostNames; }
Source:
public void setupJetifier(String version) { if (!version.equals(JetifierExtension.JETIFIER_VERSION)) { LOG.warn("Using jetifier version other than %s; This might result in problems with the tool", JetifierExtension.JETIFIER_VERSION); } Configuration jetifierConfig = project.getConfigurations().maybeCreate(JETIFIER_DEPS_CONFIG); DependencyHandler handler = project.getDependencies(); JETIFIER_MODULES .stream() .map(module -> String.format("%s:%s:%s", JETIFIER_GROUP, module, version)) .forEach(dependency -> handler.add(JETIFIER_DEPS_CONFIG, dependency)); handler.add(JETIFIER_DEPS_CONFIG, "commons-cli:commons-cli:1.3.1"); dependencies = new DependencyCache(project, ProjectUtil.getDependencyManager(project)).build(jetifierConfig); }

Target:
public void setupJetifier(String version) { if (!version.equals(JetifierExtension.DEFAULT_JETIFIER_VERSION)) { LOG.warn("Using jetifier version other than %s; This might result in problems with the tool", JetifierExtension.DEFAULT_JETIFIER_VERSION); } Configuration jetifierConfig = project.getConfigurations().maybeCreate(JETIFIER_DEPS_CONFIG); DependencyHandler handler = project.getDependencies(); JETIFIER_MODULES .stream() .map(module -> String.format("%s:%s:%s", JETIFIER_GROUP, module, version)) .forEach(dependency -> handler.add(JETIFIER_DEPS_CONFIG, dependency)); handler.add(JETIFIER_DEPS_CONFIG, COMMONS_CLI_DEP); dependencies = new DependencyCache(project, ProjectUtil.getDependencyManager(project)).build(jetifierConfig); }
Source:
public Tuple(Object... values) { this.values = Arrays.asList(values); }

Target:
public Tuple(Object... values) { this.values = list(values); }
Source:
private void validateListenerConfig() { if (!eventListenerConfigurations.isEmpty() && eventNotifier instanceof DisabledCacheEventNotificationService) { if (orderedExecutor == null && unOrderedExecutor == null) { throw new IllegalArgumentException("Listeners will not work unless exceutors or EventDispatcher is configured."); } } }

Target:
private void validateListenerConfig() { if (!eventListenerConfigurations.isEmpty() && eventDispatcher instanceof DisabledCacheEventNotificationService) { if (orderedExecutor == null && unOrderedExecutor == null) { throw new IllegalArgumentException("Listeners will not work unless Executors or EventDispatcher is configured."); } } }
Source:
protected static boolean canAttachPrestartedVmToUser(Guid vmId, boolean isStatefulPool, List<String> messages) { return !vmAssignedToUser(vmId, messages) && (isStatefulPool || vmIsRunningStateless(vmId)); }

Target:
protected static boolean canAttachPrestartedVmToUser(Guid vmId, boolean isStatefulPool, List<String> messages) { return !vmAssignedToUser(vmId, messages) && (isStatefulPool && !vmIsStartedByRunOnce(vmId) || vmIsRunningStateless(vmId)); }
Source:
public boolean hit(World world, int x, int y, int z, Direction side, GameProfile profile) { EntityPlayerMP player = setUpPlayer(profile, world, x, y, z, null); EnumFacing facing = DirectionFacingProvider.directionMap.get(side); boolean result = onBlockClicked(player, new BlockPos(x, y, z), facing); tearDownPlayer(player); return result; }

Target:
public boolean hit(World world, int x, int y, int z, Direction side, GameProfile profile) { return setUpPlayer(profile, world, x, y, z, null, player -> { EnumFacing facing = DirectionFacingProvider.directionMap.get(side); return onBlockClicked(player, new BlockPos(x, y, z), facing); }); }
Source:
public static void registerServerLifeCycleOperationsTransformers(ResourceTransformationDescriptionBuilder builder) { builder.addOperationTransformationOverride(SUSPEND_SERVERS).setReject().end() .addOperationTransformationOverride(RESUME_SERVERS).setReject().end() .addOperationTransformationOverride(STOP_SERVERS) .setCustomOperationTransformer((context, address, operation) -> { if (operation.hasDefined(ModelDescriptionConstants.TIMEOUT)) { return new OperationTransformer.TransformedOperation(operation, new OperationRejectionPolicy() { @Override public boolean rejectOperation(ModelNode preparedResult) { return true; } @Override public String getFailureDescription() { return ControllerLogger.ROOT_LOGGER.rejectedOperationAttributes(operation, Collections.singleton(TIMEOUT.getName())); } }, OperationResultTransformer.ORIGINAL_RESULT); } return new OperationTransformer.TransformedOperation(operation, OperationResultTransformer.ORIGINAL_RESULT); }) .end(); }

Target:
public static void registerServerLifeCycleOperationsTransformers(ResourceTransformationDescriptionBuilder builder) { builder.addOperationTransformationOverride(SUSPEND_SERVERS).setReject().end() .discardOperations(RESUME_SERVERS) .addOperationTransformationOverride(STOP_SERVERS) .addRejectCheck(RejectAttributeChecker.DEFINED, TIMEOUT) .end(); }
Source:
public void locatorLauncherUsesLog4jConfigurationFile() throws Exception { ProcessBuilder processBuilder = new ProcessBuilder() .redirectErrorStream(true) .redirectOutput(stdoutFile.toFile()) .directory(temporaryFolder.getRoot()) .command("java", "-Dgemfire.enable-cluster-configuration=false", "-Dgemfire.jmx-manager=false", "-Dgemfire.jmx-manager-start=false", "-Djava.awt.headless=true", "-Dlog4j.configurationFile=" + configFile.toAbsolutePath(), "-cp", geodeDependencies.toFile().getAbsolutePath(), "org.apache.geode.distributed.LocatorLauncher", "start", LOCATOR_NAME, "--port", String.valueOf(locatorPort)); System.out.println("Environment: " + System.getenv()); System.out.println("Launching command: " + processBuilder.command()); locator = processBuilder .start(); assertThat(locator.isAlive()).isTrue(); await().untilAsserted(() -> { assertThat(locatorLogFile) .doesNotExist(); assertThat(pulseLogFile) .doesNotExist(); LogFileAssert.assertThat(stdoutFile.toFile()) .exists() .contains( "Unable to start management service: Could not start the manager because the gemfire property \"jmx-manager\" is false.") .contains("Starting server location for Distribution Locator") .doesNotContain("geode-pulse war file was not found") .doesNotContain("java.lang.IllegalStateException: No factory method found for class"); }); }

Target:
public void locatorLauncherUsesLog4jConfigurationFile() throws Exception { ProcessBuilder processBuilder = new ProcessBuilder() .redirectErrorStream(true) .redirectOutput(stdoutFile.toFile()) .directory(temporaryFolder.getRoot()) .command(javaBin.toFile().getAbsolutePath(), "-Dgemfire.enable-cluster-configuration=false", "-Dgemfire.jmx-manager=false", "-Dgemfire.jmx-manager-start=false", "-Djava.awt.headless=true", "-Dlog4j.configurationFile=" + configFile.toAbsolutePath(), "-cp", geodeDependencies.toFile().getAbsolutePath(), "org.apache.geode.distributed.LocatorLauncher", "start", LOCATOR_NAME, "--port", String.valueOf(locatorPort)); System.out.println("Environment: " + System.getenv()); System.out.println("Launching command: " + processBuilder.command()); locator = processBuilder .start(); assertThat(locator.isAlive()).isTrue(); await().untilAsserted(() -> { assertThat(locatorLogFile) .as(locatorLogFile.toFile().getAbsolutePath()) .doesNotExist(); assertThat(pulseLogFile) .as(pulseLogFile.toFile().getAbsolutePath()) .doesNotExist(); LogFileAssert.assertThat(stdoutFile.toFile()) .as(stdoutFile.toFile().getAbsolutePath()) .exists() .contains( "Unable to start management service: Could not start the manager because the gemfire property \"jmx-manager\" is false.") .contains("Starting server location for Distribution Locator") .doesNotContain("geode-pulse war file was not found") .doesNotContain("java.lang.IllegalStateException: No factory method found for class"); }); }
Source:
public RelationshipView(String type, Doi doi, String title) { this.type = Objects.requireNonNull(type); this.doi = Objects.requireNonNull(doi).getName(); this.title = title; }

Target:
public RelationshipView(String type, Doi doi, String title) { this.type = Objects.requireNonNull(type); this.doi = doi.getName(); this.title = Objects.requireNonNull(title); }
Source:
private static void logNoMatchClasses(Collection<IClassCoverage> noMatchClasses) { if (!noMatchClasses.isEmpty()) { LOG.warn("The following class(es) did not match with execution data:"); for (IClassCoverage iClassCoverage : noMatchClasses) { LOG.warn(String.format("> '%s'", iClassCoverage.getName())); } LOG.warn("In order to have accurate coverage measures, the same class files must be used as at runtime for report generation."); } }

Target:
private static void logNoMatchClasses(Collection<IClassCoverage> noMatchClasses) { if (noMatchClasses.isEmpty()) { return; } LOG.warn("The following class(es) did not match with execution data:"); for (IClassCoverage iClassCoverage : noMatchClasses) { LOG.warn(String.format("> '%s'", iClassCoverage.getName())); } LOG.warn("In order to have accurate coverage measures, the same class files must be used as at runtime for report generation."); }
Source:
public static ObjectFactory loadObjectFactory(ClassFinder classFinder) { ObjectFactory objectFactory; try { Reflections reflections = new Reflections(classFinder); objectFactory = reflections.instantiateExactlyOneSubclass(ObjectFactory.class, "cucumber.runtime", new Class[0], new Object[0]); } catch (CucumberException ce) { logger.warn(getMultipleObjectFactoryLogMessage()); objectFactory = new DefaultJavaObjectFactory(); } return objectFactory; }

Target:
public static ObjectFactory loadObjectFactory(ClassFinder classFinder) { ObjectFactory objectFactory; try { Reflections reflections = new Reflections(classFinder); objectFactory = reflections.instantiateExactlyOneSubclass(ObjectFactory.class, "cucumber.runtime", new Class[0], new Object[0]); } catch (TooManyInstancesException e) { System.out.println(getMultipleObjectFactoryLogMessage()); objectFactory = new DefaultJavaObjectFactory(); } catch (NoInstancesException e) { objectFactory = new DefaultJavaObjectFactory(); } return objectFactory; }
Source:
protected void scanAndAggregate( final PooledTopNParams params, final int[] positions, final BufferAggregator[] theAggregators, final int numProcessed ) { final Cursor cursor = params.getCursor(); if (theAggregators.length == 1) { BufferAggregator aggregator = theAggregators[0]; if (cursor instanceof HistoricalCursor && aggregator instanceof SimpleDoubleBufferAggregator) { if (specializeHistoricalSingleValueDimSelector1SimpleDoubleAggPooledTopN && params.getDimSelector() instanceof SingleValueHistoricalDimensionSelector && ((SimpleDoubleBufferAggregator) aggregator).getSelector() instanceof HistoricalFloatColumnSelector) { scanAndAggregateHistorical1SimpleDoubleAgg( params, positions, (SimpleDoubleBufferAggregator) aggregator, cursor, defaultHistoricalSingleValueDimSelector1SimpleDoubleAggScanner ); BaseQuery.checkInterrupted(); return; } if (specializeHistorical1SimpleDoubleAggPooledTopN && params.getDimSelector() instanceof HistoricalDimensionSelector && ((SimpleDoubleBufferAggregator) aggregator).getSelector() instanceof HistoricalFloatColumnSelector) { scanAndAggregateHistorical1SimpleDoubleAgg( params, positions, (SimpleDoubleBufferAggregator) aggregator, cursor, defaultHistorical1SimpleDoubleAggScanner ); BaseQuery.checkInterrupted(); return; } } if (specializeGeneric1AggPooledTopN) { scanAndAggregateGeneric1Agg(params, positions, aggregator, cursor); BaseQuery.checkInterrupted(); return; } } if (specializeGeneric2AggPooledTopN && theAggregators.length == 2) { scanAndAggregateGeneric2Agg(params, positions, theAggregators, cursor); BaseQuery.checkInterrupted(); return; } scanAndAggregateDefault(params, positions, theAggregators); BaseQuery.checkInterrupted(); }

Target:
protected void scanAndAggregate( final PooledTopNParams params, final int[] positions, final BufferAggregator[] theAggregators, final int numProcessed ) { for (ScanAndAggregate specializedScanAndAggregate : specializedScanAndAggregateImplementations) { if (specializedScanAndAggregate.scanAndAggregate(params, positions, theAggregators)) { BaseQuery.checkInterrupted(); return; } } scanAndAggregateDefault(params, positions, theAggregators); BaseQuery.checkInterrupted(); }
Source:
public void testFunction() { tableEnv.executeSql(String.format("create function my_abs as '%s'", GenericUDFAbs.class.getName())); List<Row> functions = Lists.newArrayList(tableEnv.executeSql("show functions").collect()); assertTrue(functions.toString().contains("my_abs")); tableEnv.executeSql("drop function my_abs"); assertFalse(hiveCatalog.functionExists(new ObjectPath("default", "my_abs"))); tableEnv.executeSql("drop function if exists foo"); }

Target:
public void testFunction() throws Exception { tableEnv.executeSql(String.format("create function my_abs as '%s'", GenericUDFAbs.class.getName())); List<Row> functions = Lists.newArrayList(tableEnv.executeSql("show functions").collect()); assertTrue(functions.toString().contains("my_abs")); tableEnv.executeSql("create table src(x int)"); waitForJobFinish(tableEnv.executeSql("insert into src values (1),(-1)")); assertEquals("[1, 1]", queryResult(tableEnv.sqlQuery("select my_abs(x) from src")).toString()); tableEnv.executeSql("drop function my_abs"); assertFalse(hiveCatalog.functionExists(new ObjectPath("default", "my_abs"))); tableEnv.executeSql("drop function if exists foo"); }
Source:
private Set<PersistentResource> upsertObjects(Environment context) { if(context.ids.isPresent()) { throw new BadRequestException("UPSERT must not include ids"); } if(!context.data.isPresent()) { throw new BadRequestException("UPSERT must include data argument"); } Class<?> entityClass; EntityDictionary dictionary = context.requestScope.getDictionary(); if(context.isRoot()) { entityClass = dictionary.getEntityClass(context.field.getName()); } else { entityClass = dictionary.getParameterizedType(context.parentResource.getResourceClass(), context.field.getName()); } Set<PersistentResource> upsertedObjects = new HashSet(); for(Map<String, Object> input : context.data.get()) { upsertedObjects.addAll(graphWalker(input, this::upsertObject, entityClass, context.requestScope)); } for(Map<String, Object> input : context.data.get()) { graphWalker(input, this::updateRelationship, entityClass, context.requestScope); } if(!context.isRoot()) { for(PersistentResource obj : upsertedObjects) { context.parentResource.addRelation(context.field.getName(), obj); } } return upsertedObjects; }

Target:
private Set<PersistentResource> upsertObjects(Environment context) { if(context.ids.isPresent()) { throw new BadRequestException("UPSERT must not include ids"); } if(!context.data.isPresent()) { throw new BadRequestException("UPSERT must include data argument"); } Class<?> entityClass; EntityDictionary dictionary = context.requestScope.getDictionary(); if(context.isRoot()) { entityClass = dictionary.getEntityClass(context.field.getName()); } else { entityClass = dictionary.getParameterizedType(context.parentResource.getResourceClass(), context.field.getName()); } Optional<Entity> parentEntity; if(!context.isRoot()) { parentEntity = Optional.of(new Entity(Optional.empty(), null, context.parentResource.getResourceClass(), context.requestScope)); } else { parentEntity = Optional.empty(); } Set<Entity> entitySet = new HashSet<>(); for(Map<String, Object> input : context.data.get()) { entitySet.add(new Entity(parentEntity, input, entityClass, context.requestScope)); } for(Entity entity : entitySet) { graphWalker(entity, this::upsertObject); } for(Entity entity : entitySet) { graphWalker(entity, this::updateRelationship); if (!context.isRoot()) { context.parentResource.addRelation(context.field.getName(), entity.toPersistentResource()); } } return entitySet.stream().map(Entity::toPersistentResource).collect(Collectors.toSet()); }
Source:
public void onMapClick(LatLng latLng) { Log.d(TAG, "Map clicked"); if (mMarkerData.getFocus() != null) { mMarkerData.removeFocus(); } Location location = LocationUtil.makeLocation(latLng.latitude, latLng.longitude); mOnFocusChangedListener.onFocusChanged(null, null, location); }

Target:
public void onMapClick(LatLng latLng) { Log.d(TAG, "Map clicked"); if (mMarkerData.getFocus() != null) { mMarkerData.removeFocus(); } Location location = MapHelpV2.makeLocation(latLng); mOnFocusChangedListener.onFocusChanged(null, null, location); }
Source:
private boolean isTenantSpecificTable() { return (getType() == USER || getType() == SYSTEM) && getParentTableName() != null; }

Target:
public boolean isTenantSpecificTable() { return getType() == USER && getBaseTableName() != null; }
Source:
public void testBatchRunOnNonExistentSpecificPractitioner() { assertLinkCount(2); myEmpiProviderR4.clearEmpiLinks(null); try { myEmpiProviderR4.empiBatchPractitionerInstance(new IdType("Practitioner/999"), null); fail(); } catch (ResourceNotFoundException e){} }

Target:
public void testBatchRunOnNonExistentSpecificPractitioner() { myEmpiProviderR4.clearEmpiLinks(null); try { myEmpiProviderR4.empiBatchPractitionerInstance(new IdType("Practitioner/999"), null); fail(); } catch (ResourceNotFoundException e){} }
Source:
public void acceptsNoContentLengthOnClosedConnection() throws Exception { final String text = "Close Test"; final Socket socket = Mockito.mock(Socket.class); Mockito.when(socket.getInputStream()).thenReturn( new ByteArrayInputStream(Joiner.on("\r\n").join( "POST / HTTP/1.1", "Host: localhost", "Connection: Close", "", "hi" ).getBytes() ) ); Mockito.when(socket.getLocalAddress()).thenReturn( InetAddress.getLocalHost() ); Mockito.when(socket.getLocalPort()).thenReturn(0); Mockito.when(socket.getInetAddress()).thenReturn( InetAddress.getLocalHost() ); Mockito.when(socket.getPort()).thenReturn(0); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); Mockito.when(socket.getOutputStream()).thenReturn(baos); new BkReuse(new BkBasic(new TkText(text))).accept(socket); MatcherAssert.assertThat( baos.toString(), Matchers.containsString(text) ); }

Target:
public void acceptsNoContentLengthOnClosedConnection() throws Exception { final String text = "Close Test"; final Socket socket = Mockito.mock(Socket.class); Mockito.when(socket.getInputStream()).thenReturn( new ByteArrayInputStream( Joiner.on("\r\n").join( "POST / HTTP/1.1", "Host: localhost", "Connection: Close", "", "hi" ).getBytes("UTF-8") ) ); Mockito.when(socket.getLocalAddress()).thenReturn( InetAddress.getLocalHost() ); Mockito.when(socket.getLocalPort()).thenReturn(0); Mockito.when(socket.getInetAddress()).thenReturn( InetAddress.getLocalHost() ); Mockito.when(socket.getPort()).thenReturn(0); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); Mockito.when(socket.getOutputStream()).thenReturn(baos); new BkReuse(new BkBasic(new TkText(text))).accept(socket); MatcherAssert.assertThat( baos.toString(), Matchers.containsString(text) ); }
Source:
public void init(Composite parent, String viewerName, ITmfTrace trace) { super.init(parent, viewerName); fCountInstance++; fInstanceNb = fCountInstance; fTrace = trace; fProcessAll = (trace instanceof TmfExperiment); initContent(parent); initInput(); fSash.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { internalDispose(); } }); }

Target:
public void init(Composite parent, String viewerName, ITmfTrace trace) { super.init(parent, viewerName); fCountInstance++; fInstanceNb = fCountInstance; fTrace = trace; fProcessAll = (trace instanceof TmfExperiment); initContent(parent); initInput(); fSash.addDisposeListener((e) -> { internalDispose(); }); }
Source:
protected void initializeModelHandlers(final TagListModel model) { super.initializeModelHandlers(model); model.getResetRequestedEvent().addListener(new IEventListener<EventArgs>() { @Override public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { if (model.getItems() == null) { return; } Iterator<TagModel> iterator = model.getItems().iterator(); if (iterator.hasNext()) { TagModel root = model.cloneTagModel(iterator.next()); updateDataProvider(Arrays.asList(root)); } } }); model.getPropertyChangedEvent().addListener(new IEventListener<PropertyChangedEventArgs>() { @Override public void eventRaised(Event<? extends PropertyChangedEventArgs> ev, Object sender, PropertyChangedEventArgs args) { if ("SelectedItems".equals(args.propertyName)) { if (getSelectionModel().getSelectedObject() != null) { TagActivationChangeEvent.fire(TagModelProvider.this, findRootNode(getSelectionModel().getSelectedObject())); } } } private TagModel findRootNode(TagModel tagModel) { if (tagModel.getParent() != null) { return findRootNode(tagModel.getParent()); } return tagModel; } }); }

Target:
protected void initializeModelHandlers(final TagListModel model) { super.initializeModelHandlers(model); model.getResetRequestedEvent().addListener(new IEventListener<EventArgs>() { @Override public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { if (model.getItems() == null) { return; } Iterator<TagModel> iterator = model.getItems().iterator(); if (iterator.hasNext()) { TagModel root = model.cloneTagModel(iterator.next()); updateDataProvider(Arrays.asList(root)); } } }); model.getPropertyChangedEvent().addListener(new IEventListener<PropertyChangedEventArgs>() { @Override public void eventRaised(Event<? extends PropertyChangedEventArgs> ev, Object sender, PropertyChangedEventArgs args) { if ("SelectedItems".equals(args.propertyName)) { if (getSelectionModel().getSelectedObject() != null) { TagActivationChangeEvent.fire(TagModelProvider.this, activeTagList( findRootNode(getSelectionModel().getSelectedObject()))); } } } private TagModel findRootNode(TagModel tagModel) { if (tagModel.getParent() != null) { return findRootNode(tagModel.getParent()); } return tagModel; } private List<TagModel> activeTagList(TagModel model) { List<TagModel> result = new ArrayList<>(); if (model.getSelection()) { result.add(model); } for (TagModel child : model.getChildren()) { result.addAll(activeTagList(child)); } return result; } }); }
Source:
public void validateValue(Reference target, Object providedValue, boolean validate) { if (providedValue == null) { return; } Input<?> input = toInject.get(target); if (input != null) { if (validate && target instanceof GeneratedReference) { validateValue(target, input.value(), providedValue); } toInject.remove(target); } if (ObjectType.ID == target.valueType().id()) { List<Reference> nestedGeneratedReferences = nestedReferenceByTopLevelColumnName.get(target.column().name()); if (nestedGeneratedReferences != null) { @SuppressWarnings("unchecked") Map<String, Object> objectMap = (Map<String, Object>) providedValue; for (var generatedColumn : nestedGeneratedReferences) { ColumnIdent generatedColumnIdent = generatedColumn.column(); assert (generatedColumnIdent.isTopLevel() == false) : "We should be checking only nested columns at this point"; Object byPathValue = Maps.getByPath(objectMap, generatedColumnIdent.path()); validateValue(generatedColumn, byPathValue, true); } } } }

Target:
public void validateValue(Reference target, Object providedValue, boolean validate) { if (providedValue == null) { return; } Input<?> input = toInject.remove(target); if (input != null) { if (validate && target instanceof GeneratedReference) { validateValue(target, input.value(), providedValue); } } if (ObjectType.ID == target.valueType().id()) { List<Reference> nestedGeneratedReferences = nestedReferenceByTopLevelColumnName.get(target.column().name()); if (nestedGeneratedReferences != null) { @SuppressWarnings("unchecked") Map<String, Object> objectMap = (Map<String, Object>) providedValue; for (var generatedColumn : nestedGeneratedReferences) { ColumnIdent generatedColumnIdent = generatedColumn.column(); assert (generatedColumnIdent.isTopLevel() == false) : "We should be checking only nested columns at this point"; Object byPathValue = Maps.getByPath(objectMap, generatedColumnIdent.path()); validateValue(generatedColumn, byPathValue, true); } } } }
Source:
private ReplicaSet getReplicaSetByLabel(String labelKey, String labelValue) throws IOException { ReplicaSetList rs = openShiftClient .extensions().replicaSets() .inNamespace(this.cheOpenShiftProjectName) .withLabel(labelKey, labelValue) .list(); if (rs.getItems().size() == 0) { LOG.warn("No ReplicaSet with label " + labelKey + "=" + labelValue + " could be found"); throw new IOException("No ReplicaSet with label " + labelKey + "=" + labelValue + " could be found"); } if (rs.getItems().size() > 1) { LOG.warn("Found more than one ReplicaSet with label " + labelKey + "=" + labelValue); throw new IOException("Found more than one ReplicaSet with label " + labelValue + "=" + labelValue); } return rs.getItems().get(0); }

Target:
private ReplicaSet getReplicaSetByLabel(String labelKey, String labelValue) throws IOException { ReplicaSetList replicaSetList = openShiftClient .extensions().replicaSets() .inNamespace(this.openShiftCheProjectName) .withLabel(labelKey, labelValue) .list(); List<ReplicaSet> items = replicaSetList.getItems(); if (items.isEmpty()) { LOG.warn("No ReplicaSet with label {}={} could be found", labelKey, labelValue); throw new IOException("No ReplicaSet with label " + labelKey + "=" + labelValue + " could be found"); } if (items.size() > 1) { LOG.warn("Found more than one ReplicaSet with label {}={}", labelKey, labelValue); throw new IOException("Found more than one ReplicaSet with label " + labelValue + "=" + labelValue); } return items.get(0); }
Source:
public void run() { try { service.executeOutOfBandManagementPowerOperation(host, powerOperation, null); } catch (Exception ignored) { } }

Target:
public void run() { try { service.executeOutOfBandManagementPowerOperation(host, powerOperation, null); } catch (Exception e) { LOG.warn(String.format("Out-of-band management background task operation=%s for host id=%d failed with: %s", powerOperation.name(), host.getId(), e.getMessage())); } }
Source:
public IRadioButton<T> getButtonFor(T value) { for (IRadioButton<T> b : getButtons()) { T radioValue = TypeCastUtility.castValue(b.getRadioValue(), getHolderType()); if (CompareUtility.equals(radioValue, value)) { return b; } } return null; }

Target:
public IRadioButton<T> getButtonFor(T value) { for (IRadioButton<T> b : getButtons()) { T radioValue = b.getRadioValue(); if (CompareUtility.equals(radioValue, value)) { return b; } } return null; }
Source:
protected void abortOldUploads() throws IOException { long oneDay = 1000L * 60 * 60 * 24; try { Date oneDayAgo = new Date(System.currentTimeMillis() - oneDay); transferManager.abortMultipartUploads(bucketName, oneDayAgo); } catch (AmazonServiceException e) { if (e.getStatusCode() == 400 || e.getStatusCode() == 404) { log.warn("Aborting old uploads is not supported by this provider"); return; } throw new IOException("Failed to abort old uploads", e); } }

Target:
protected void abortOldUploads() throws IOException { long oneDay = Duration.ofDays(1).toMillis(); try { Date oneDayAgo = new Date(System.currentTimeMillis() - oneDay); transferManager.abortMultipartUploads(bucketName, oneDayAgo); } catch (AmazonServiceException e) { if (e.getStatusCode() == 400 || e.getStatusCode() == 404) { log.warn("Aborting old uploads is not supported by this provider"); return; } throw new IOException("Failed to abort old uploads", e); } }
Source:
public void testConcurrentSRems() throws InterruptedException { int ENTRIES = 1000; List<String> masterSet = new ArrayList<>(); for (int i = 0; i < ENTRIES; i++) { masterSet.add("master-" + i); } jedis.sadd("master", masterSet.toArray(new String[] {})); AtomicLong sremmed1 = new AtomicLong(0); Runnable runnable1 = () -> { for (int i = 0; i < ENTRIES; i++) { sremmed1.addAndGet(jedis.srem("master", masterSet.get(i))); Thread.yield(); } }; AtomicLong sremmed2 = new AtomicLong(0); Runnable runnable2 = () -> { for (int i = ENTRIES; i < ENTRIES; i++) { sremmed2.addAndGet(jedis2.srem("master", masterSet.get(i))); Thread.yield(); } }; Thread thread1 = new Thread(runnable1); Thread thread2 = new Thread(runnable2); thread1.start(); thread2.start(); thread1.join(); thread2.join(); assertThat(jedis.smembers("master")).isEmpty(); assertThat(sremmed1.get() + sremmed2.get()).isEqualTo(ENTRIES); }

Target:
public void testConcurrentSRems() throws InterruptedException { int ENTRIES = 1000; List<String> masterSet = new ArrayList<>(); for (int i = 0; i < ENTRIES; i++) { masterSet.add("master-" + i); } jedis.sadd("master", masterSet.toArray(new String[] {})); AtomicLong sremmed1 = new AtomicLong(0); Runnable runnable1 = () -> { for (int i = 0; i < ENTRIES; i++) { sremmed1.addAndGet(jedis.srem("master", masterSet.get(i))); Thread.yield(); } }; AtomicLong sremmed2 = new AtomicLong(0); Runnable runnable2 = () -> { for (int i = 0; i < ENTRIES; i++) { sremmed2.addAndGet(jedis2.srem("master", masterSet.get(i))); Thread.yield(); } }; Thread thread1 = new Thread(runnable1); Thread thread2 = new Thread(runnable2); thread1.start(); thread2.start(); thread1.join(); thread2.join(); assertThat(jedis.smembers("master")).isEmpty(); assertThat(sremmed1.get() + sremmed2.get()).isEqualTo(ENTRIES); }
Source:
public UUID getIncarnationId() { return incarnationId; }

Target:
UUID getIncarnationId() { return incarnationId; }
Source:
protected List<File> copyBundlesToDeploy(ReloadContext context) throws BundleException { List<File> bundlesToDeploy = new ArrayList<>(); Path homePath = Framework.getRuntime().getHome().toPath(); Path destinationPath = homePath.resolve(context.bundlesDestination); destinationPath.toFile().mkdirs(); try { for (File bundle : context.bundlesToDeploy) { Path bundlePath = bundle.toPath(); if (!bundlePath.startsWith(destinationPath)) { if (bundle.isDirectory()) { bundlePath = ZipUtils.zipDirectory(bundlePath, destinationPath.resolve("hotreload-bundle-" + System.currentTimeMillis() + ".jar"), StandardCopyOption.REPLACE_EXISTING); } else { bundlePath = Files.copy(bundlePath, destinationPath.resolve(bundle.getName()), StandardCopyOption.REPLACE_EXISTING); } } bundlesToDeploy.add(bundlePath.toFile()); } return bundlesToDeploy; } catch (IOException e) { throw new BundleException("Unable to copy bundles to " + destinationPath, e); } }

Target:
protected List<File> copyBundlesToDeploy(ReloadContext context) throws BundleException { List<File> bundlesToDeploy = new ArrayList<>(); Path homePath = Framework.getRuntime().getHome().toPath(); Path destinationPath = homePath.resolve(context.bundlesDestination); try { Files.createDirectories(destinationPath); for (File bundle : context.bundlesToDeploy) { Path bundlePath = bundle.toPath(); if (!bundlePath.startsWith(destinationPath)) { if (Files.isDirectory(bundlePath)) { bundlePath = ZipUtils.zipDirectory(bundlePath, destinationPath.resolve("hotreload-bundle-" + System.currentTimeMillis() + ".jar"), StandardCopyOption.REPLACE_EXISTING); } else { bundlePath = Files.copy(bundlePath, destinationPath.resolve(bundle.getName()), StandardCopyOption.REPLACE_EXISTING); } } bundlesToDeploy.add(bundlePath.toFile()); } return bundlesToDeploy; } catch (IOException e) { throw new BundleException("Unable to copy bundles to " + destinationPath, e); } }
Source:
private static void loadExtensions(ModuleService moduleService, Map<String, Object> argMap) { ExtensionsManager extensionsManager = new ExtensionsManager(); Map<String, ExtensionProxy> proxies = moduleService.getContext().get(ModuleService.EXTENSIONS_MAP); List<File> files = (List<File>)argMap.get("extension-file"); if(files == null) { files = listFiles((String)argMap.get("extensions-dir"), "properties"); } for(File f : files) { proxies.put(extensionsManager.load(f), null); } for(String proxy : proxies.keySet()) { extensionsManager.initialize(proxy); proxies.put(proxy, extensionsManager.getExtensionByName(proxy)); } }

Target:
private static void loadExtensions(ModuleService moduleService, Map<String, Object> argMap) { ExtensionsManager extensionsManager = new ExtensionsManager(); Map<String, ExtensionProxy> proxies = moduleService.getContext().get(ModuleService.EXTENSIONS_MAP); List<File> files = (List<File>)argMap.get("extension-file"); if(files == null) { files = listFiles((String)argMap.get("extensions-dir"), "properties"); } for(File f : files) { proxies.put(extensionsManager.load(f), null); } for(Map.Entry<String, ExtensionProxy> entry : proxies.entrySet()) { extensionsManager.initialize(entry.getKey()); entry.setValue(extensionsManager.getExtensionByName(entry.getKey())); } }
Source:
public Optional<FieldSortExpectations<Double>> getFieldSortExpectations() { return Optional.of( new FieldSortExpectations<>( 1.01, 3.2, 5.1, Double.MIN_VALUE, 2.0, 4.00001, Double.MAX_VALUE ) ); }

Target:
public Optional<FieldSortExpectations<Double>> getFieldSortExpectations() { return Optional.of( new FieldSortExpectations<>( 1.01, 3.2, 5.1, -Double.MIN_VALUE, 2.0, 4.00001, Double.MAX_VALUE ) ); }
Source:
public DatasourceService() { metadataDomainRepositoryReal = PentahoSystem.get( IMetadataDomainRepository.class, PentahoSessionHolder.getSession() ); metadataDomainRepository = new PentahoMetadataDomainRepository( getRepository() ); mondrianCatalogService = PentahoSystem.get( IMondrianCatalogService.class, PentahoSessionHolder.getSession() ); repositoryFileAclAdapter = new RepositoryFileAclAdapter(); }

Target:
public DatasourceService() { metadataDomainRepository = PentahoSystem.get( IMetadataDomainRepository.class, PentahoSessionHolder.getSession() ); mondrianCatalogService = PentahoSystem.get( IMondrianCatalogService.class, PentahoSessionHolder.getSession() ); repositoryFileAclAdapter = new RepositoryFileAclAdapter(); }
Source:
private String getCurrentHost() { if (Server.isProductionServer()) { if ("".equals(appengineHost.get())) { String applicationVersionId = SystemProperty.applicationVersion.get(); String applicationId = SystemProperty.applicationId.get(); return applicationVersionId + "." + applicationId + ".appspot.com"; } else { return appengineHost.get(); } } else { return "localhost:8888"; } }

Target:
private String getCurrentHost() { if (Server.isProductionServer()) { if (StringUtils.isNullOrEmpty(appengineHost.get())) { String applicationVersionId = SystemProperty.applicationVersion.get(); String applicationId = SystemProperty.applicationId.get(); return applicationVersionId + "." + applicationId + ".appspot.com"; } else { return appengineHost.get(); } } else { return "localhost:8888"; } }
Source:
public boolean accept(InputFile inputFile) { if (!Php.KEY.equals(inputFile.language())) { return true; } String property = PhpPlugin.PHP_EXCLUSIONS_KEY; String[] excludedPatterns = this.configuration.getStringArray(property); String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(WildcardPattern.create(excludedPatterns), relativePath)) { LOG.debug("File [" + inputFile.uri() + "] is excluded by '" + property + "' property and will not be analyzed"); return false; } return true; }

Target:
public boolean accept(InputFile inputFile) { if (!Php.KEY.equals(inputFile.language())) { return true; } String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(WildcardPattern.create(excludedPatterns), relativePath)) { LOG.debug("File [" + inputFile.uri() + "] is excluded by '" + PhpPlugin.PHP_EXCLUSIONS_KEY + "' property and will not be analyzed"); return false; } return true; }
Source:
public Project getRootProject() { if (currentResource == null || currentResources == null) { EditorAgent editorAgent = editorAgentProvider.get(); if (editorAgent == null) { return null; } final EditorPartPresenter editor = editorAgent.getActiveEditor(); if (editor == null) { return null; } final VirtualFile file = editor.getEditorInput().getFile(); if (file instanceof SyntheticNode) { final Path projectPath = ((SyntheticNode)file).getProject(); for (Project project : projects) { if (project.getLocation().equals(projectPath)) { return project; } } } } if (currentResources[0] == null) { return null; } Project root = null; for (Project project : projects) { if (project.getLocation().isPrefixOf(currentResources[0].getLocation())) { root = project; } } if (root == null) { return null; } for (int i = 1; i < currentResources.length; i++) { if (!root.getLocation().isPrefixOf(currentResources[i].getLocation())) { return null; } } return root; }

Target:
public Project getRootProject() { if (currentResource == null || currentResources == null) { EditorAgent editorAgent = editorAgentProvider.get(); if (editorAgent == null) { return null; } final EditorPartPresenter editor = editorAgent.getActiveEditor(); if (editor == null) { return null; } final VirtualFile file = editor.getEditorInput().getFile(); if (file instanceof SyntheticNode) { final Path projectPath = ((SyntheticNode)file).getProject(); for (Project project : projects) { if (project.getLocation().equals(projectPath)) { return project; } } } } if (currentResource == null) { return null; } Project root = null; for (Project project : projects) { if (project.getLocation().isPrefixOf(currentResource.getLocation())) { root = project; } } if (root == null) { return null; } for (int i = 1; i < currentResources.length; i++) { if (!root.getLocation().isPrefixOf(currentResources[i].getLocation())) { return null; } } return root; }
Source:
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) { if (extensionKind == DifferenceKind.CHANGE) { extension.getRefinedBy().addAll( Collections2.filter(getAllDifferencesForChange(refiningDiff), EMFComparePredicates .fromSide(extension.getSource()))); } }

Target:
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) { if (extensionKind == DifferenceKind.CHANGE) { extension.getRefinedBy().addAll( Collections2.filter(getAllDifferencesForChange(refiningDiff), fromSide(extension .getSource()))); } }
Source:
protected void addValue(Object value) { if (!_stack.isEmpty()) { DataComplex currItem = _stack.peek(); int currItemSize = -1; if (_isCurrList) { CheckedUtil.addWithoutChecking((DataList) currItem, value); currItemSize = ((DataList) currItem).size(); } else { if (currItem instanceof DataMapBuilder) { DataMapBuilder dataMapBuilder = (DataMapBuilder) currItem; if (dataMapBuilder.smallHashMapThresholdReached()) { _stack.pop(); DataMap dataMap = dataMapBuilder.convertToDataMap(); _stack.push(dataMap); CheckedUtil.putWithoutChecking(dataMap, _currField, value); } else { dataMapBuilder.addKVPair(_currField, value); } } else { CheckedUtil.putWithoutChecking((DataMap) currItem, _currField, value); currItemSize = ((DataMap) currItem).size(); } _currField = null; } if (_currObjSize != -1 && currItemSize != -1 && _currObjSize == currItemSize) { pop(); } else { updateExpected(); } } else { _result = (T) value; _expectedTokens = NONE; } }

Target:
protected void addValue(Object value) { if (!_stack.isEmpty()) { DataComplex currItem = _stack.peek(); if (_isCurrList) { CheckedUtil.addWithoutChecking((DataList) currItem, value); } else { addEntryToDataObject(currItem, _currField, value); _currField = null; } updateExpected(); } }
Source:
public void testUseRowMapperUpdate() throws Exception { dbRule.getJdbi().useHandle(handle -> { handle.execute("drop table something"); handle.execute("create table something (id serial, name varchar(50), created_on timestamp default now())"); UseRowMapperDao dao = handle.attach(UseRowMapperDao.class); IdCreateTime result = dao.insert("foo"); assertThat(result.id).isEqualTo(1); assertThat(result.createdOn).isNotNull(); }); }

Target:
public void testUseRowMapperUpdate() throws Exception { dbRule.getJdbi().useExtension(UseRowMapperDao.class, dao -> { dao.createTable(); IdCreateTime result = dao.insert("foo"); assertThat(result.id).isEqualTo(1); assertThat(result.createdOn).isNotNull(); }); }
Source:
public void init() { view.init(this); view.initWidgets(queryTarget.view, serverTemplateId.view, dataSource.view, dbSQL.view); queryTarget.setSelectHint(KieServerClientConstants.INSTANCE.remote_query_target_hint()); List<DropDownEditor.Entry> entries = Stream.of("CUSTOM", "PROCESS", "TASK", "BA_TASK", "PO_TASK", "JOBS", "FILTERED_PROCESS", "FILTERED_BA_TASK", "FILTERED_PO_TASK") .map(s -> queryTarget.newEntry(s, s)).collect(Collectors.toList()); queryTarget.setEntries(entries); queryTarget.addHelpContent(KieServerClientConstants.INSTANCE.remote_query_target(), KieServerClientConstants.INSTANCE.remote_query_target_description(), Placement.RIGHT); serverTemplateId.setSelectHint(KieServerClientConstants.INSTANCE.remote_server_template_hint()); kieServerConnectionInfoProvider.call((List<String> serverTemplates) -> onServerTemplateLoad(serverTemplates)).serverTemplates(); serverTemplateId.addHelpContent(KieServerClientConstants.INSTANCE.remote_server_template(), KieServerClientConstants.INSTANCE.remote_server_template_description(), Placement.RIGHT); dataSource.addHelpContent(KieServerClientConstants.INSTANCE.remote_data_set_editor(), KieServerClientConstants.INSTANCE.remote_datasource_description(), Placement.BOTTOM); dbSQL.addHelpContent(KieServerClientConstants.INSTANCE.remote_data_set_editor(), KieServerClientConstants.INSTANCE.remote_datasource_description(), Placement.BOTTOM); }

Target:
public void init() { view.init(this); view.initWidgets(queryTarget.view, serverTemplateId.view, dataSource.view, dbSQL.view); queryTarget.setSelectHint(KieServerClientConstants.INSTANCE.remoteQueryTargetHint()); List<DropDownEditor.Entry> entries = Stream.of("CUSTOM", "PROCESS", "TASK", "BA_TASK", "PO_TASK", "JOBS", "FILTERED_PROCESS", "FILTERED_BA_TASK", "FILTERED_PO_TASK") .map(s -> queryTarget.newEntry(s, s)).collect(Collectors.toList()); queryTarget.setEntries(entries); queryTarget.addHelpContent(KieServerClientConstants.INSTANCE.remoteQueryTarget(), KieServerClientConstants.INSTANCE.remoteQueryTargetDescription(), Placement.RIGHT); serverTemplateId.setSelectHint(KieServerClientConstants.INSTANCE.remoteServerTemplateHint()); kieServerConnectionInfoProvider.call((List<String> serverTemplates) -> onServerTemplateLoad(serverTemplates)).serverTemplates(); serverTemplateId.addHelpContent(KieServerClientConstants.INSTANCE.remoteServerTemplate(), KieServerClientConstants.INSTANCE.remoteServerTemplateDescription(), Placement.RIGHT); dataSource.addHelpContent(KieServerClientConstants.INSTANCE.remoteDataSetEditor(), KieServerClientConstants.INSTANCE.remoteDatasourceDescription(), Placement.BOTTOM); dbSQL.addHelpContent(KieServerClientConstants.INSTANCE.remoteDataSetEditor(), KieServerClientConstants.INSTANCE.remoteDatasourceDescription(), Placement.BOTTOM); }
Source:
public void stop() { synchronized (startStopLock) { running = false; taskStatusChecker.shutdownNow(); if (numRunningTasks > 0) { final Iterator<MonitorEntry> iterator = runningTasks.values().iterator(); while (iterator.hasNext()) { final MonitorEntry entry = iterator.next(); iterator.remove(); final String taskId = entry.runningTask.getId(); log.info("Request to kill subtask[%s]", taskId); indexingServiceClient.cancelTask(taskId); numRunningTasks--; numKilledTasks++; } if (numRunningTasks > 0) { log.warn( "Inconsistent state: numRunningTasks[%d] is still not zero after trying to kill all running tasks.", numRunningTasks ); } } log.info("Stopped taskMonitor"); } }

Target:
public void stop() { synchronized (startStopLock) { if (running) { running = false; taskStatusChecker.shutdownNow(); synchronized (taskCountLock) { if (numRunningTasks > 0) { final Iterator<MonitorEntry> iterator = runningTasks.values().iterator(); while (iterator.hasNext()) { final MonitorEntry entry = iterator.next(); iterator.remove(); final String taskId = entry.runningTask.getId(); log.info("Request to cancel subtask[%s]", taskId); indexingServiceClient.cancelTask(taskId); numRunningTasks--; numCanceledTasks++; } if (numRunningTasks > 0) { log.warn( "Inconsistent state: numRunningTasks[%d] is still not zero after trying to cancel all running tasks.", numRunningTasks ); } } } log.info("Stopped taskMonitor"); } } }
Source:
ChangeAndCommit(@Nullable Change change, @Nullable PatchSet ps, RevCommit c) { if (change != null) { changeId = change.getKey().get(); _changeNumber = change.getChangeId(); _revisionNumber = ps != null ? ps.getPatchSetId() : null; PatchSet.Id curr = change.currentPatchSetId(); _currentRevisionNumber = curr != null ? curr.get() : null; } commit = new CommitInfo(); commit.commit = c.name(); commit.parents = Lists.newArrayListWithCapacity(c.getParentCount()); for (int i = 0; i < c.getParentCount(); i++) { CommitInfo p = new CommitInfo(); p.commit = c.getParent(i).name(); commit.parents.add(p); } commit.author = toGitPerson(c.getAuthorIdent()); commit.subject = c.getShortMessage(); IncludedInDetail detail = new IncludedInDetail(); try { detail = resolveBranches(c); } catch (Exception e) { e.printStackTrace(); } branches = detail.getBranches(); }

Target:
ChangeAndCommit(@Nullable Change change, @Nullable PatchSet ps, RevCommit c) throws RepositoryNotFoundException, IOException, OrmException { if (change != null) { changeId = change.getKey().get(); _changeNumber = change.getChangeId(); _revisionNumber = ps != null ? ps.getPatchSetId() : null; PatchSet.Id curr = change.currentPatchSetId(); _currentRevisionNumber = curr != null ? curr.get() : null; } commit = new CommitInfo(); commit.commit = c.name(); commit.parents = Lists.newArrayListWithCapacity(c.getParentCount()); for (int i = 0; i < c.getParentCount(); i++) { CommitInfo p = new CommitInfo(); p.commit = c.getParent(i).name(); commit.parents.add(p); } commit.author = toGitPerson(c.getAuthorIdent()); commit.subject = c.getShortMessage(); IncludedInDetail detail = new IncludedInDetail(); detail = resolveBranches(c); branches = detail.getBranches().size() != 0 ? detail.getBranches() : null; }