auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static void main(String... args) throws InterruptedException { System.out.println(">>> Decision tree classification trainer example started."); try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { System.out.println(">>> Ignite grid started."); IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(), DecisionTreeClassificationTrainerExample.class.getSimpleName(), () -> { CacheConfiguration<Integer, LabeledPoint> trainingSetCfg = new CacheConfiguration<>(); trainingSetCfg.setName("TRAINING_SET"); <START> trainingSetCfg.setAffinity(new RendezvousAffinityFunction(false, 1)); <END> IgniteCache<Integer, LabeledPoint> trainingSet = ignite.createCache(trainingSetCfg); Random rnd = new Random(0); for (int i = 0; i < 1000; i++) trainingSet.put(i, generatePoint(rnd)); DecisionTreeClassificationTrainer trainer = new DecisionTreeClassificationTrainer(4, 0, false); DecisionTreeNode mdl = trainer.fit( ignite, trainingSet, (k, v) -> VectorUtils.of(v.x, v.y), (k, v) -> v.lb ); int correctPredictions = 0; for (int i = 0; i < 1000; i++) { LabeledPoint pnt = generatePoint(rnd); double prediction = mdl.apply(VectorUtils.of(pnt.x, pnt.y)); if (prediction == pnt.lb) correctPredictions++; } System.out.println(">>> Accuracy: " + correctPredictions / 10.0 + "%"); System.out.println(">>> Decision tree classification trainer example completed."); }); igniteThread.start(); igniteThread.join(); } }</code><technical_language>change 1? work multiple partitions</technical_language>

Target:
public static void main(String... args) throws InterruptedException { System.out.println(">>> Decision tree classification trainer example started."); try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { System.out.println(">>> Ignite grid started."); IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(), DecisionTreeClassificationTrainerExample.class.getSimpleName(), () -> { CacheConfiguration<Integer, LabeledPoint> trainingSetCfg = new CacheConfiguration<>(); trainingSetCfg.setName("TRAINING_SET"); trainingSetCfg.setAffinity(new RendezvousAffinityFunction(false, 10)); IgniteCache<Integer, LabeledPoint> trainingSet = ignite.createCache(trainingSetCfg); Random rnd = new Random(0); for (int i = 0; i < 1000; i++) trainingSet.put(i, generatePoint(rnd)); DecisionTreeClassificationTrainer trainer = new DecisionTreeClassificationTrainer(4, 0); DecisionTreeNode mdl = trainer.fit( ignite, trainingSet, (k, v) -> VectorUtils.of(v.x, v.y), (k, v) -> v.lb ); int correctPredictions = 0; for (int i = 0; i < 1000; i++) { LabeledPoint pnt = generatePoint(rnd); double prediction = mdl.apply(VectorUtils.of(pnt.x, pnt.y)); if (prediction == pnt.lb) correctPredictions++; } System.out.println(">>> Accuracy: " + correctPredictions / 10.0 + "%"); System.out.println(">>> Decision tree classification trainer example completed."); }); igniteThread.start(); igniteThread.join(); } }
Source:
<code><START> public JSONPointer(List<String> refTokens) { <END> this.refTokens = refTokens; }</code><technical_language>This a **protected/private/or default** constructor, **List** copied Pointer modified of class. java this.refTokens = refTokens.clone(); is now, I do this: java Builder b = JSONPointer.builder().append("key1"); JSONPointer jp1 = b.build(); b.append("key2"); JSONPointer jp2 = b.build(); if(jp1.toString().equals(jp2.toString()){ throw new Exception("Oops, pointers sharing a backing array"); }</technical_language>

Target:
public JSONPointer(List<String> refTokens) { this.refTokens = new ArrayList<String>(refTokens); }
Source:
<code>public int <START> getAggressiveHandover() <END> { enforceAccessPermission(); return mWifiStateMachine.getAggressiveHandover(); }</code><technical_language>trace this one</technical_language>

Target:
public int getAggressiveHandover() { enforceAccessPermission(); mLog.trace("getAggressiveHandover uid=%").c(Binder.getCallingUid()).flush(); return mWifiStateMachine.getAggressiveHandover(); }
Source:
<code>public void onViewCreated(View view, Bundle savedInstanceState) { GoogleMap map = mapView.getMap(); map.setMyLocationEnabled(true); map.setOnMarkerClickListener(this); setUpClusterer(); <START> Location myLocation = map.getMyLocation(); <END> if (myLocation != null) { currentLocation = new LatLng(myLocation.getLatitude(), myLocation.getLongitude()); map.animateCamera(CameraUpdateFactory.newLatLng(currentLocation)); loadActiveTrucks(); } }</code><technical_language>This api is deprecated. I rely onConnected callback duplicates this logic anyhow</technical_language>

Target:
public void onViewCreated(View view, Bundle savedInstanceState) { GoogleMap map = mapView.getMap(); if (map != null) { map.setMyLocationEnabled(true); setUpClusterer(); } }
Source:
<code>public GenericRecord transform(StructuredRecord structuredRecord, co.cask.cdap.api.data.schema.Schema schema) throws IOException { co.cask.cdap.api.data.schema.Schema structuredRecordSchema = structuredRecord.getSchema(); Schema avroSchema = getAvroSchema(schema); GenericRecordBuilder recordBuilder = new GenericRecordBuilder(avroSchema); for (Schema.Field field : avroSchema.getFields()) { String fieldName = field.name(); co.cask.cdap.api.data.schema.Schema.Field schemaField = structuredRecordSchema.getField(fieldName); if (schemaField == null) { throw new IllegalArgumentException("Input record does not contain the " + fieldName + " field."); } <START> if (schemaField.getSchema().getType().equals(co.cask.cdap.api.data.schema.Schema.Type.BYTES)) { <END> recordBuilder.set(fieldName, ByteBuffer.wrap((byte[]) structuredRecord.get(fieldName))); } else { recordBuilder.set(fieldName, convertField(structuredRecord.get(fieldName), schemaField.getSchema())); } } return recordBuilder.build(); }</code><technical_language>I this fail if field is nullable. need check get simple type. example here: <LINK_0></technical_language>

Target:
public GenericRecord transform(StructuredRecord structuredRecord, co.cask.cdap.api.data.schema.Schema schema) throws IOException { co.cask.cdap.api.data.schema.Schema structuredRecordSchema = structuredRecord.getSchema(); Schema avroSchema = getAvroSchema(schema); GenericRecordBuilder recordBuilder = new GenericRecordBuilder(avroSchema); for (Schema.Field field : avroSchema.getFields()) { String fieldName = field.name(); co.cask.cdap.api.data.schema.Schema.Field schemaField = structuredRecordSchema.getField(fieldName); if (schemaField == null) { throw new IllegalArgumentException("Input record does not contain the " + fieldName + " field."); } co.cask.cdap.api.data.schema.Schema schemaFieldSchema = schemaField.getSchema(); co.cask.cdap.api.data.schema.Schema.Type inputFieldType = (schemaFieldSchema.isNullableSimple()) ? schemaFieldSchema.getNonNullable().getType() : schemaFieldSchema.getType(); if (inputFieldType.equals(co.cask.cdap.api.data.schema.Schema.Type.BYTES)) { recordBuilder.set(fieldName, ByteBuffer.wrap((byte[]) structuredRecord.get(fieldName))); } else { recordBuilder.set(fieldName, convertField(structuredRecord.get(fieldName), schemaField.getSchema())); } } return recordBuilder.build(); }
Source:
<code>protected void obtainResource() throws Exception { if (embedded) { try { log.debug("Starting Zookeeper"); zookeeper = new EmbeddedZookeeper(TestZKUtils.zookeeperConnect()); log.debug("Started Zookeeper at " + zookeeper.getConnectString()); } catch (Exception e) { throw new RuntimeException("Issues creating the ZK server", e); } try { int zkConnectionTimeout = 6000; int zkSessionTimeout = 6000; zkClient = new ZkClient(getZkConnectString(), zkSessionTimeout, zkConnectionTimeout, ZKStringSerializer$.MODULE$); } catch (Exception e) { zookeeper.shutdown(); throw new RuntimeException("Issues creating the ZK client", e); } try { log.debug("Creating Kafka server"); Properties brokerConfigProperties = brokerConfig; kafkaServer = TestUtils.createServer(new KafkaConfig(brokerConfigProperties), SystemTime$.MODULE$); log.debug("Created Kafka server at " + kafkaServer.config().hostName() + ":" + kafkaServer.config().port()); } catch (Exception e) { zookeeper.shutdown(); zkClient.close(); throw new RuntimeException("Issues creating the Kafka server", e); <START> } <END> } else { try { this.zkClient = new ZkClient(DEFAULT_ZOOKEEPER_CONNECT, 5000, 5000, ZKStringSerializer$.MODULE$); if (ZkUtils.getAllBrokersInCluster(zkClient).size() == 0) { throw new RuntimeException("Kafka server not available on localhost"); } } catch (Exception e) { throw new RuntimeException("Issues connecting to ZK server"); } } }</code><technical_language>picking here, wrap of Exceptions in RuntimeException if method is throwing Exception anyways</technical_language>

Target:
protected void obtainResource() throws Exception { if (embedded) { log.debug("Starting Zookeeper"); zookeeper = new EmbeddedZookeeper(TestZKUtils.zookeeperConnect()); log.debug("Started Zookeeper at " + zookeeper.getConnectString()); try { int zkConnectionTimeout = 6000; int zkSessionTimeout = 6000; zkClient = new ZkClient(getZkConnectString(), zkSessionTimeout, zkConnectionTimeout, ZKStringSerializer$.MODULE$); } catch (Exception e) { zookeeper.shutdown(); throw e; } try { log.debug("Creating Kafka server"); Properties brokerConfigProperties = brokerConfig; kafkaServer = TestUtils.createServer(new KafkaConfig(brokerConfigProperties), SystemTime$.MODULE$); log.debug("Created Kafka server at " + kafkaServer.config().hostName() + ":" + kafkaServer.config().port()); } catch (Exception e) { zookeeper.shutdown(); zkClient.close(); throw e; } } else { this.zkClient = new ZkClient(DEFAULT_ZOOKEEPER_CONNECT, 5000, 5000, ZKStringSerializer$.MODULE$); if (ZkUtils.getAllBrokersInCluster(zkClient).size() == 0) { throw new RuntimeException("Kafka server not available"); } } }
Source:
<code>protected void startBackgroundDiscovery() { if (usbSerialDiscovery != null) { usbSerialDiscovery.startBackgroundScanning(); } else { logger.info( <START> "Could not start background discovery, as there is no usb serial discovery service configured."); <END> } }</code><technical_language>**USB**</technical_language>

Target:
protected void startBackgroundDiscovery() { if (usbSerialDiscovery != null) { usbSerialDiscovery.startBackgroundScanning(); } else { logger.info( "Could not start background discovery, as there is no USB-Serial discovery service configured."); } }
Source:
<code>public void shouldIgnoreBase() { WorkBenchDto workBenchDto = new WorkBenchDto(); workBenchDto.setArticleName( "MyBench" ); workBenchDto.setArticleDescription( "Beautiful" ); WorkBenchEntity benchTarget = ToolMapper.INSTANCE.mapBench( workBenchDto ); assertThat( benchTarget ).isNotNull(); assertThat( benchTarget.getArticleName() ).isEqualTo( "MyBench" ); <START> assertThat( benchTarget.getDescription() ).isEqualTo( "Beautiful" ); <END> assertThat( benchTarget.getKey() ).isNull(); assertThat( benchTarget.getModificationDate() ).isNull(); assertThat( benchTarget.getCreationDate() ).isNull(); }</code><technical_language>properties base null mapping. show want I presume need null mapping</technical_language>

Target:
public void shouldIgnoreBase() { WorkBenchDto workBenchDto = new WorkBenchDto(); workBenchDto.setArticleName( "MyBench" ); workBenchDto.setArticleDescription( "Beautiful" ); workBenchDto.setCreationDate( new Date() ); workBenchDto.setModificationDate( new Date() ); WorkBenchEntity benchTarget = ToolMapper.INSTANCE.mapBench( workBenchDto ); assertThat( benchTarget ).isNotNull(); assertThat( benchTarget.getArticleName() ).isEqualTo( "MyBench" ); assertThat( benchTarget.getDescription() ).isEqualTo( "Beautiful" ); assertThat( benchTarget.getKey() ).isNull(); assertThat( benchTarget.getModificationDate() ).isNull(); assertThat( benchTarget.getCreationDate() ).isNull(); }
Source:
<code>@Override protected String run(Void arg) throws IgniteException { Set<Object> ids = ignite.context().cache().context().snapshotMgr().statusSnapshot().get().stream() .filter(Objects::nonNull) .collect(Collectors.toSet()); if (ids.isEmpty()) return "No snapshot operations."; <START> StringBuilder sb = new StringBuilder("чSnapshot operation in progress on nodes with Consistent ID:"); <END> ids.stream() .map(String::valueOf) .forEach(s -> sb.append(IgniteUtils.nl()).append(s)); return sb.toString(); }</code><technical_language>cyrillic letters removed message</technical_language>

Target:
@Override protected String run(Void arg) throws IgniteException { Set<Object> ids = new SnapshotMXBeanImpl(ignite.context()).statusSnapshot().entrySet() .stream() .filter(Map.Entry::getValue) .map(Map.Entry::getKey).collect(Collectors.toSet()); if (ids.isEmpty()) return "No snapshot operations."; StringBuilder sb = new StringBuilder("Snapshot operation in progress on nodes with Consistent ID:"); ids.stream() .map(String::valueOf) .forEach(s -> sb.append(IgniteUtils.nl()).append(s)); return sb.toString(); }
Source:
<code>public List<Integer> parse() { <START> final List<Integer> list = new LinkedList<>(); <END> for (int i = 0; i < numTrainingDataInstance; i++) { list.add(RAND.nextInt()); } return list; }</code><technical_language>new ArrayList<>(numTrainingDataInstance);</technical_language>

Target:
public List<Integer> parse() { final List<Integer> list = new ArrayList<>(numTrainingDataInstance); for (int i = 0; i < numTrainingDataInstance; i++) { list.add(RAND.nextInt()); } return list; }
Source:
<code>default DRepresentation copyRepresentation(DRepresentation representation, String name, Session session, IProgressMonitor monitor) { if (session instanceof DAnalysisSessionImpl) { <START> DRepresentationQuery query = new DRepresentationQuery(representation); for (DAnalysis analysis: ((DAnalysisSessionImpl) session).allAnalyses()) { DRepresentationDescriptor descriptor = query.findDescriptorFromAnalysis(analysis); <END> if (descriptor != null) { return this.copyRepresentation(descriptor, name, session, monitor); } } } return null; }</code><technical_language>constructor DRepresentationQuery.DRepresentationQuery(DRepresentation, Session) call DRepresentationQuery.getRepresentationDescriptor()</technical_language>

Target:
default DRepresentation copyRepresentation(DRepresentation representation, String name, Session session, IProgressMonitor monitor) { DRepresentationDescriptor descriptor = new DRepresentationQuery(representation, session).getRepresentationDescriptor(); if (descriptor != null) { return this.copyRepresentation(descriptor, name, session, monitor); } else { return null; } }
Source:
<code>public void invokeBusinessLogic(MessageContext msgContext) throws AxisFault { try { if (log.isDebugEnabled()) { log.debug("Request received to DSS. Data Service :" + msgContext.getServiceContext().getName() + ", " + "Operation :" + msgContext.getSoapAction() + ", Request body: " + msgContext.getEnvelope().toString() + ", ThreadID:" + Thread.currentThread().getId()); } DataServiceProcessor.dispatch(msgContext); } catch(Exception e) { e.printStackTrace(); log.error("Error in in-only message receiver", e); msgContext.setProperty(Constants.FAULT_NAME, DBConstants.DS_FAULT_NAME); throw DBUtils.createAxisFault(e); } finally { if (log.isDebugEnabled()) { log.debug("Request processing completed from DSS. Data Service :" + msgContext.getServiceContext().getName() + ", Operation :" + msgContext.getSoapAction() + <START> ", ThreadID :" + Thread.currentThread().getId()); <END> } } }</code><technical_language>logging, format "some_message: " + ... notice colon, space that. This consistent, fix in places</technical_language>

Target:
public void invokeBusinessLogic(MessageContext msgContext) throws AxisFault { try { if (log.isDebugEnabled()) { log.debug("Request received to DSS: Data Service - " + msgContext.getServiceContext().getName() + ", Operation - " + msgContext.getSoapAction() + ", Request body - " + msgContext.getEnvelope().toString() + ", ThreadID - " + Thread.currentThread().getId()); } DataServiceProcessor.dispatch(msgContext); } catch (Exception e) { log.error("Error in in-only message receiver", e); msgContext.setProperty(Constants.FAULT_NAME, DBConstants.DS_FAULT_NAME); throw DBUtils.createAxisFault(e); } finally { if (log.isDebugEnabled()) { log.debug("Request processing completed from DSS: Data Service - " + msgContext.getServiceContext().getName() + ", Operation - " + msgContext.getSoapAction() + ", ThreadID - " + Thread.currentThread().getId()); } } }
Source:
<code>public void partitionPage(Page page) { populatePositionsForEachPartition(page); int channelCount = page.getChannelCount(); for (int i = 0; i < channelCount; i++) { <START> decodedBlocks[i] = decodeBlock(flattener, page.getBlock(i)); <END> } for (int i = 0; i < partitionData.length; i++) { partitionData[i].appendRows(decodedBlocks, fixedWidthRowSize, variableWidthChannels, outputBuffer); } }</code><technical_language>channelCount -> decodedBlocks.length for consistency next loop</technical_language>

Target:
public void partitionPage(Page page) { populatePositionsForEachPartition(page); for (int i = 0; i < decodedBlocks.length; i++) { decodedBlocks[i] = decodeBlock(flattener, page.getBlock(i)); } for (int i = 0; i < partitionData.length; i++) { partitionData[i].appendRows(decodedBlocks, fixedWidthRowSize, variableWidthChannels, outputBuffer); } }
Source:
<code>public Role populate(ModelTranslator modelTranslator, RoleDTO source, Role destination) { if (source == null) { throw new IllegalArgumentException("source is null"); } if (destination == null) { throw new IllegalArgumentException("destination is null"); } destination.setCreated(source.getCreated() != null ? new Date(source.getCreated().toInstant().toEpochMilli()) : null); destination.setUpdated(source.getUpdated() != null ? new Date(source.getUpdated().toInstant().toEpochMilli()) : null); destination.setId(source.getId()); destination.setName(source.getName()); if (modelTranslator != null) { List<UserDTO> users = source.getUsers(); if (users != null) { destination.setUsers(users.stream() .map(modelTranslator.getStreamMapper(UserDTO.class, User.class)) .collect(Collectors.toSet())); } else { destination.setUsers(Collections.<User>emptySet()); } List<PermissionBlueprintDTO> permissions = source.getPermissions(); if (permissions != null) { destination.setPermissions(permissions.stream() .map(modelTranslator.getStreamMapper(PermissionBlueprintDTO.class, PermissionBlueprint.class)) .collect(Collectors.toSet())); } else { <START> destination.setPermissions(Collections.<PermissionBlueprint>emptySet()); <END> } } else { destination.setUsers(Collections.<User>emptySet()); destination.setPermissions(Collections.<PermissionBlueprint>emptySet()); } return destination; }</code><technical_language>is need explicit type arguments. JVM infer omited. java Collections.emptySet()</technical_language>

Target:
public Role populate(ModelTranslator modelTranslator, RoleDTO source, Role destination) { if (source == null) { throw new IllegalArgumentException("source is null"); } if (destination == null) { throw new IllegalArgumentException("destination is null"); } destination.setCreated(source.getCreated() != null ? new Date(source.getCreated().toInstant().toEpochMilli()) : null); destination.setUpdated(source.getUpdated() != null ? new Date(source.getUpdated().toInstant().toEpochMilli()) : null); destination.setId(source.getId()); destination.setName(source.getName()); if (modelTranslator != null) { Set<UserDTO> users = source.getUsers(); if (users != null) { destination.setUsers(users.stream() .map(modelTranslator.getStreamMapper(UserDTO.class, User.class)) .collect(Collectors.toSet())); } else { destination.setUsers(Collections.emptySet()); } List<PermissionBlueprintDTO> permissions = source.getPermissions(); if (permissions != null) { destination.setPermissions(permissions.stream() .map(modelTranslator.getStreamMapper(PermissionBlueprintDTO.class, PermissionBlueprint.class)) .collect(Collectors.toSet())); } else { destination.setPermissions(Collections.emptySet()); } } else { destination.setUsers(Collections.emptySet()); destination.setPermissions(Collections.emptySet()); } return destination; }
Source:
<code>public Single<Media> fetchMediaDetails(String filename) { Single<Media> mediaSingle = getMediaFromFileName(filename); <START> Single<Boolean> pageExistsSingle = mediaClient.doesPageExist("Commons:Deletion_requests/" + filename); <END> Single<String> discussionSingle = getDiscussion(filename); return Single.zip(mediaSingle, pageExistsSingle, discussionSingle, (media, deletionStatus, discussion) -> { media.setDiscussion(discussion); if (deletionStatus) { media.setRequestedDeletion(); } return media; }); }</code><technical_language>"Commons:Deletion_requests" multiple times code. a a constants file defining strings</technical_language>

Target:
public Single<Media> fetchMediaDetails(String filename) { Single<Media> mediaSingle = getMediaFromFileName(filename); Single<Boolean> pageExistsSingle = mediaClient.checkPageExistsUsingTitle("Commons:Deletion_requests/" + filename); Single<String> discussionSingle = getDiscussion(filename); return Single.zip(mediaSingle, pageExistsSingle, discussionSingle, (media, deletionStatus, discussion) -> { media.setDiscussion(discussion); if (deletionStatus) { media.setRequestedDeletion(); } return media; }); }
Source:
<code>public void doubleAllocate() { clf.createCANTalon(1); <START> try { <END> clf.createCANTalon(1); assertTrue("You shouldn't be able to double-allocate!", false); } catch (Exception e) { } }</code><technical_language>catch exception, add annotation tells JUnit expect exception fail if thrown</technical_language>

Target:
public void doubleAllocate() { clf.createCANTalon(1); clf.createCANTalon(1); assertTrue("You shouldn't be able to double-allocate!", false); }
Source:
<code>public void clickPropertiesTableButton() { selectFromContextMenu(propertiesItem); <START> waitForElementByElement(tablePropertiesInputs.get(2)); <END> }</code><technical_language>wait for "Table properties" modal</technical_language>

Target:
public void clickPropertiesTableButton() { selectFromContextMenu(propertiesItem); waitForElementByElement(addTableLightbox); }
Source:
<code>private TreeWalk createFileWalker(Repository db, List<FilterPath> paths) { final TreeWalk fileWalker = new TreeWalk(db); fileWalker.setRecursive(true); if (store.getBoolean(UIPreferences.RESOURCEHISTORY_FOLLOW_RENAMES) <START> && paths.size() == 1 <END> && paths.get(0).isRegularFile()) { pathFilters = paths; String selectedPath = paths.get(0).getPath(); currentWalk.setTreeFilter(FollowFilter.create(selectedPath)); fileWalker.setFilter(AndTreeFilter.create(PathFilterGroup .createFromStrings(selectedPath), TreeFilter.ANY_DIFF)); } else if (paths.size() > 0) { pathFilters = paths; List<String> stringPaths = new ArrayList<String>(paths.size()); for (FilterPath p : paths) { stringPaths.add(p.getPath()); } currentWalk.setTreeFilter(AndTreeFilter.create(PathFilterGroup .createFromStrings(stringPaths), TreeFilter.ANY_DIFF)); fileWalker.setFilter(currentWalk.getTreeFilter().clone()); } else { pathFilters = null; currentWalk.setTreeFilter(TreeFilter.ALL); fileWalker.setFilter(TreeFilter.ANY_DIFF); } return fileWalker; }</code><technical_language>want able follow renames for a pair of files? I able live restriction if is a good reason for this</technical_language>

Target:
private TreeWalk createFileWalker(Repository db, List<FilterPath> paths) { final TreeWalk fileWalker = new TreeWalk(db); fileWalker.setRecursive(true); if (store.getBoolean(UIPreferences.RESOURCEHISTORY_FOLLOW_RENAMES) && !paths.isEmpty() && allRegularFiles(paths)) { pathFilters = paths; List<String> selectedPaths = new ArrayList<String>(paths.size()); for (FilterPath filterPath : paths) selectedPaths.add(filterPath.getPath()); TreeFilter followFilter = createFollowFilterFor(selectedPaths); currentWalk.setTreeFilter(followFilter); fileWalker.setFilter(AndTreeFilter.create(PathFilterGroup .createFromStrings(selectedPaths), TreeFilter.ANY_DIFF)); } else if (paths.size() > 0) { pathFilters = paths; List<String> stringPaths = new ArrayList<String>(paths.size()); for (FilterPath p : paths) stringPaths.add(p.getPath()); currentWalk.setTreeFilter(AndTreeFilter.create(PathFilterGroup .createFromStrings(stringPaths), TreeFilter.ANY_DIFF)); fileWalker.setFilter(currentWalk.getTreeFilter().clone()); } else { pathFilters = null; currentWalk.setTreeFilter(TreeFilter.ALL); fileWalker.setFilter(TreeFilter.ANY_DIFF); } return fileWalker; }
Source:
<code>public UUID lookupUUID(String name) { for (OfflinePlayer player : getOfflinePlayers()) { if (player.getName().equalsIgnoreCase(name)) { return player.getUniqueId(); } } <START> if (Bukkit.getServer().getOnlineMode()) { <END> UUID id = UuidUtils.fetchUUID(name); if (id != null) { return id; } } return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)); }</code><technical_language>This check for active proxy support fetch UUID if enabled GlowServer.getProxySupport()</technical_language>

Target:
public UUID lookupUUID(String name) { for (OfflinePlayer player : getOfflinePlayers()) { if (player.getName().equalsIgnoreCase(name)) { return player.getUniqueId(); } } if (Bukkit.getServer().getOnlineMode() || ((GlowServer) Bukkit.getServer()).getProxySupport()) { UUID id = UuidUtils.fetchUUID(name); if (id != null) { return id; } } return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)); }
Source:
<code>private static boolean allChildrenTypeOnly(Cast node) { ImmutableList.Builder<Boolean> casts = ImmutableList.builder(); new DefaultExpressionTraversalVisitor<Void, ImmutableList.Builder<Boolean>>() { @Override protected Void visitCast(Cast node, ImmutableList.Builder<Boolean> context) { super.visitCast(node, context); <START> context.add(node.isTypeOnly()); <END> return null; } }.process(node, casts); return casts.build().stream().allMatch(Boolean::booleanValue); }</code><technical_language>need a list here. update context = context && node.isTypeOnly() assuming context is Boolean</technical_language>

Target:
private static boolean allChildrenTypeOnly(Cast node) { AtomicReference<Optional<Boolean>> allTrue = new AtomicReference<>(Optional.empty()); new DefaultExpressionTraversalVisitor<Void, AtomicReference<Optional<Boolean>>>() { @Override protected Void visitCast(Cast node, AtomicReference<Optional<Boolean>> context) { super.visitCast(node, context); context.set(Optional.of(node.isTypeOnly() && context.get().orElse(true))); return null; } }.process(node, allTrue); return allTrue.get().orElse(false); }
Source:
<code>void update(RawPacket pkt, long nowMs) { rateStatistics.update(pkt.getLength(), nowMs); long ts = pkt.getTimestamp(); FrameDesc frame = frames.get(ts); <START> boolean isNew; <END> if (frame == null) { isNew = true; synchronized (frames) { frames.put(ts, frame = new FrameDesc(this, ts, nowMs)); } lastStableBitrateBps = getBitrateBps(nowMs); if (lastReceivedFrame == null || TimeUtils.rtpDiff(ts, lastReceivedFrame.getTimestamp()) > 0) { lastReceivedFrame = frame; } } else { isNew = false; } boolean frameChanged = frame.update(pkt); if (frameChanged) { Map.Entry<Long, FrameDesc> ceilingEntry = frames.ceilingEntry((ts + 1) & 0xFFFFFFFFL); if (ceilingEntry != null) { applyFrameBoundsHeuristics(frame, ceilingEntry.getValue()); } Map.Entry<Long, FrameDesc> floorEntry = frames.floorEntry((ts - 1) & 0xFFFFFFFFL); if (floorEntry != null) { applyFrameBoundsHeuristics(floorEntry.getValue(), frame); } } track.update(pkt, frame, isNew, nowMs); }</code><technical_language>rename isFirstPacketOfNewFrame maybe? also, if initialize false get rid of else block</technical_language>

Target:
void update(RawPacket pkt, long nowMs) { rateStatistics.update(pkt.getLength(), nowMs); long ts = pkt.getTimestamp(); FrameDesc frame = frames.get(ts); boolean isPacketOfNewFrame; if (frame == null) { isPacketOfNewFrame = true; synchronized (frames) { frames.put(ts, frame = new FrameDesc(this, ts, nowMs)); } lastStableBitrateBps = getBitrateBps(nowMs); if (lastReceivedFrame == null || TimeUtils.rtpDiff(ts, lastReceivedFrame.getTimestamp()) > 0) { lastReceivedFrame = frame; } } else { isPacketOfNewFrame = false; } boolean frameChanged = frame.update(pkt); if (frameChanged) { Map.Entry<Long, FrameDesc> ceilingEntry = frames.ceilingEntry((ts + 1) & 0xFFFFFFFFL); if (ceilingEntry != null) { applyFrameBoundsHeuristics(frame, ceilingEntry.getValue()); } Map.Entry<Long, FrameDesc> floorEntry = frames.floorEntry((ts - 1) & 0xFFFFFFFFL); if (floorEntry != null) { applyFrameBoundsHeuristics(floorEntry.getValue(), frame); } } track.update(pkt, frame, isPacketOfNewFrame, nowMs); }
Source:
<code>public void testVariance() { final SecureRandom random = new SecureRandom(); final int numberOfSamples = 10000; for (int run = 0; run < 100; run++) { final double[] dist = new double[8]; for (int i = 0; i < numberOfSamples; i++) { dist[random.nextInt(dist.length)]++; } final double variance = calculateVarianceOfUniformDistribution(dist); <START> System.out.println(Arrays.toString(dist) + " = " + variance); <END> } }</code><technical_language>scissors:</technical_language>

Target:
public void testVariance() { final SecureRandom random = new SecureRandom(); final int numberOfSamples = 100000; final int numberOfRuns = 1000; final double threshold = 1.5; double failProbability = 0; for (int run = 0; run < numberOfRuns; run++) { final double[] dist = new double[8]; for (int i = 0; i < numberOfSamples; i++) { dist[random.nextInt(dist.length)]++; } final double variance = calculateVarianceOfUniformDistribution(dist); if (variance > threshold) { failProbability += (1.0 / numberOfRuns); } if (((run * 100.0) / numberOfRuns) % 1 == 0) { System.out.println((int) ((run * 100.0) / numberOfRuns) + "%"); } } System.out.println("probability to fail the test: " + failProbability); }
Source:
<code>public static NodeList query(Document dom, String query, Node context) throws XPathExpressionException { NodeList nodeList; XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(new NamespaceContext() { public String getNamespaceURI(String prefix) { String result = null; <START> if (prefix.equals("samlp")) <END> result = Constants.NS_SAMLP; else if (prefix.equals("saml")) result = Constants.NS_SAML; else if (prefix.equals("ds")) result = Constants.NS_DS; else if (prefix.equals("xenc")) result = Constants.NS_XENC; return result; } public String getPrefix(String namespaceURI) { return null; } @SuppressWarnings("rawtypes") public Iterator getPrefixes(String namespaceURI) { return null; } }); if (context == null) nodeList = (NodeList) xpath.evaluate(query, dom, XPathConstants.NODESET); else nodeList = (NodeList) xpath.evaluate(query, context, XPathConstants.NODESET); return nodeList; }</code><technical_language>Sometime, IdPs samlp2 saml2 prefixes instead of samlp saml, compatible fact</technical_language>

Target:
public static NodeList query(Document dom, String query, Node context) throws XPathExpressionException { NodeList nodeList; XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(new NamespaceContext() { public String getNamespaceURI(String prefix) { String result = null; if (prefix.equals("samlp") || prefix.equals("samlp2")) result = Constants.NS_SAMLP; else if (prefix.equals("saml") || prefix.equals("saml2")) result = Constants.NS_SAML; else if (prefix.equals("ds")) result = Constants.NS_DS; else if (prefix.equals("xenc")) result = Constants.NS_XENC; return result; } public String getPrefix(String namespaceURI) { return null; } @SuppressWarnings("rawtypes") public Iterator getPrefixes(String namespaceURI) { return null; } }); if (context == null) nodeList = (NodeList) xpath.evaluate(query, dom, XPathConstants.NODESET); else nodeList = (NodeList) xpath.evaluate(query, context, XPathConstants.NODESET); return nodeList; }
Source:
<code>public Iterator<Identity> enter(final Request request) throws IOException { return Collections.singleton( <START> PsLinkedin.parse(this.luserjson <END> .fetch(new Href("<LINK_1>") .with("grant_type", "authorization_code") .toString(), "<LINK_0>,first-name,last-name,picture-url)", new RqHref.Base(request).href() ) ) ).iterator(); }</code><technical_language>@ikhvostenkov leave parameter in line ( if ) is there. this line more like: PsLinkedin.parse( this.luserjson.fetch( new Href( "..</technical_language>

Target:
public Iterator<Identity> enter(final Request request) throws IOException { final Href href = new RqHref.Base(request).href(); final Iterator<String> code = href.param("code").iterator(); if (!code.hasNext()) { throw new IllegalArgumentException("code is not provided"); } return Collections.singleton( this.fetch(this.token(href.toString(), code.next())) ).iterator(); }
Source:
<code>public Map<String, Boolean> validateResourcesForWagedRebalance(String clusterName, List<String> resourceNames) { if (clusterName == null || clusterName.isEmpty()) { throw new HelixException("Cluster name is invalid!"); } if (resourceNames == null || resourceNames.isEmpty()) { throw new HelixException("Resource name list is invalid!"); } HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<>(_zkClient)); Builder keyBuilder = accessor.keyBuilder(); <START> List<String> liveInstances = accessor.getChildNames(keyBuilder.liveInstances()); <END> if (validateInstancesForWagedRebalance(clusterName, liveInstances).containsValue(false)) { throw new HelixException(String .format("Instance capacities haven't been configured properly for cluster %s", clusterName)); } Map<String, Boolean> result = new HashMap<>(); ClusterConfig clusterConfig = _configAccessor.getClusterConfig(clusterName); for (String resourceName : resourceNames) { IdealState idealState = getResourceIdealState(clusterName, resourceName); if (idealState == null || !idealState.isValid()) { result.put(resourceName, false); continue; } ResourceConfig resourceConfig = _configAccessor.getResourceConfig(clusterName, resourceName); if (resourceConfig == null || !resourceConfig.isValid()) { result.put(resourceName, false); continue; } result.put(resourceName, validateWeightForResourceConfig(clusterConfig, resourceConfig, idealState)); } return result; }</code><technical_language>instance config. is live, calculate baseline instance config</technical_language>

Target:
public Map<String, Boolean> validateResourcesForWagedRebalance(String clusterName, List<String> resourceNames) { if (clusterName == null || clusterName.isEmpty()) { throw new HelixException("Cluster name is invalid!"); } if (resourceNames == null || resourceNames.isEmpty()) { throw new HelixException("Resource name list is invalid!"); } HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<>(_zkClient)); Builder keyBuilder = accessor.keyBuilder(); List<String> instances = accessor.getChildNames(keyBuilder.instanceConfigs()); if (validateInstancesForWagedRebalance(clusterName, instances).containsValue(false)) { throw new HelixException(String .format("Instance capacities haven't been configured properly for cluster %s", clusterName)); } Map<String, Boolean> result = new HashMap<>(); ClusterConfig clusterConfig = _configAccessor.getClusterConfig(clusterName); for (String resourceName : resourceNames) { IdealState idealState = getResourceIdealState(clusterName, resourceName); if (idealState == null || !idealState.isValid()) { result.put(resourceName, false); continue; } ResourceConfig resourceConfig = _configAccessor.getResourceConfig(clusterName, resourceName); result.put(resourceName, validateWeightForResourceConfig(clusterConfig, resourceConfig, idealState)); } return result; }
Source:
<code>public void enhanceMetadata(Context context) { super.enhanceMetadata(context); <START> context.put(RuleMetadata.CATEGORY, "Core"); <END> }</code><technical_language>Windup/Discover/Java</technical_language>

Target:
public void enhanceMetadata(Context context) { super.enhanceMetadata(context); context.put(RuleMetadata.CATEGORY, "Java"); }
Source:
<code>public void testAdd() throws InterruptedException { String testKey = "key"; String testValue = "value"; CountDownLatch latch = new CountDownLatch(1); <START> StringBuilder actualKey = new StringBuilder(); <END> StringBuilder actualValue = new StringBuilder(); metadataStore.addListener(new MetadataStoreListenerAdapter() { @Override public void onAdd(String key, String value) { actualKey.append(key); actualValue.append(value); latch.countDown(); } }); metadataStore.put(testKey, testValue); latch.await(2, TimeUnit.SECONDS); assertEquals(0, latch.getCount()); assertEquals(testKey, actualKey.toString()); assertEquals(testValue, actualValue.toString()); }</code><technical_language>a bit unusual approach for testing data StringBuilder. Typically rely AtomicReference. be</technical_language>

Target:
public void testAdd() throws InterruptedException { String testKey = "key"; String testValue = "value"; CountDownLatch latch = new CountDownLatch(1); AtomicReference<String> actualKey = new AtomicReference<String>(); AtomicReference<String> actualValue = new AtomicReference<String>(); metadataStore.addListener(new MetadataStoreListenerAdapter() { @Override public void onAdd(String key, String value) { actualKey.set(key); actualValue.set(value); latch.countDown(); } }); metadataStore.put(testKey, testValue); latch.await(2, TimeUnit.SECONDS); assertEquals(0, latch.getCount()); assertEquals(testKey, actualKey.get()); assertEquals(testValue, actualValue.get()); }
Source:
<code>private void collectIds(Long id) { int keepTrying = 0; long curser = -1; do { try { twitter4j.IDs ids = null; if( endpoint.equals("followers") ) ids = client.friendsFollowers().getFollowersIDs(id.longValue(), curser, max_per_page); else if( endpoint.equals("friends") ) ids = client.friendsFollowers().getFriendsIDs(id.longValue(), curser, max_per_page); <START> Preconditions.checkNotNull(ids); <END> Preconditions.checkArgument(ids.getIDs().length > 0); for (long otherId : ids.getIDs()) { try { Follow follow; if( endpoint.equals("followers") ) { follow = new Follow() .withFollowee(new User().withId(id)) .withFollower(new User().withId(otherId)); } else if( endpoint.equals("friends") ) { follow = new Follow() .withFollowee(new User().withId(otherId)) .withFollower(new User().withId(id)); } else { throw new Exception("endpoint must be set to 'friends' or 'followers'"); } ComponentUtils.offerUntilSuccess(new StreamsDatum(follow), provider.providerQueue); } catch (Exception e) { LOGGER.warn(e.getMessage()); } } if( ids.hasNext() ) curser = ids.getNextCursor(); else break; } catch(TwitterException twitterException) { keepTrying += TwitterErrorHandler.handleTwitterError(client, twitterException); } catch(Exception e) { keepTrying += TwitterErrorHandler.handleTwitterError(client, e); } } while (curser != 0 && keepTrying < 10); }</code><technical_language>This is a roundabout, right? conditions ids == null is !endpoint.equals("followers") !endpoint.equals("friends"). Preconditions checking _that_, throwing a more verbose exception in case fails</technical_language>

Target:
private void collectIds(Long id) { int keepTrying = 0; long curser = -1; do { try { twitter4j.IDs ids = null; if( endpoint.equals("followers") ) ids = client.friendsFollowers().getFollowersIDs(id.longValue(), curser, max_per_page); else if( endpoint.equals("friends") ) ids = client.friendsFollowers().getFriendsIDs(id.longValue(), curser, max_per_page); Preconditions.checkNotNull(ids); Preconditions.checkArgument(ids.getIDs().length > 0); for (long otherId : ids.getIDs()) { try { Follow follow = null; if( endpoint.equals("followers") ) { follow = new Follow() .withFollowee(new User().withId(id)) .withFollower(new User().withId(otherId)); } else if( endpoint.equals("friends") ) { follow = new Follow() .withFollowee(new User().withId(otherId)) .withFollower(new User().withId(id)); } ComponentUtils.offerUntilSuccess(new StreamsDatum(follow), provider.providerQueue); Preconditions.checkNotNull(follow); } catch (Exception e) { LOGGER.warn("Exception: {}", e); } } if( ids.hasNext() ) curser = ids.getNextCursor(); else break; } catch(TwitterException twitterException) { keepTrying += TwitterErrorHandler.handleTwitterError(client, twitterException); } catch(Exception e) { keepTrying += TwitterErrorHandler.handleTwitterError(client, e); } } while (curser != 0 && keepTrying < 10); }
Source:
<code><START> public void updateGlobalPieChart() { <END> if (getGlobalPC() == null) { fGlobalPC = new PieChart(this, SWT.NONE); getGlobalPC().getTitle().setText(fGlobalPCname); getGlobalPC().getAxisSet().getXAxis(0).getTitle().setText(""); getGlobalPC().getLegend().setVisible(true); getGlobalPC().getLegend().setPosition(SWT.RIGHT); getGlobalPC().addListener(SWT.MouseMove, fMouseListener); } else if (getGlobalPC().isDisposed()) { return; } updatePieChartWithData(fGlobalPC, fGlobalEventTypes, MIN_PRECENTAGE_TO_SHOW_SLICE, fOthersSliceName); }</code><technical_language>For this method package visible</technical_language>

Target:
void updateGlobalPieChart() { if (getGlobalPC() == null) { fGlobalPC = new PieChart(this, SWT.NONE); getGlobalPC().getTitle().setText(fGlobalPCname); getGlobalPC().getAxisSet().getXAxis(0).getTitle().setText(""); getGlobalPC().getLegend().setVisible(true); getGlobalPC().getLegend().setPosition(SWT.RIGHT); getGlobalPC().addListener(SWT.MouseMove, fMouseListener); } else if (getGlobalPC().isDisposed() || fModel == null || fModel.getPieChartGlobalModel() == null) { return; } Map<String, Long> totalEventCountForChart = getTotalEventCountForChart(true); if(totalEventCountForChart == null){ return; } updatePieChartWithData(fGlobalPC, totalEventCountForChart, MIN_PRECENTAGE_TO_SHOW_SLICE, fOthersSliceName); }
Source:
<code>public void eachNonZeroInColumn(int j, MatrixProcedure procedure) { for (int i = 0; i < rows; i++) { <START> if (get(i, j) > Matrices.EPS) procedure.apply(i,j,get(i,j)); <END> } }</code><technical_language>Again: missed Math.abs() arround procedure.appy(...)</technical_language>

Target:
public void eachNonZeroInColumn(int j, MatrixProcedure procedure) { for (int i = 0; i < rows; i++) { if (Math.abs(get(i, j)) > Matrices.EPS) { procedure.apply(i, j, get(i, j)); } } }
Source:
<code>public void initialize() throws Exception { <START> String stringDoCommit = dspace.getConfigurationService().getProperty("discovery.index.commit"); <END> if(stringDoCommit!=null) { doCommit = Boolean.parseBoolean(stringDoCommit); } }</code><technical_language>getPropertyAsType method get a Boolean <LINK_0></technical_language>

Target:
public void initialize() throws Exception { softCommit = dspace.getConfigurationService().getPropertyAsType("discovery.index.nrt", true); }
Source:
<code>public void testPojoSerialization() throws IOException { SomeClassWithNoDefaultConstructors foo = new SomeClassWithNoDefaultConstructors("hello", 123); SomeClassWithNoDefaultConstructors foo2 = (SomeClassWithNoDefaultConstructors) codec.deserialize( codec.serialize(foo), <START> SomeClassWithNoDefaultConstructors.class); <END> assertEquals(foo, foo2); }</code><technical_language>agree casting is a redundant silly work..</technical_language>

Target:
public void testPojoSerialization() throws IOException { SomeClassWithNoDefaultConstructors foo = new SomeClassWithNoDefaultConstructors("hello", 123); SomeClassWithNoDefaultConstructors foo2 = codec.decode( codec.encode(foo), SomeClassWithNoDefaultConstructors.class); assertEquals(foo, foo2); }
Source:
<code>public void setUp() throws Exception { workspaceManager = spy(new WorkspaceManager(workspaceDao, runtimes, eventService, machineManager, userManager, false, false)); workspaceManager.setHooks(workspaceHooks); when(workspaceDao.create(any(WorkspaceImpl.class))).thenAnswer(invocation -> invocation.getArguments()[0]); when(workspaceDao.update(any(WorkspaceImpl.class))).thenAnswer(invocation -> invocation.getArguments()[0]); EnvironmentContext.setCurrent(new EnvironmentContext() { @Override public Subject getSubject() { <START> return new SubjectImpl(NAMESPACE, USER_ID, "token", new ArrayList<>(), false); <END> } }); }</code><technical_language>do need arraylist empty list</technical_language>

Target:
public void setUp() throws Exception { workspaceManager = spy(new WorkspaceManager(workspaceDao, runtimes, eventService, machineManager, userManager, false, false)); workspaceManager.setHooks(workspaceHooks); when(workspaceDao.create(any(WorkspaceImpl.class))).thenAnswer(invocation -> invocation.getArguments()[0]); when(workspaceDao.update(any(WorkspaceImpl.class))).thenAnswer(invocation -> invocation.getArguments()[0]); EnvironmentContext.setCurrent(new EnvironmentContext() { @Override public Subject getSubject() { return new SubjectImpl(NAMESPACE, USER_ID, "token", null, false); } }); }
Source:
<code>public static String getSessionToken(String url) { String token = "undefined"; try { String decodedURL = URLDecoder.decode(url, "UTF-8"); <START> String[] splitedURL = decodedURL.split("\\?"); <END> if (splitedURL.length == 2) { String params = splitedURL[1]; for (String param : params.split("\\&")) { if (param.startsWith("sessionToken=")) { token = param.split("\\=")[1]; } } } } catch (UnsupportedEncodingException e) { log.error(e.toString()); } return token; }</code><technical_language>Consider renaming splitedURL splitURL</technical_language>

Target:
public static String getSessionToken(String url) { String token = "undefined"; try { String decodedURL = URLDecoder.decode(url, "UTF-8"); String[] splitURL = decodedURL.split("\\?"); if (splitURL.length == 2) { String params = splitURL[1]; for (String param : params.split("\\&")) { if (param.startsWith("sessionToken=")) { token = param.split("\\=")[1]; } } } } catch (UnsupportedEncodingException e) { log.error(e.toString()); } return token; }
Source:
<code>public static int indexOfChangeId(String message, String delimiter) { String[] lines = message.split(delimiter); int footerFirstLine = findFirstFooterLine(lines); if (footerFirstLine == lines.length) return -1; int indexOfFooter = 0; <START> for (int i = 0; i < footerFirstLine; ++i) { <END> indexOfFooter += lines[i].length() + delimiter.length(); } return message.indexOf(CHANGE_ID, indexOfFooter); }</code><technical_language>style nit: braces</technical_language>

Target:
public static int indexOfChangeId(String message, String delimiter) { String[] lines = message.split(delimiter); int footerFirstLine = indexOfFirstFooterLine(lines); if (footerFirstLine == lines.length) return -1; int indexOfFooter = 0; for (int i = 0; i < footerFirstLine; ++i) { indexOfFooter += lines[i].length() + delimiter.length(); } return message.indexOf(CHANGE_ID, indexOfFooter); }