auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static @Nonnull String getExecutable(@CheckForNull String name, @CheckForNull Node node, @Nullable TaskListener listener, @CheckForNull EnvVars env) throws IOException, InterruptedException { if (name != null) { Jenkins j = Jenkins.getInstance(); if (j != null) { for (DockerTool tool : j.getDescriptorByType(DescriptorImpl.class).getInstallations()) { if (tool.getName().equals(name)) { if (node != null) { tool = tool.forNode(node, listener); } if (env != null) { tool = tool.forEnvironment(env); <START> } <END> String home = Util.fixEmpty(tool.getHome()); if (home != null) { return home + "/bin/docker"; } } } } } return COMMAND; }</code><technical_language>Is to: java if (env != null) { tool = tool.forEnvironment(env); } else if (node != null) { tool = tool.forNode(node, listener); } fact flows leg of if (imo) more shows env takes precedence node</technical_language>

Target:
public static @Nonnull String getExecutable(@CheckForNull String name, @CheckForNull Node node, @Nullable TaskListener listener, @CheckForNull EnvVars env) throws IOException, InterruptedException { if (name != null) { Jenkins j = Jenkins.getInstance(); if (j != null) { for (DockerTool tool : j.getDescriptorByType(DescriptorImpl.class).getInstallations()) { if (tool.getName().equals(name)) { if (node != null) { tool = tool.forNode(node, listener); } if (env != null) { tool = tool.forEnvironment(env); } String home = Util.fixEmpty(tool.getHome()); if (home != null) { if (node != null) { FilePath homeFP = node.createPath(home); if (homeFP != null) { return homeFP.child("bin/docker").getRemote(); } } return home + "/bin/docker"; } } } } } return COMMAND; }
Source:
<code>protected boolean isRegistered(final String uuid) { <START> return handlers.containsKey(uuid) && !handlers.get(uuid).isEmpty(); <END> }</code><technical_language>this case given? I entry for uuid registrations</technical_language>

Target:
protected boolean isRegistered(final String uuid) { return handlers.containsKey(uuid); }
Source:
<code>public DataStream<RowData> getDataStream(StreamExecutionEnvironment execEnv) { List<HiveTablePartition> allHivePartitions = initAllPartitions(); @SuppressWarnings("unchecked") TypeInformation<RowData> typeInfo = (TypeInformation<RowData>) TypeInfoDataTypeConverter.fromDataTypeToTypeInfo(getProducedDataType()); HiveTableInputFormat inputFormat = getInputFormat( allHivePartitions, flinkConf.get(HiveOptions.TABLE_EXEC_HIVE_FALLBACK_MAPRED_READER)); if (isStreamingSource()) { if (catalogTable.getPartitionKeys().isEmpty()) { throw new UnsupportedOperationException( <START> "Non-partition table not support streaming read now."); <END> } return createStreamSource(execEnv, typeInfo, inputFormat); } else { return createBatchSource(execEnv, typeInfo, inputFormat); } }</code><technical_language>></technical_language>

Target:
public DataStream<RowData> getDataStream(StreamExecutionEnvironment execEnv) { List<HiveTablePartition> allHivePartitions = initAllPartitions(); @SuppressWarnings("unchecked") TypeInformation<RowData> typeInfo = (TypeInformation<RowData>) TypeInfoDataTypeConverter.fromDataTypeToTypeInfo(getProducedDataType()); HiveTableInputFormat inputFormat = getInputFormat( allHivePartitions, flinkConf.get(HiveOptions.TABLE_EXEC_HIVE_FALLBACK_MAPRED_READER)); if (isStreamingSource()) { if (catalogTable.getPartitionKeys().isEmpty()) { throw new UnsupportedOperationException( "Non-partition table does not support streaming read now."); } return createStreamSource(execEnv, typeInfo, inputFormat); } else { return createBatchSource(execEnv, typeInfo, inputFormat); } }
Source:
<code>public void testTransitionProbabilities() { final double[] weights = MathUtils.normalizeFromRealSpace(new double[] {0.2, 0.2, 0.6, 0.1, 0.9, 0.1}); final double[] minorAlleleFractions = new double[] {0.1, 0.2, 0.3, 0.4, 0.23, 0.11}; final double memoryLength = 5e6; <START> AlleleFractionHiddenMarkovModel model = new AlleleFractionHiddenMarkovModel(minorAlleleFractions, weights, <END> memoryLength, AllelicPanelOfNormals.EMPTY_PON, NO_BIAS_OR_OUTLIERS_PARAMS); final int pos1 = 100; final int pos2 = (int) (pos1 + 100*memoryLength); final int pos3 = (int) (pos1 + memoryLength/1000); final SimpleInterval position1 = new SimpleInterval("chr1", pos1, pos1); final SimpleInterval position2 = new SimpleInterval("chr1", pos2, pos2); final SimpleInterval position3 = new SimpleInterval("chr1", pos3, pos3); for (int fromState = 0; fromState < weights.length; fromState++) { for (int toState = 0; toState < weights.length; toState++) { Assert.assertEquals(model.logTransitionProbability(fromState, position1, toState, position2), model.logPriorProbability(toState, position2), 1e-3); if (toState == fromState) { Assert.assertEquals(model.logTransitionProbability(fromState, position1, toState, position3), Math.log(1), 1e-3); } else { Assert.assertTrue(model.logTransitionProbability(fromState, position1, toState, position3) < Math.log(1e-3)); } } } }</code><technical_language>final</technical_language>

Target:
public void testTransitionProbabilities() { final double[] weights = MathUtils.normalizeFromRealSpace(new double[] {0.2, 0.2, 0.6, 0.1, 0.9, 0.1}); final double[] minorAlleleFractions = new double[] {0.1, 0.2, 0.3, 0.4, 0.23, 0.11}; final double memoryLength = 5e6; final AlleleFractionHiddenMarkovModel model = new AlleleFractionHiddenMarkovModel(minorAlleleFractions, weights, memoryLength, AllelicPanelOfNormals.EMPTY_PON, NO_BIAS_OR_OUTLIERS_PARAMS); final int pos1 = 100; final int pos2 = (int) (pos1 + 100*memoryLength); final int pos3 = (int) (pos1 + memoryLength/1000); final SimpleInterval position1 = new SimpleInterval("chr1", pos1, pos1); final SimpleInterval position2 = new SimpleInterval("chr1", pos2, pos2); final SimpleInterval position3 = new SimpleInterval("chr1", pos3, pos3); for (int fromState = 0; fromState < weights.length; fromState++) { for (int toState = 0; toState < weights.length; toState++) { Assert.assertEquals(model.logTransitionProbability(fromState, position1, toState, position2), model.logPriorProbability(toState, position2), 1e-3); if (toState == fromState) { Assert.assertEquals(model.logTransitionProbability(fromState, position1, toState, position3), Math.log(1), 1e-3); } else { Assert.assertTrue(model.logTransitionProbability(fromState, position1, toState, position3) < Math.log(1e-3)); } } } }
Source:
<code>public static Thread[] findThreadsByName(final String threadName) { if (threadName == null) { throw new IllegalArgumentException("The threadName must not be null"); } <START> final Thread[] allThreads = getAllThreads(); <END> final List<Thread> threads = new ArrayList<Thread>(); for (int i = 0; i < allThreads.length; i++) { final Thread thread = allThreads[i]; if (thread != null && threadName.equals(thread.getName())) { threads.add(thread); } } return threads.toArray(new Thread[threads.size()]); }</code><technical_language>this allocation wasteful, couldnt inline allthreads call check them</technical_language>

Target:
public static Collection<Thread> findThreadsByName(final String threadName) { return selectThreads(new NamePredicate(threadName)); }
Source:
<code>public void readFromNbt(NBTTagCompound compound) { this.reset(); NBTTagList nbttaglist = compound.getTagList("Inventory", 10); <START> this.inventory.readFromNBT(nbttaglist); <END> final NBTTagCompound spongeCompound = compound.getCompoundTag(NbtDataUtil.FORGE_DATA).getCompoundTag(NbtDataUtil.SPONGE_DATA); CustomDataNbtUtil.readCustomData(spongeCompound, ((DataHolder) this)); if (!spongeCompound.hasNoTags()) { final NBTTagList spawnList = spongeCompound.getTagList(NbtDataUtil.USER_SPAWN_LIST, NbtDataUtil.TAG_COMPOUND); for (int i = 0; i < spawnList.tagCount(); i++) { final NBTTagCompound spawnCompound = spawnList.getCompoundTagAt(i); final UUID uuid = spawnCompound.getUniqueId(NbtDataUtil.UUID); if (uuid.getLeastSignificantBits() != 0 && uuid.getMostSignificantBits() != 0) { final double xPos = spawnCompound.getDouble(NbtDataUtil.USER_SPAWN_X); final double yPos = spawnCompound.getDouble(NbtDataUtil.USER_SPAWN_Y); final double zPos = spawnCompound.getDouble(NbtDataUtil.USER_SPAWN_Z); final boolean forced = spawnCompound.getBoolean(NbtDataUtil.USER_SPAWN_FORCED); this.spawnLocations.put(uuid, new RespawnLocation.Builder() .forceSpawn(forced) .position(new Vector3d(xPos, yPos, zPos)) .world(uuid) .build()); } } } }</code><technical_language>s/"Inventory"/NbtDataUtil.INVENTORY thereof</technical_language>

Target:
public void readFromNbt(NBTTagCompound compound) { this.reset(); this.nbt = compound; final NBTTagCompound spongeCompound = compound.getCompoundTag(NbtDataUtil.FORGE_DATA).getCompoundTag(NbtDataUtil.SPONGE_DATA); CustomDataNbtUtil.readCustomData(spongeCompound, ((DataHolder) this)); if (!spongeCompound.hasNoTags()) { final NBTTagList spawnList = spongeCompound.getTagList(NbtDataUtil.USER_SPAWN_LIST, NbtDataUtil.TAG_COMPOUND); for (int i = 0; i < spawnList.tagCount(); i++) { final NBTTagCompound spawnCompound = spawnList.getCompoundTagAt(i); final UUID uuid = spawnCompound.getUniqueId(NbtDataUtil.UUID); if (uuid.getLeastSignificantBits() != 0 && uuid.getMostSignificantBits() != 0) { final double xPos = spawnCompound.getDouble(NbtDataUtil.USER_SPAWN_X); final double yPos = spawnCompound.getDouble(NbtDataUtil.USER_SPAWN_Y); final double zPos = spawnCompound.getDouble(NbtDataUtil.USER_SPAWN_Z); final boolean forced = spawnCompound.getBoolean(NbtDataUtil.USER_SPAWN_FORCED); this.spawnLocations.put(uuid, new RespawnLocation.Builder() .forceSpawn(forced) .position(new Vector3d(xPos, yPos, zPos)) .world(uuid) .build()); } } } }
Source:
<code>public void onFinish(@NonNull final PageTitle title) { try { client.get(title.getText(), new BecauseYouReadClient.BecauseYouReadCallback() { @Override public void success(MwQueryResponse<BecauseYouReadClient.Pages> pages) { if (!fragment.isAdded()) { return; } <START> fragment.addNewBecauseYouReadCard(title, pages); <END> } @Override public void failure(Throwable t) { L.w("Error fetching 'because you read' suggestions", t); } }); } catch (IOException e) { L.w("Error fetching 'because you read' suggestions", e); } }</code><technical_language>I for client pass in a simple callback interface. This avoid a weird dependency Fragments (and crazy lifecycle!)</technical_language>

Target:
public void onFinish(@NonNull final PageTitle title) { try { new BecauseYouReadClient(title.getSite()).get(title.getText(), new BecauseYouReadClient.BecauseYouReadCallback() { @Override public void success(MwQueryResponse<BecauseYouReadClient.Pages> pages) { cb.success(title, pages); } @Override public void failure(Throwable t) { L.w("Error fetching 'because you read' suggestions", t); } }); } catch (IOException e) { L.w("Error fetching 'because you read' suggestions", e); } }
Source:
<code>private boolean canCreateBrick(){ if (getItems() == null || getItems().isEmpty()) { return false; } <START> boolean canCreateBrick = false; for (StorageDevice device : getItems()) { if (device.getCanCreateBrick()) { canCreateBrick = true; break; } } if (canCreateBrick) { List<StorageDevice> selectedDevices = getSelectedItems(); if (selectedDevices != null) { for (StorageDevice device : selectedDevices) { if(!device.getCanCreateBrick()){ canCreateBrick = false; break; } } } } <END> return canCreateBrick; }</code><technical_language>Order of logic swapped. need for selectedDevices first. If devices selected, for devices</technical_language>

Target:
private boolean canCreateBrick(){ boolean canCreateBrick = false; List<StorageDevice> selectedDevices = getSelectedItems(); if (selectedDevices != null) { for (StorageDevice device : selectedDevices) { if (device.getCanCreateBrick()) { canCreateBrick = true; } else { canCreateBrick = false; break; } } } return canCreateBrick; }
Source:
<code>public void getGIIEventsReturnsCorrectEvents() { HARegionQueue spy = spy(haRegionQueue); List<EventID> giiEvents; spy.positionBeforeGII = 1; spy.positionAfterGII = 4; HAEventWrapper wrapper1 = mock(HAEventWrapper.class); HAEventWrapper wrapper2 = mock(HAEventWrapper.class); when(wrapper1.getEventId()).thenReturn(id1); when(wrapper2.getEventId()).thenReturn(id2); <START> Region.Entry entry1 = mock(Region.Entry.class); Region.Entry entry2 = mock(Region.Entry.class); Region.Entry entry3 = mock(Region.Entry.class); <END> when(entry1.getValue()).thenReturn(wrapper1); when(entry3.getValue()).thenReturn(wrapper2); when(entry2.getValue()).thenReturn(id3); when(haRegion.getEntry(1L)).thenReturn(entry1); when(haRegion.getEntry(2L)).thenReturn(entry2); when(haRegion.getEntry(3L)).thenReturn(null); when(haRegion.getEntry(4L)).thenReturn(entry3); giiEvents = spy.getGIIEvents(); assertThat(giiEvents.size()).isEqualTo(2); assertThat(giiEvents.contains(id1)); assertThat(giiEvents.contains(id2)); }</code><technical_language>IDE warnings for lines removed Region.Entry<Object,Object> entry1 = uncheckedCast(mock(Region.Entry.class)); Region.Entry<Object,Object> entry2 = uncheckedCast(mock(Region.Entry.class)); Region.Entry<Object,Object> entry3 = uncheckedCast(mock(Region.Entry.class));</technical_language>

Target:
public void getGIIEventsReturnsCorrectEvents() { HARegionQueue spy = spy(haRegionQueue); List<EventID> giiEvents; spy.positionBeforeGII = 1; spy.positionAfterGII = 4; HAEventWrapper wrapper1 = mock(HAEventWrapper.class); HAEventWrapper wrapper2 = mock(HAEventWrapper.class); when(wrapper1.getEventId()).thenReturn(id1); when(wrapper2.getEventId()).thenReturn(id2); Region.Entry<Object, Object> entry1 = uncheckedCast(mock(Region.Entry.class)); Region.Entry<Object, Object> entry2 = uncheckedCast(mock(Region.Entry.class)); Region.Entry<Object, Object> entry3 = uncheckedCast(mock(Region.Entry.class)); when(entry1.getValue()).thenReturn(wrapper1); when(entry2.getValue()).thenReturn(new Object()); when(entry3.getValue()).thenReturn(wrapper2); when(haRegion.getEntry(1L)).thenReturn(entry1); when(haRegion.getEntry(2L)).thenReturn(entry2); when(haRegion.getEntry(3L)).thenReturn(null); when(haRegion.getEntry(4L)).thenReturn(entry3); giiEvents = spy.getGIIEvents(); assertThat(giiEvents).containsExactlyInAnyOrder(id1, id2); }
Source:
<code>public <ClusterID> ClusterClientFactory<ClusterID> getClusterClientFactory(final Configuration configuration) { checkNotNull(configuration); final List<ClusterClientFactory> compatibleFactories = new ArrayList<>(); final Iterator<ClusterClientFactory> factories = defaultLoader.iterator(); while (factories.hasNext()) { try { final ClusterClientFactory factory = factories.next(); if (factory != null && factory.isCompatibleWith(configuration)) { compatibleFactories.add(factory); } } catch (Throwable e) { if (e.getCause() instanceof NoClassDefFoundError) { LOG.info("Could not load factory due to missing dependencies."); } else { throw e; } } } if (compatibleFactories.size() > 1) { final List<String> configStr = configuration.toMap().entrySet().stream() .map(e -> e.getKey() + "=" + e.getValue()) .collect(Collectors.toList()); throw new IllegalStateException("Multiple compatible client factories found for:\n" + String.join("\n", configStr) + "."); } if (compatibleFactories.isEmpty()) { throw new IllegalStateException( "No ClusterClientFactory found to execute the application." + " If you were targeting a Yarn cluster, please make sure to have " + <START> "hadoop in your classpath. For more information refer to the " + <END> "\"Deployment & Operations\" section of the official Apache Flink documentation."); } return (ClusterClientFactory<ClusterID>) compatibleFactories.get(0); }</code><technical_language>suggestion "Hadoop in classpath. For more information refer " + above, mention HADOOP_CLASSPATH</technical_language>

Target:
public <ClusterID> ClusterClientFactory<ClusterID> getClusterClientFactory(final Configuration configuration) { checkNotNull(configuration); final List<ClusterClientFactory> compatibleFactories = new ArrayList<>(); final Iterator<ClusterClientFactory> factories = defaultLoader.iterator(); while (factories.hasNext()) { try { final ClusterClientFactory factory = factories.next(); if (factory != null && factory.isCompatibleWith(configuration)) { compatibleFactories.add(factory); } } catch (Throwable e) { if (e.getCause() instanceof NoClassDefFoundError) { LOG.info("Could not load factory due to missing dependencies."); } else { throw e; } } } if (compatibleFactories.size() > 1) { final List<String> configStr = configuration.toMap().entrySet().stream() .map(e -> e.getKey() + "=" + e.getValue()) .collect(Collectors.toList()); throw new IllegalStateException("Multiple compatible client factories found for:\n" + String.join("\n", configStr) + "."); } if (compatibleFactories.isEmpty()) { throw new IllegalStateException( "No ClusterClientFactory found. If you were targeting a Yarn cluster, " + "please make sure to export the HADOOP_CLASSPATH environment variable or have hadoop in your " + "classpath. For more information refer to the \"Deployment & Operations\" section of the official " + "Apache Flink documentation."); } return (ClusterClientFactory<ClusterID>) compatibleFactories.get(0); }
Source:
<code>public void testEnoughSpaceToMergeSnapshotsWithMultipleDiskAndDomains() { <START> ArrayList<DiskImage> imagesDisks = mockMultipleSourceImagesForDomain(4, STORAGE_DOMAIN_ID, 4); <END> imagesDisks.addAll(mockMultipleSourceImagesForDomain(4, STORAGE_DOMAIN_ID2, 4)); doReturn(imagesDisks).when(cmd).getSourceImages(); mockStorageDomainDAOGetForStoragePool(22, STORAGE_DOMAIN_ID); mockStorageDomainDAOGetForStoragePool(22, STORAGE_DOMAIN_ID2); assertTrue("Validation should succeed. Free space minus threshold should be bigger then summarize all disks size for each domain", cmd.isEnoughSpaceToMergeSnapshots()); }</code><technical_language>this defined a List<DiskImage></technical_language>

Target:
public void testEnoughSpaceToMergeSnapshotsWithMultipleDiskAndDomains() { List<DiskImage> imagesDisks = mockMultipleSourceImagesForDomain(4, STORAGE_DOMAIN_ID, IMAGE_ACTUAL_SIZE_GB); imagesDisks.addAll(mockMultipleSourceImagesForDomain(4, STORAGE_DOMAIN_ID2, IMAGE_ACTUAL_SIZE_GB)); doReturn(imagesDisks).when(cmd).getSourceImages(); mockStorageDomainDAOGetForStoragePool(22, STORAGE_DOMAIN_ID); mockStorageDomainDAOGetForStoragePool(22, STORAGE_DOMAIN_ID2); assertTrue("Validation should succeed. Free space minus threshold should be bigger then summarize all disks size for each domain", cmd.isEnoughSpaceToMergeSnapshots()); }
Source:
<code><START> private String getLocalDateTime(Date modificationTime) {; <END> SimpleDateFormat dt = new SimpleDateFormat("EEE LLL dd yyyy", Locale.getDefault()); return dt.format(modificationTime); }</code><technical_language>Spare semicolon ;</technical_language>

Target:
private String getLocalDateTime(Date modificationTime) { SimpleDateFormat dt = new SimpleDateFormat("EEE LLL dd yyyy", Locale.getDefault()); return dt.format(modificationTime); }
Source:
<code>public List<Address> listAddresses(List<String> names, EntityStatus status) { List<Address> results = null; Session session = null; Query query; try { session = DaoUtils.getSession(); <START> if (names != null && !names.isEmpty()) { <END> query = session.getNamedQuery("getAddress"); query.setParameterList("emailList", names); } else { query = session.getNamedQuery("getAddressByStatus"); } query.setParameter("status", status == null ? status : status.ordinal()); results = query.list(); if (results == null) { results = new ArrayList<>(); } log.debug("Addresses found: " + results.size()); } catch (Exception e) { log.error("Exception while getting the list of addresses: ", e); } finally { DaoUtils.closeSession(session); } return results; }</code><technical_language>CollectionUtils.isNotEmpty apache commons here</technical_language>

Target:
public List<Address> listAddresses(List<String> names, EntityStatus status) { List<Address> results = null; Session session = null; Query query; try { session = DaoUtils.getSession(); if (CollectionUtils.isNotEmpty(names)) { query = session.getNamedQuery("getAddress"); query.setParameterList("emailList", names); } else { query = session.getNamedQuery("getAddressByStatus"); } query.setParameter("status", status == null ? status : status.ordinal()); results = query.list(); if (results == null) { results = new ArrayList<>(); } log.debug("Addresses found: " + results.size()); } finally { DaoUtils.closeSession(session); } return results; }
Source:
<code>public void testPushDownConstantFilterPredicate() { assertPlan( "SELECT sum(totalprice) FILTER(WHERE FALSE) FROM orders", anyTree( aggregation( ImmutableMap.of("sum_6", functionCall("sum", ImmutableList.of("totalprice"))), project( values("totalprice"))))); assertPlan( "SELECT sum(totalprice) FILTER(WHERE TRUE) FROM orders", <START> anyTree( <END> aggregation( ImmutableMap.of("sum", functionCall("sum", ImmutableList.of("sum_6"))), exchange( aggregation( ImmutableMap.of("sum_6", functionCall("sum", ImmutableList.of("totalprice"))), project( tableScan( "orders", ImmutableMap.of("totalprice", "totalprice")))))))); }</code><technical_language>instead like: com.facebook.presto.sql.planner.TestLogicalPlanner#assertPlanContainsNoApplyOrAnyJoin if is filter node</technical_language>

Target:
public void testPushDownConstantFilterPredicate() { assertPlanContainsNoFilter("SELECT sum(totalprice) FILTER(WHERE FALSE) FROM orders"); assertPlanContainsNoFilter("SELECT sum(totalprice) FILTER(WHERE TRUE) FROM orders"); }
Source:
<code><START> public byte[] unwrapKey(KeyWrapAlgorithm algorithm, byte[] encryptedKey) { <END> return withContext(context -> client.unwrapKey(algorithm, encryptedKey, context)).block(); }</code><technical_language>byte[] [](start = 11, length = 6) KeyUnwrapResult property key</technical_language>

Target:
public KeyUnwrapResult unwrapKey(KeyWrapAlgorithm algorithm, byte[] encryptedKey) { return unwrapKey(algorithm, encryptedKey, Context.NONE); }
Source:
<code>public void onApplicationEvent(ContextRefreshedEvent event) { ConfigurableApplicationContext ctx = (ConfigurableApplicationContext) event.getSource(); if (!ObjectUtils.isEmpty(this.properties.getProperties())) { for (PropertySource source : ctx.getEnvironment().getPropertySources()) { if (source instanceof EnumerablePropertySource) { EnumerablePropertySource e = (EnumerablePropertySource) source; for (String propertyName : e.getPropertyNames()) { RelaxedNames relaxedNames = new RelaxedNames(propertyName); <START> outer: for (String relaxedPropertyName : relaxedNames) { <END> if (isMatch(relaxedPropertyName, this.properties.getProperties(), null)) { whitelistedProperties.put(RelaxedPropertiesUtils.findCanonicalFormat(relaxedNames), source.getProperty(propertyName)); break outer; } } } } } } }</code><technical_language>label "outer" is a bit confusing this for loop is nested in another for loop</technical_language>

Target:
public void onApplicationEvent(ContextRefreshedEvent event) { ConfigurableApplicationContext ctx = (ConfigurableApplicationContext) event.getSource(); if (!ObjectUtils.isEmpty(this.properties.getProperties())) { for (PropertySource source : ctx.getEnvironment().getPropertySources()) { if (source instanceof EnumerablePropertySource) { EnumerablePropertySource e = (EnumerablePropertySource) source; for (String propertyName : e.getPropertyNames()) { RelaxedNames relaxedNames = new RelaxedNames(propertyName); relaxedLoop: for (String relaxedPropertyName : relaxedNames) { if (isMatch(relaxedPropertyName, this.properties.getProperties(), null)) { whitelistedProperties.put(RelaxedPropertiesUtils.findCanonicalFormat(relaxedNames), source.getProperty(propertyName)); break relaxedLoop; } } } } } } }
Source:
<code>public void beginWindow(long windowId) { if (simulateFailureWindows > 0 && ((simulateFailureAfterCommit && committed) || !simulateFailureAfterCommit) && !failureSimulated) { <START> LOG.info("FailableFibonacciOperator beginWindow {}", windowId, windowCount, simulateFailureWindows); <END> if (windowCount++ == simulateFailureWindows) { failureSimulated = true; LOG.info("FailableFibonacciOperator is simulating failure"); throw new RuntimeException("simulating failure"); } } }</code><technical_language>this INFO level logging? I removed DEBUG</technical_language>

Target:
public void beginWindow(long windowId) { if (simulateFailureWindows > 0 && ((simulateFailureAfterCommit && committed) || !simulateFailureAfterCommit) && !failureSimulated) { LOG.debug("FailableFibonacciOperator beginWindow {}", windowId, windowCount, simulateFailureWindows); if (windowCount++ == simulateFailureWindows) { failureSimulated = true; LOG.debug("FailableFibonacciOperator is simulating failure"); throw new RuntimeException("simulating failure"); } } }
Source:
<code>public boolean equals(Object obj) { if (obj == this) { return true; } if (obj == null) { return false; } if (obj instanceof ReferenceBindingSetWrapper) { ReferenceBindingSetWrapper other = (ReferenceBindingSetWrapper) obj; <START> return this.referenceBinding.equals(other.referenceBinding); <END> } return false; }</code><technical_language>This referenceBinding == other.referenceBinding (see ObjectVector.containsIdentical())</technical_language>

Target:
public boolean equals(Object obj) { if (obj == this) { return true; } if (obj == null) { return false; } if (obj instanceof ReferenceBindingSetWrapper) { ReferenceBindingSetWrapper other = (ReferenceBindingSetWrapper) obj; return identityEqual(this.referenceBinding, other.referenceBinding); } return false; }
Source:
<code>private static List<Type> removeRedundantBounds(final Type[] bounds) { if (bounds.length == 1) { <START> return Collections.unmodifiableList(new ArrayList<Type>() { { add(bounds[0]); } }); <END> } List<Type> result = new ArrayList<Type>(); for (int i = 0; i < bounds.length; i++) { boolean isRedundant = false; for (int j = 0; j < bounds.length && i != j; j++) { if (Reflections.getRawType(bounds[i]).isAssignableFrom(Reflections.getRawType(bounds[j]))) { isRedundant = true; break; } } if (!isRedundant) { result.add(bounds[i]); } } return result; }</code><technical_language>want is Collections.singleton()</technical_language>

Target:
private static List<Type> removeRedundantBounds(final Type[] bounds) { if (bounds.length == 1) { return Collections.singletonList(bounds[0]); } List<Type> result = new LinkedList<Type>(); for (int i = 0; i < bounds.length; i++) { boolean isRedundant = false; for (int j = 0; j < bounds.length && i != j; j++) { if (Reflections.getRawType(bounds[i]).isAssignableFrom(Reflections.getRawType(bounds[j]))) { isRedundant = true; break; } } if (!isRedundant) { result.add(bounds[i]); } } return result; }
Source:
<code>public void execute() throws BuildException { String generatedPassword=""; if (addproperty == null || addproperty.equals("")) { throw new BuildException("\tThe output property is required for this task."); } if (password == null || password.equals("")) { throw new BuildException("\tThe password property is required for this task."); } try { MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(password.getBytes()); byte[] bytes = md.digest(); <START> generatedPassword = new String(Base64.encodeBase64(bytes)); <END> } catch (NoSuchAlgorithmException e) { throw new BuildException("\tThere is a problem encrypting the password with MD5 algorithm"); } if (addproperty != null && !addproperty.equals("")) { getProject().setProperty(addproperty, generatedPassword); } }</code><technical_language>If include commons-codec a dependency, I replace block of code this: generatedPassword = DigestUtils.sha256Hex(password);</technical_language>

Target:
public void execute() throws BuildException { String generatedPassword=""; if (addproperty == null || addproperty.equals("")) { throw new BuildException("\tThe output property is required for this task."); } if (password == null || password.equals("")) { throw new BuildException("\tThe password property is required for this task."); } generatedPassword = DigestUtils.sha256Hex(password); if (addproperty != null && !addproperty.equals("")) { getProject().setProperty(addproperty, generatedPassword); } }
Source:
<code>public void addPersistentProperty(ElasticsearchPersistentProperty property) { super.addPersistentProperty(property); if (property.isParentProperty()) { ElasticsearchPersistentProperty parentProperty = this.parentIdProperty; if (parentProperty != null) { throw new MappingException( String.format("Attempt to add parent property %s but already have property %s registered " + "as version. Check your mapping configuration!", property.getField(), parentProperty.getField())); } <START> Assert.isTrue(property.getType() == String.class, String.format("Parent property %s must be of type String", property.getField())); <END> Parent parentAnnotation = property.getType().getAnnotation(Parent.class); this.parentIdProperty = property; this.parentType = parentAnnotation.type(); } if (property.isVersionProperty()) { Assert.isTrue(property.getType() == Long.class, String.format("Version property %s must be of type Long", property.getField())); } }</code><technical_language>move fundamental type constraints implementation of ElasticsearchPersistentProperty fail faster</technical_language>

Target:
public void addPersistentProperty(ElasticsearchPersistentProperty property) { super.addPersistentProperty(property); if (property.isParentProperty()) { ElasticsearchPersistentProperty parentProperty = this.parentIdProperty; if (parentProperty != null) { throw new MappingException( String.format("Attempt to add parent property %s but already have property %s registered " + "as parent property. Check your mapping configuration!", property.getField(), parentProperty.getField())); } Parent parentAnnotation = property.findAnnotation(Parent.class); this.parentIdProperty = property; this.parentType = parentAnnotation.type(); } if (property.isScoreProperty()) { ElasticsearchPersistentProperty scoreProperty = this.scoreProperty; if (scoreProperty != null) { throw new MappingException( String.format("Attempt to add score property %s but already have property %s registered " + "as score property. Check your mapping configuration!", property.getField(), scoreProperty.getField())); } this.scoreProperty = property; } }
Source:
<code>public void provision(String projectName) throws InfrastructureException { OpenShiftClient osClient = clientFactory.createOC(); String stopWorkspacesRoleName = "workspace-stop"; if (osClient.roles().inNamespace(projectName).withName(stopWorkspacesRoleName).get() == null) { createStopWorkspacesRole(osClient, stopWorkspacesRoleName, projectName); } osClient .roleBindings() .inNamespace(projectName) <START> .createOrReplace(createStopWorkspacesRoleBinding(projectName)); <END> }</code><technical_language>technically speaking installationLocation null based implementation, in this case log error avoid in provision method</technical_language>

Target:
public void provision(String projectName) throws InfrastructureException { if (stopWorkspaceRoleEnabled && installationLocation != null) { OpenShiftClient osClient = clientFactory.createOC(); String stopWorkspacesRoleName = "workspace-stop"; if (osClient.roles().inNamespace(projectName).withName(stopWorkspacesRoleName).get() == null) { osClient .roles() .inNamespace(projectName) .createOrReplace(createStopWorkspacesRole(stopWorkspacesRoleName)); } osClient .roleBindings() .inNamespace(projectName) .createOrReplace(createStopWorkspacesRoleBinding(projectName)); } else { LOG.warn( "Stop workspace Role and RoleBinding will not be provisioned to the '{}' namespace. 'che.workspace.stop.role.enabled' property is set to '{}'", installationLocation, stopWorkspaceRoleEnabled); } }
Source:
<code><START> public void onThemesChanged(ThemeStore.OnThemesChanged event) { <END> if (mThemeBrowserFragment != null) { mThemeBrowserFragment.setRefreshing(false); mThemeBrowserFragment.refreshView(); } if (event.origin == ThemeAction.FETCH_INSTALLED_THEMES) { mIsFetchingInstalledPlugins = false; } if (event.isError()) { AppLog.e(T.THEMES, "Error fetching themes: " + event.error.message); ToastUtils.showToast(this, R.string.theme_fetch_failed, ToastUtils.Duration.SHORT); } else { if (event.origin == ThemeAction.FETCH_WP_COM_THEMES) { AppLog.d(T.THEMES, "WordPress.com Theme fetch successful!"); AppPrefs.setLastWpComThemeSync(System.currentTimeMillis()); } else if (event.origin == ThemeAction.FETCH_INSTALLED_THEMES) { AppLog.d(T.THEMES, "Installed themes fetch successful!"); } } }</code><technical_language>implementation of this callback correct, feels a bit messy. kind of I generally prefer separating events if possible. A bit of a organization of code well, required. leaving general feedback here</technical_language>

Target:
public void onThemesChanged(ThemeStore.OnThemesChanged event) { if (mThemeBrowserFragment != null) { mThemeBrowserFragment.setRefreshing(false); mThemeBrowserFragment.refreshView(); } if (event.origin == ThemeAction.FETCH_INSTALLED_THEMES) { mIsFetchingInstalledThemes = false; } if (event.isError()) { AppLog.e(T.THEMES, "Error fetching themes: " + event.error.message); ToastUtils.showToast(this, R.string.theme_fetch_failed, ToastUtils.Duration.SHORT); } else { if (event.origin == ThemeAction.FETCH_WP_COM_THEMES) { AppLog.d(T.THEMES, "WordPress.com Theme fetch successful!"); AppPrefs.setLastWpComThemeSync(System.currentTimeMillis()); } else if (event.origin == ThemeAction.FETCH_INSTALLED_THEMES) { AppLog.d(T.THEMES, "Installed themes fetch successful!"); } } }
Source:
<code>protected void doGet(HttpServletRequest request, HttpServletResponse response) { Optional<String> publishIdOptional = Optional.ofNullable(request.getParameter("publish_id")); if (publishIdOptional.isEmpty()) { return; } String publishId = publishIdOptional.get(); db.single(Publish.class).where("publish_id=?", publishId).execute().ifPresent(publish -> { Optional<String> encode = Optional.ofNullable(request.getParameter("encode")); String fileName = publishId + ".csv"; <START> boolean showHeader = Boolean.parseBoolean(request.getParameter("header")); <END> csvDownload(response, fileName, publish.getDatasource(), publish.getQueryId(), encode.orElse(DEFAULT_ENCODE), showHeader); }); }</code><technical_language>if header is null, showHeader true</technical_language>

Target:
protected void doGet(HttpServletRequest request, HttpServletResponse response) { Optional<String> publishIdOptional = Optional.ofNullable(request.getParameter("publish_id")); if (publishIdOptional.isEmpty()) { return; } String publishId = publishIdOptional.get(); db.single(Publish.class).where("publish_id=?", publishId).execute().ifPresent(publish -> { Optional<String> encode = Optional.ofNullable(request.getParameter("encode")); String fileName = publishId + ".csv"; boolean showHeader = getOrDefaultParameter(request, "header", true); csvDownload(response, fileName, publish.getDatasource(), publish.getQueryId(), encode.orElse(DEFAULT_ENCODE), showHeader); }); }
Source:
<code>public static boolean parseReturningKeyword(final char[] query, int offset) { if (query.length < (offset + 9)) { return false; } <START> return (query[offset - 1] == ' ') <END> && (query[offset] | 32) == 'r' && (query[offset + 1] | 32) == 'e' && (query[offset + 2] | 32) == 't' && (query[offset + 3] | 32) == 'u' && (query[offset + 4] | 32) == 'r' && (query[offset + 5] | 32) == 'n' && (query[offset + 6] | 32) == 'i' && (query[offset + 7] | 32) == 'n' && (query[offset + 8] | 32) == 'g' && (query[offset + 9] == ' '); }</code><technical_language>I if "whitespace" handling incorporated call site of parseReturningKeyword other parseXYZKeyword. way: tab, newline trigger defeat query[offset - 1] == ' ' kind of check</technical_language>

Target:
public static boolean parseReturningKeyword(final char[] query, int offset) { if (query.length < (offset + 9)) { return false; } return (query[offset] | 32) == 'r' && (query[offset + 1] | 32) == 'e' && (query[offset + 2] | 32) == 't' && (query[offset + 3] | 32) == 'u' && (query[offset + 4] | 32) == 'r' && (query[offset + 5] | 32) == 'n' && (query[offset + 6] | 32) == 'i' && (query[offset + 7] | 32) == 'n' && (query[offset + 8] | 32) == 'g'; }
Source:
<code>void denyUserInTree(String userName, String resourceId, String action, boolean updateCache) throws UserStoreException { write.lock(); try { SearchResult sr = getNode(root, PermissionTreeUtil.toComponenets(resourceId)); if (sr.getUnprocessedPaths() != null) { List<String> paths = sr.getUnprocessedPaths(); TreeNode tn = sr.getLastNode().create(paths); tn.denyUser(userName, PermissionTreeUtil.actionToPermission(action)); } else { sr.getLastNode().denyUser(userName, PermissionTreeUtil.actionToPermission(action)); } if (updateCache) { invalidateCache(root); } } catch (Exception e) { <START> throw new UserStoreException(e.getMessage(),e); <END> } finally { write.unlock(); } }</code><technical_language>Add context specific message e.getMessage()</technical_language>

Target:
void denyUserInTree(String userName, String resourceId, String action, boolean updateCache) throws UserStoreException { write.lock(); try { SearchResult sr = getNode(root, PermissionTreeUtil.toComponenets(resourceId)); if (sr.getUnprocessedPaths() != null) { List<String> paths = sr.getUnprocessedPaths(); TreeNode tn = sr.getLastNode().create(paths); tn.denyUser(userName, PermissionTreeUtil.actionToPermission(action)); } else { sr.getLastNode().denyUser(userName, PermissionTreeUtil.actionToPermission(action)); } if (updateCache) { invalidateCache(root); } } catch (IllegalArgumentException e) { throw new UserStoreException("Error while denying user: " + userName + "in permission tree for resource id: " + resourceId + "for action: " + action, e); } finally { write.unlock(); } }
Source:
<code>public static void main(String[] args) throws GeneralSecurityException, IOException, URISyntaxException { PipelineOptionsFactory.register(Options.class); pipelineOptions = PipelineOptionsFactory.fromArgs(args) .withValidation().as(Options.class); Options.Methods.validateOptions(pipelineOptions); pipelineOptions.setTempLocation(pipelineOptions.getTempPath()); auth = GenomicsOptions.Methods.getGenomicsAuth(pipelineOptions); p = Pipeline.create(pipelineOptions); String BAMFilePath = pipelineOptions.getBAMFilePath(); if (!Strings.isNullOrEmpty(BAMFilePath)) { if (GCSURLExists(BAMFilePath)) { System.out.println(BAMFilePath + " is present, good."); } else { System.out.println("Error: " + BAMFilePath + " not found."); return; } if (pipelineOptions.isShardBAMReading()) { String BAMIndexPath = BAMFilePath + ".bai"; <START> if (GCSURLExists(BAMIndexPath)) { <END> System.out.println(BAMIndexPath + " is present, good."); } else { System.out.println("Error: " + BAMIndexPath + " not found."); return; } } } PCollection<Read> reads = getReads(); reads.apply(ParDo.of(new ReadToRowConverter())) .apply(BigQueryIO.writeTableRows() .to(pipelineOptions.getBigQueryTablePath()) .withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED) .withSchema(ReadToRowConverter.getSchema())); PipelineResult result = p.run(); if(pipelineOptions.getWait()) { result.waitUntilFinish(); } }</code><technical_language>I need index is present, error message a user on. "Index file [path file] found. index is required for sharded export." for example</technical_language>

Target:
public static void main(String[] args) throws GeneralSecurityException, IOException, URISyntaxException { PipelineOptionsFactory.register(Options.class); pipelineOptions = PipelineOptionsFactory.fromArgs(args) .withValidation().as(Options.class); Options.Methods.validateOptions(pipelineOptions); pipelineOptions.setTempLocation(pipelineOptions.getTempPath()); auth = GenomicsOptions.Methods.getGenomicsAuth(pipelineOptions); p = Pipeline.create(pipelineOptions); String BamFilePath = pipelineOptions.getBamFilePath(); if (!Strings.isNullOrEmpty(BamFilePath)) { try { checkGcsUrlExists(BamFilePath); } catch (Exception x) { System.err.println("Error: BAM file " + BamFilePath + " not found. A BAM file is " + "required."); System.err.println("Exception: " + x.getMessage()); return; } if (pipelineOptions.getMaxShardSizeMB() > 0) { String BamIndexPath = BamFilePath + ".bai"; try { checkGcsUrlExists(BamIndexPath); } catch (Exception x) { System.err.println("Error: Index file " + BamIndexPath + " not found. An index is " + "required for sharded export."); System.err.println("Exception: " + x.getMessage()); return; } } } PCollection<Read> reads = getReadsFromBamFile(); reads.apply(ParDo.of(new ReadToRowConverter())) .apply(BigQueryIO.writeTableRows() .to(pipelineOptions.getBigQueryTablePath()) .withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED) .withSchema(ReadToRowConverter.getSchema())); PipelineResult result = p.run(); if (pipelineOptions.getWait()) { result.waitUntilFinish(); } }
Source:
<code>public static void checkDirectoryStructure(File dir) throws IOException { if (!dir.exists()) { File parent = dir.getParentFile(); File preV3versionFile = new File(dir.getParent(), BookKeeperConstants.VERSION_FILENAME); final AtomicBoolean oldDataExists = new AtomicBoolean(false); <START> parent.list((dir1, name) -> { <END> if (name.endsWith(".txn") || name.endsWith(".idx") || name.endsWith(".log")) { oldDataExists.set(true); } return true; }); if (preV3versionFile.exists() || oldDataExists.get()) { String err = "Directory layout version is less than 3, upgrade needed"; LOG.error(err); throw new IOException(err); } if (!dir.mkdirs()) { String err = "Unable to create directory " + dir; LOG.error(err); throw new IOException(err); } } }</code><technical_language>nit: is necessary</technical_language>

Target:
public static void checkDirectoryStructure(File dir) throws IOException { if (!dir.exists()) { File parent = dir.getParentFile(); File preV3versionFile = new File(dir.getParent(), BookKeeperConstants.VERSION_FILENAME); final AtomicBoolean oldDataExists = new AtomicBoolean(false); parent.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { if (name.endsWith(".txn") || name.endsWith(".idx") || name.endsWith(".log")) { oldDataExists.set(true); } return true; } }); if (preV3versionFile.exists() || oldDataExists.get()) { String err = "Directory layout version is less than 3, upgrade needed"; LOG.error(err); throw new IOException(err); } if (!dir.mkdirs()) { String err = "Unable to create directory " + dir; LOG.error(err); throw new IOException(err); } } }
Source:
<code>private Point getBlockTransclusionLocation(int index) { <START> String boundingScript = "return jQuery.data( $('" + blockTransclusionString + "')["+ index +"] ).view.getBoundingRect();"; <END> JavascriptExecutor js = (JavascriptExecutor) driver; Object templateBounding = js.executeScript(boundingScript); JSONObject json; int tempLeft = 0, tempTop = 0; try { json = new JSONObject(templateBounding.toString()); tempLeft = (int) json.get("left"); tempTop = (int) json.get("top"); } catch (JSONException e) { e.printStackTrace(); } return new Point(tempLeft, tempTop); }</code><technical_language>I if move this VEContent.java in ContentPatterns package. similar Palantir javascripts put PalantirContent class</technical_language>

Target:
private Point getBlockTransclusionLocation(int index) { JavascriptExecutor js = (JavascriptExecutor) driver; Object templateBounding = js.executeScript(VEContent.boundingScript, blockTransclusionString, index); JSONObject json; int tempLeft = 0, tempTop = 0; try { json = new JSONObject(templateBounding.toString()); tempLeft = (int) json.get("left"); tempTop = (int) json.get("top"); } catch (JSONException e) { e.printStackTrace(); } return new Point(tempLeft, tempTop); }
Source:
<code>public Object getMetricObjectValue(int rowOffset, int aggOffset) { final Aggregator[] aggs = aggList.get(rowOffset); <START> if (null == aggs) { <END> return null; } return aggs[aggOffset].get(); }</code><technical_language>I allow this condition happen. returned null in 0.6, this devastating for complex metrics assume some initial non-null (e.g. HLL)</technical_language>

Target:
public Object getMetricObjectValue(int rowOffset, int aggOffset) { return concurrentGet(rowOffset)[aggOffset].get(); }
Source:
<code>public synchronized void stop(StopContext context) { for (JarFile jarFile : jarFiles) { log.debugf("Closing %s jar file which was added as resource root for %s module identifier", jarFile.toString(), moduleIdentifier.getName()); VFSUtils.safeClose(jarFile); <START> log.debugf("Closed %s jar file which was added as resource root for %s module identifier", jarFile.toString(), moduleIdentifier.getName()); <END> } jarFiles.clear(); jarFiles = null; moduleDefinition = null; }</code><technical_language>debug statements add much, jarFile.toString() is getClass().getName() + "@" + Integer.toHexString(hashCode()) file sufficient</technical_language>

Target:
public synchronized void stop(StopContext context) { for (JarFile jarFile : jarFiles) { log.debugf("Closing %s jar file which was added as resource root for %s module identifier", jarFile.getName(), moduleIdentifier.getName()); VFSUtils.safeClose(jarFile); } jarFiles.clear(); jarFiles = null; moduleDefinition = null; }
Source:
<code>public boolean shouldSkipField(FieldAttributes f) { boolean skip = super.shouldSkipField(f); if (!skip) { <START> LogLevel logLevel = f.getAnnotation(LogLevel.class); <END> skip = (logLevel != null && logLevel.value() == Log4jLevel.Off); } return skip; }</code><technical_language>suggest: Param sensitivity = f.getAnnotation(Param.class); skip = (sensitivity != null && sensitivity.isSensitive()); extra changes needed fro this response classes</technical_language>

Target:
public boolean shouldSkipField(FieldAttributes f) { Param param = f.getAnnotation(Param.class); boolean skip = (param != null && param.isSensitive()); if (!skip) { skip = super.shouldSkipField(f); } return skip; }
Source:
<code>private String removeSpacesAroundRDN(String dn) { <START> if (dn == null || StringUtils.isEmpty(dn)) { <END> return dn; } List<String> strings = new ArrayList<>(); String[] splitted = dn.split(","); for (String aSplitted : splitted) { String element = aSplitted.trim(); strings.add(element); } StringBuilder sb = new StringBuilder(); Iterator<String> idIterator = strings.iterator(); while (idIterator.hasNext()){ sb.append(idIterator.next().trim()); if (idIterator.hasNext()) sb.append(','); } return sb.toString(); }</code><technical_language>I stringUtils.isEmpty returns true for null string. check condition skipped</technical_language>

Target:
private String removeSpacesAroundRDN(String dn) { if (StringUtils.isEmpty(dn)) { return dn; } List<String> strings = new ArrayList<>(); String[] splitted = dn.split(","); for (String aSplitted : splitted) { String element = aSplitted.trim(); strings.add(element); } StringBuilder sb = new StringBuilder(); Iterator<String> idIterator = strings.iterator(); while (idIterator.hasNext()){ sb.append(idIterator.next().trim()); if (idIterator.hasNext()) sb.append(','); } return sb.toString(); }