auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testThatCodeForDecoratedMapperWorks() { Target mappedTarget = DecoratedUsesPlainMapper.INSTANCE.toTarget( this.source ); assertThat( mappedTarget ).isNotNull(); <START> assertThat( mappedTarget ).isEqualTo( this.target ); <END> }</code><technical_language>I meant.. assertThat fields in order is culprit in case of failure.</technical_language>

Target:
public void testThatCodeForDecoratedMapperWorks() { Target mappedTarget = DecoratedUsesPlainMapper.INSTANCE.toTarget( this.source ); assertThatSourceWasMappedCorrectly( mappedTarget ); }
Source:
<code>public static boolean isInstanceSetup(HelixZkClient zkclient, String clusterName, String instanceName, InstanceType type) { if (type == InstanceType.PARTICIPANT || type == InstanceType.CONTROLLER_PARTICIPANT) { ArrayList<String> requiredPaths = new ArrayList<>(); requiredPaths.add(PropertyPathBuilder.instanceConfig(clusterName, instanceName)); requiredPaths.add(PropertyPathBuilder.instanceMessage(clusterName, instanceName)); requiredPaths.add(PropertyPathBuilder.instanceCurrentState(clusterName, instanceName)); <START> requiredPaths.add(PropertyPathBuilder.instanceCustomizedState(clusterName, instanceName)); <END> requiredPaths.add(PropertyPathBuilder.instanceStatusUpdate(clusterName, instanceName)); requiredPaths.add(PropertyPathBuilder.instanceError(clusterName, instanceName)); boolean isValid = true; for (String path : requiredPaths) { if (!zkclient.exists(path)) { isValid = false; logger.error("Invalid instance setup, missing znode path: {}", path); } } if (isValid) { String historyPath = PropertyPathBuilder.instanceHistory(clusterName, instanceName); if (!zkclient.exists(historyPath)) { zkclient.createPersistent(historyPath, true); } } return isValid; } return true; }</code><technical_language>this is required path? a good idea add this. If add this existing product Helix library for participant check failure Instance is created</technical_language>

Target:
public static boolean isInstanceSetup(HelixZkClient zkclient, String clusterName, String instanceName, InstanceType type) { if (type == InstanceType.PARTICIPANT || type == InstanceType.CONTROLLER_PARTICIPANT) { ArrayList<String> requiredPaths = new ArrayList<>(); requiredPaths.add(PropertyPathBuilder.instanceConfig(clusterName, instanceName)); requiredPaths.add(PropertyPathBuilder.instanceMessage(clusterName, instanceName)); requiredPaths.add(PropertyPathBuilder.instanceCurrentState(clusterName, instanceName)); requiredPaths.add(PropertyPathBuilder.instanceStatusUpdate(clusterName, instanceName)); requiredPaths.add(PropertyPathBuilder.instanceError(clusterName, instanceName)); boolean isValid = true; for (String path : requiredPaths) { if (!zkclient.exists(path)) { isValid = false; logger.error("Invalid instance setup, missing znode path: {}", path); } } if (isValid) { String historyPath = PropertyPathBuilder.instanceHistory(clusterName, instanceName); if (!zkclient.exists(historyPath)) { zkclient.createPersistent(historyPath, true); } } return isValid; } return true; }
Source:
<code>public void testAddObjectDepth2() { <START> JsonNode n = new ObjectNode(JsonNodeFactory.instance); <END> ((ObjectNode) n).set("o", new ObjectNode(JsonNodeFactory.instance)); n.add(JsonPointer.compile("/o/i"), ONE); assertEquals(1, n.at("/o/i").asInt()); }</code><technical_language>Suggestion here; JsonNodeFactory.instance, factory methods for creating ObjectNodes (etc) -- for other usage of course. Or, if tests ObjectMapper, array/object node factory methods</technical_language>

Target:
public void testAddObjectDepth2() { ObjectNode n = objectMapper().createObjectNode(); n.set("o", n.objectNode()); n.add(JsonPointer.compile("/o/i"), n.numberNode(1)); assertEquals(1, n.at("/o/i").asInt()); }
Source:
<code>public void createActivity(WorkspaceActivity activity) throws ConflictException, ServerException { try { doCreate(activity); } catch (IntegrityConstraintViolationException e) { throw new ServerException( String.format( "Can not create activity record since the specified workspace with " + "id '%s' does not exist.", activity.getWorkspaceId()), e); } catch (DuplicateKeyException e) { throw new ConflictException( "Activity record for workspace ID " + activity.getWorkspaceId() + " already exists.", e); } catch (RuntimeException e) { <START> throw new ServerException(e.getLocalizedMessage(), e); <END> } }</code><technical_language>getMessage() in remove() .getLocalizedMessage() is done here</technical_language>

Target:
public void createActivity(WorkspaceActivity activity) throws ConflictException, ServerException { try { doCreate(activity); } catch (IntegrityConstraintViolationException e) { throw new ServerException( String.format( "Can not create activity record since the specified workspace with " + "id '%s' does not exist.", activity.getWorkspaceId()), e); } catch (DuplicateKeyException e) { throw new ConflictException( "Activity record for workspace ID " + activity.getWorkspaceId() + " already exists.", e); } catch (RuntimeException e) { throw new ServerException(e.getMessage(), e); } }
Source:
<code>public Program saveProgram(Program program) throws APIException { if (program.getConcept() == null) { throw new APIException("Program.concept.required", (Object[]) null); } for (ProgramWorkflow workflow : program.getAllWorkflows()) { ensureProgramIsSet(workflow, program); if (!workflow.getProgram().equals(program)) { <START> throw new APIException("Program.error.contains.ProgramWorkflow", new Object[] { workflow.getProgram() }); <END> } for (ProgramWorkflowState state : workflow.getStates()) { ensureProgramWorkflowIsSet(state, workflow); } } return dao.saveProgram(program); }</code><technical_language>@HVFrancis this if clause stay in APIException("ProgramWorkflow.concept.required"</technical_language>

Target:
public Program saveProgram(Program program) throws APIException { if (program.getConcept() == null) { throw new APIException("Program.concept.required", (Object[]) null); } for (ProgramWorkflow workflow : program.getAllWorkflows()) { if (workflow.getConcept() == null) { throw new APIException("ProgramWorkflow.concept.required", (Object[]) null); } ensureProgramIsSet(workflow, program); for (ProgramWorkflowState state : workflow.getStates()) { if (state.getConcept() == null || state.getInitial() == null || state.getTerminal() == null) { throw new APIException("ProgramWorkflowState.requires", (Object[]) null); } ensureProgramWorkflowIsSet(state, workflow); } } return dao.saveProgram(program); }
Source:
<code>private void close() { LOG.info("ZkBackedTaskListProvider::Unsubscribing to the changes under the path " + _path); _zkclient.unsubscribeChildChanges(_path, this); <START> _zkclient.unsubscribeDataChanges(_path, this); <END> }</code><technical_language>I added unsubscribeDataChanges() here. this added for other listeners subscribe child data changes close()? e.g. ZkBackedDMSDatastreamList</technical_language>

Target:
public void close() { LOG.info("ZkBackedTaskListProvider::Unsubscribing to the changes under the path " + _path); _zkclient.unsubscribeChildChanges(_path, this); _zkclient.unsubscribeDataChanges(_path, this); }
Source:
<code>public void initialize() { BooleanBinding passwordIsEmpty = passwordField.textProperty().isEmpty(); BooleanBinding passwordsDiffer = passwordField.textProperty().isNotEqualTo(retypePasswordField.textProperty()); okButton.disableProperty().bind(passwordIsEmpty.or(passwordsDiffer)); EasyBind.subscribe(passwordField.textProperty(), this::checkPasswordStrength); <START> strengthRater.setLocalization(localization); <END> passwordStrengthShape.widthProperty().bind(EasyBind.map(passwordStrength, strengthRater::getWidth)); passwordStrengthShape.fillProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrengthColor)); passwordStrengthShape.strokeWidthProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrokeWidth)); passwordStrengthLabel.textProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrengthDescription)); }</code><technical_language>longer needed, DI</technical_language>

Target:
public void initialize() { BooleanBinding passwordIsEmpty = passwordField.textProperty().isEmpty(); BooleanBinding passwordsDiffer = passwordField.textProperty().isNotEqualTo(retypePasswordField.textProperty()); okButton.disableProperty().bind(passwordIsEmpty.or(passwordsDiffer)); passwordStrength.bind(EasyBind.map(passwordField.textProperty(), strengthRater::computeRate)); passwordStrengthShape.widthProperty().bind(EasyBind.map(passwordStrength, strengthRater::getWidth)); passwordStrengthShape.fillProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrengthColor)); passwordStrengthShape.strokeWidthProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrokeWidth)); passwordStrengthLabel.textProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrengthDescription)); }
Source:
<code>public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = view.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), UBUNTU); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getHardware().getName(), "micro"); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); <START> } <END></code><technical_language>This test class is jclouds is date Image offering of providers. this works for local images, sense this test class</technical_language>

Target:
public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = view.getComputeService().templateBuilder().build(); String imageId = defaultTemplate.getImage().getId(); if (imageId.startsWith("ubuntu")) { assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), UBUNTU); } else if (imageId.startsWith("centos")) { assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), CENTOS); } assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getHardware().getName(), "micro"); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); }
Source:
<code>public void putAndGetWrongProtobuf() throws Exception { String BASE_URL = String.format("http://localhost:%d/rest/v2/protobuf", restServer().getPort()); String errorProto = getResourceAsString("error.proto", getClass().getClassLoader()); ContentResponse response = client.newRequest(BASE_URL + "/error") .content(new StringContentProvider(errorProto)) .header("Content-type", "text/plain; charset=utf-8") .method(HttpMethod.PUT) <START> .accept(APPLICATION_JSON_TYPE).send(); <END> String validation = "java.lang.IllegalStateException:" + " Syntax error in error.proto at 3:8: unexpected label: messoge"; ResponseAssertion.assertThat(response).isBadRequest(); ResponseAssertion.assertThat(response).hasReturnedText("{validation:" + validation + "}"); checkListProtobufEndpointUrl("error.proto", validation); }</code><technical_language>Nitpick: "accept" header is in PUT requests</technical_language>

Target:
public void putAndGetWrongProtobuf() throws Exception { String BASE_URL = String.format("http://localhost:%d/rest/v2/schemas", restServer().getPort()); String errorProto = getResourceAsString("error.proto", getClass().getClassLoader()); ContentResponse response = addSchema("error", errorProto); String cause = "java.lang.IllegalStateException:" + " Syntax error in error.proto at 3:8: unexpected label: messoge"; ResponseAssertion.assertThat(response).isOk(); JsonNode jsonNode = new ObjectMapper().readTree(response.getContent()); assertEquals("error.proto", jsonNode.get("name").asText()); assertEquals("Schema error.proto has errors", jsonNode.get("error").get("message").asText()); assertEquals(cause, jsonNode.get("error").get("cause").asText()); response = client.newRequest(BASE_URL + "/error") .method(HttpMethod.GET) .accept(TEXT_PLAIN_TYPE).send(); ResponseAssertion.assertThat(response).isOk(); ResponseAssertion.assertThat(response).hasContentEqualToFile("error.proto"); checkListProtobufEndpointUrl("error.proto", cause); }
Source:
<code>public void testNullUrl() { <START> assertThrowsException(IllegalArgumentException.class, "url", new Runnable() { <END> public void run() { WebRequestHandler request = new WebRequestHandler(); try { request.sendGet(null, null); } catch (IOException e) { fail(); } } }); }</code><technical_language>ThrowableRunnable, need in try-catch block</technical_language>

Target:
public void testNullUrl() { assertThrowsException(IllegalArgumentException.class, "url", new ThrowableRunnable() { public void run() throws IOException { WebRequestHandler request = new WebRequestHandler(); request.sendGet(null, null); } }); }
Source:
<code>public List<FeatureFlag> listAggregatedFeatureFlags(final Project project) { <START> notNull(project, "project cannot be null!"); <END> try { final FeatureFlags featureFlags = restTemplate.getForObject(AGGREGATED_FEATURE_FLAGS_TEMPLATE.expand(project.getId()), FeatureFlags.class); if (featureFlags == null) { throw new GoodDataException("empty response from API call"); } return featureFlags.getFeatureFlags(); } catch (GoodDataException | RestClientException e) { throw new GoodDataException("Unable to list aggregated feature flags for project ID=" + project.getId(), e); } }</code><technical_language>remove " null"</technical_language>

Target:
public List<FeatureFlag> listAggregatedFeatureFlags(final Project project) { notNull(project, "project"); try { final FeatureFlags featureFlags = restTemplate.getForObject(AGGREGATED_FEATURE_FLAGS_TEMPLATE.expand(project.getId()), FeatureFlags.class); if (featureFlags == null) { throw new GoodDataException("empty response from API call"); } return featureFlags.getFeatureFlags(); } catch (GoodDataException | RestClientException e) { throw new GoodDataException("Unable to list aggregated feature flags for project ID=" + project.getId(), e); } }
Source:
<code>public void putUnlessExists(final TableReference tableRef, final Map<Cell, byte[]> values) throws KeyAlreadyExistsException { try { Optional<KeyAlreadyExistsException> failure = clientPool.runWithRetry(client -> { for (Entry<Cell, byte[]> e : values.entrySet()) { CheckAndSetRequest request = CheckAndSetRequest.newCell(tableRef, e.getKey(), e.getValue()); CASResult casResult = executeCheckAndSet(client, request); if (!casResult.isSuccess()) { return Optional.of(new KeyAlreadyExistsException( String.format("The row in table %s already exists.", tableRef.getQualifiedName()), ImmutableList.of(e.getKey()))); } } clientPool.markWritesForTable(values, tableRef); <START> return null; <END> }); failure.ifPresent(exception -> { throw exception; }); } catch (KeyAlreadyExistsException e) { throw e; } catch (Exception e) { throw QosAwareThrowables.unwrapAndThrowRateLimitExceededOrAtlasDbDependencyException(e); } }</code><technical_language>this Optional.empty()</technical_language>

Target:
public void putUnlessExists(final TableReference tableRef, final Map<Cell, byte[]> values) throws KeyAlreadyExistsException { try { Optional<KeyAlreadyExistsException> failure = clientPool.runWithRetry(client -> { for (Entry<Cell, byte[]> e : values.entrySet()) { CheckAndSetRequest request = CheckAndSetRequest.newCell(tableRef, e.getKey(), e.getValue()); CASResult casResult = executeCheckAndSet(client, request); if (!casResult.isSuccess()) { return Optional.of(new KeyAlreadyExistsException( String.format("The row in table %s already exists.", tableRef.getQualifiedName()), ImmutableList.of(e.getKey()))); } } clientPool.markWritesForTable(values, tableRef); return Optional.empty(); }); failure.ifPresent(exception -> { throw exception; }); } catch (KeyAlreadyExistsException e) { throw e; } catch (Exception e) { throw QosAwareThrowables.unwrapAndThrowRateLimitExceededOrAtlasDbDependencyException(e); } }
Source:
<code>public void printTrader() { System.out.println("Trader Name: " + name); System.out.println("====================="); System.out.println("Cash: " + cashInHand); System.out.println("Stocks Owned: "); for (Stock <START> s : <END> position) { if (!s.getSymbol().equals("")) System.out.println(s.getSymbol()); } System.out.println("Stocks Desired: "); for (Order o : ordersPlaced) { o.printOrder(); } System.out.println("+++++++++++++++++++++"); System.out.println("+++++++++++++++++++++"); }</code><technical_language>Bad variable name! Variable names clear enough. Rename it</technical_language>

Target:
public void printTrader() { System.out.println("Trader Name: " + name); System.out.println("====================="); System.out.println("Cash: " + cashInHand); System.out.println("Stocks Owned: "); for (Stock stock : position) { if (!stock.getSymbol().equals("")) System.out.println(stock.getSymbol()); } System.out.println("Stocks Desired: "); for (Order order : ordersPlaced) { order.printOrder(); } System.out.println("+++++++++++++++++++++"); System.out.println("+++++++++++++++++++++"); }
Source:
<code>public int hashCode() { <START> return Objects.hashCode(pointer, size); <END> }</code><technical_language>enough Longs.hashCode(pointer) a faster</technical_language>

Target:
public int hashCode() { return Longs.hashCode(pointer); }
Source:
<code>public List<IgniteModel<I, O>> submodels() { <START> return new ArrayList<>(submodels); <END> }</code><technical_language>Collections.unmodifiableList(submodels) in this case</technical_language>

Target:
public List<IgniteModel<I, O>> submodels() { return Collections.unmodifiableList(submodels); }
Source:
<code>public void execute(FunctionContext<Object[]> context) { InternalLocator locator = getLocator(); Object[] args = context.getArguments(); String group = (String) args[0]; String jarName = (String) args[1]; RemoteInputStream result = null; if (locator != null && group != null && jarName != null) { InternalConfigurationPersistenceService sharedConfig = locator.getConfigurationPersistenceService(); if (sharedConfig != null) { SystemManagementService managementService = getExistingManagementService(context); ManagementAgent managementAgent = managementService.getManagementAgent(); if (managementAgent == null) { throw new IllegalStateException( "Failed to download jar because JMX Management agent is not available. Please ensure geode property jmx-manager is set to true."); } RemoteInputStreamServer istream = null; try { File jarFile = sharedConfig.getPathToJarOnThisLocator(group, jarName).toFile(); <START> if (jarFile.lastModified() > System.currentTimeMillis() - 1000) { <END> Thread.sleep(1000); } RemoteStreamExporter exporter = managementAgent.getRemoteStreamExporter(); istream = new SimpleRemoteInputStream(new BufferedInputStream(new FileInputStream(jarFile))); result = exporter.export(istream); istream = null; } catch (Exception e) { logger.error(e); throw new IllegalStateException(e.getMessage()); } finally { if (istream != null) { istream.close(); } } } } context.getResultSender().lastResult(result); }</code><technical_language>This replaced await get stuck forever</technical_language>

Target:
public void execute(FunctionContext<Object[]> context) { InternalLocator locator = getLocator(); Object[] args = context.getArguments(); String group = (String) args[0]; String jarName = (String) args[1]; RemoteInputStream result = null; if (locator != null && group != null && jarName != null) { InternalConfigurationPersistenceService sharedConfig = locator.getConfigurationPersistenceService(); if (sharedConfig != null) { SystemManagementService managementService = getExistingManagementService(context); ManagementAgent managementAgent = managementService.getManagementAgent(); if (managementAgent == null) { throw new IllegalStateException( "Failed to download jar because JMX Management agent is not available. Please ensure geode property jmx-manager is set to true."); } RemoteInputStreamServer istream = null; try { File jarFile = sharedConfig.getPathToJarOnThisLocator(group, jarName).toFile(); RemoteStreamExporter exporter = managementAgent.getRemoteStreamExporter(); istream = new SimpleRemoteInputStream(new BufferedInputStream(new FileInputStream(jarFile))); result = exporter.export(istream); istream = null; } catch (Exception e) { logger.error(e); throw new IllegalStateException(e.getMessage()); } finally { if (istream != null) { istream.close(); } } } } context.getResultSender().lastResult(result); }
Source:
<code>public DeviceInactivePage generatePage() { final Jedis jedis = jedisPool.getResource(); final Set<Tuple> redisSenses = new TreeSet<>(); final Long afterCursor = (afterTimestamp.isPresent()) ? afterTimestamp.get() : Long.MIN_VALUE; final Long beforeCursor = (beforeTimestamp.isPresent()) ? beforeTimestamp.get() : Long.MAX_VALUE; try { redisSenses.addAll(jedis.zrangeByScoreWithScores(deviceType, afterCursor, beforeCursor, 0, maxItemsPerPage)); } catch (Exception e) { <START> LOGGER.error("Failed to retrieve list of devices", e.getMessage()); <END> } finally { jedisPool.returnResource(jedis); } final List<DeviceInactive> inactiveDevices = extractDevicesList(redisSenses); final DeviceInactivePage formattedPage = internalFormatPage(afterCursor, beforeCursor, inactiveDevices); return formattedPage; }</code><technical_language>Missing {}</technical_language>

Target:
public DeviceInactivePage generatePage() { final Jedis jedis = jedisPool.getResource(); final Set<Tuple> redisSenses = new TreeSet<>(); final Long afterCursor = (afterTimestamp.isPresent()) ? afterTimestamp.get() : Long.MIN_VALUE; final Long beforeCursor = (beforeTimestamp.isPresent()) ? beforeTimestamp.get() : Long.MAX_VALUE; try { redisSenses.addAll(jedis.zrangeByScoreWithScores(deviceType, afterCursor, beforeCursor, 0, maxItemsPerPage)); } catch (Exception e) { LOGGER.error("Failed to retrieve list of devices {}", e.getMessage()); } finally { jedisPool.returnResource(jedis); } final List<DeviceInactive> inactiveDevices = extractDevicesList(redisSenses); final DeviceInactivePage formattedPage = internalFormatPage(afterCursor, beforeCursor, inactiveDevices); return formattedPage; }
Source:
<code>public CliCommand init(final Arguments args) throws Exception { bucketName = args.getBucket(); if (bucketName == null) { <START> CommandExceptionFactory.getInstance().handleException(this.getClass(). getSimpleName(), <END> new MissingOptionException("The delete bucket command requires '-b' to be set."), true); } force = args.isForce(); return this; }</code><technical_language>This throw exception, add a custom MissiongOptionException handler ExceptionHandler class</technical_language>

Target:
public CliCommand init(final Arguments args) throws Exception { bucketName = args.getBucket(); if (bucketName == null) { throw new MissingOptionException("The delete bucket command requires '-b' to be set."); } force = args.isForce(); return this; }
Source:
<code>public void deleteAndWaitForCompletion(String workflow, long timeout) throws InterruptedException { delete(workflow); long endTime = System.currentTimeMillis() + timeout; BaseDataAccessor baseDataAccessor = _accessor.getBaseDataAccessor(); PropertyKey.Builder keyBuilder = _accessor.keyBuilder(); String workflowConfigPath = keyBuilder.resourceConfig(workflow).getPath(); String workflowContextPath = keyBuilder.workflowContext(workflow).getPath(); while (System.currentTimeMillis() <= endTime) { <START> if (baseDataAccessor.exists(workflowConfigPath, AccessOption.PERSISTENT) <END> || baseDataAccessor.exists(workflowContextPath, AccessOption.PERSISTENT)) { Thread.sleep(1000); } else { return; } } StringBuilder failed = new StringBuilder(); if (baseDataAccessor.exists(workflowConfigPath, AccessOption.PERSISTENT)) { failed.append("WorkflowConfig "); } if (baseDataAccessor.exists(workflowContextPath, AccessOption.PERSISTENT)) { failed.append("WorkflowContext "); } throw new HelixException( String.format( "Failed to delete the workflow/queue %s within %d milliseconds. " + "The following components still remain: %s", workflow, timeout, failed.toString())); }</code><technical_language>TaskDriver clean IS for a while? happen workflows/jobs running if switch new controller? IS deleted anyways? do think</technical_language>

Target:
public void deleteAndWaitForCompletion(String workflow, long timeout) throws InterruptedException { delete(workflow); long endTime = System.currentTimeMillis() + timeout; BaseDataAccessor baseDataAccessor = _accessor.getBaseDataAccessor(); PropertyKey.Builder keyBuilder = _accessor.keyBuilder(); String idealStatePath = keyBuilder.idealStates(workflow).getPath(); String workflowConfigPath = keyBuilder.resourceConfig(workflow).getPath(); String workflowContextPath = keyBuilder.workflowContext(workflow).getPath(); while (System.currentTimeMillis() <= endTime) { if (baseDataAccessor.exists(idealStatePath, AccessOption.PERSISTENT) || baseDataAccessor.exists(workflowConfigPath, AccessOption.PERSISTENT) || baseDataAccessor.exists(workflowContextPath, AccessOption.PERSISTENT)) { Thread.sleep(1000); } else { return; } } StringBuilder failed = new StringBuilder(); if (baseDataAccessor.exists(idealStatePath, AccessOption.PERSISTENT)) { failed.append("IdealState "); } if (baseDataAccessor.exists(workflowConfigPath, AccessOption.PERSISTENT)) { failed.append("WorkflowConfig "); } if (baseDataAccessor.exists(workflowContextPath, AccessOption.PERSISTENT)) { failed.append("WorkflowContext "); } throw new HelixException( String.format( "Failed to delete the workflow/queue %s within %d milliseconds. " + "The following components still remain: %s", workflow, timeout, failed.toString())); }
Source:
<code>public Function<MultiValueMap<K, V>, MultiValueMap<K, V>> finisher() { <START> return it -> it; <END> }</code><technical_language>Function.identity()</technical_language>

Target:
public Function<MultiValueMap<K, V>, MultiValueMap<K, V>> finisher() { return Function.identity(); }
Source:
<code>public Table(@Nonnull final String namespace, @Nonnull final String fullyQualifiedTableName, @Nonnull final V valueSchema, @Nullable final M metadataSchema, @Nonnull final CorfuRuntime corfuRuntime, @Nonnull final ISerializer serializer) { this.corfuRuntime = corfuRuntime; <START> this.namespace = namespace; <END> this.fullyQualifiedTableName = fullyQualifiedTableName; if (metadataSchema != null) { this.metadataOptions = MetadataOptions.builder() .metadataEnabled(true) .defaultMetadataInstance(metadataSchema) .build(); } else { this.metadataOptions = MetadataOptions.<M>builder().build(); } this.corfuTable = corfuRuntime.getObjectsView().build() .setTypeToken(new TypeToken<CorfuTable<K, CorfuRecord<V, M>>>() { }) .setStreamName(this.fullyQualifiedTableName) .setSerializer(serializer) .setArguments(new ProtobufIndexer(valueSchema)) .open(); }</code><technical_language>TableName</technical_language>

Target:
public Table(@Nonnull final String namespace, @Nonnull final String fullyQualifiedTableName, @Nonnull final V valueSchema, @Nullable final M metadataSchema, @Nonnull final CorfuRuntime corfuRuntime, @Nonnull final ISerializer serializer) { this.corfuRuntime = corfuRuntime; this.namespace = namespace; this.fullyQualifiedTableName = fullyQualifiedTableName; this.metadataOptions = Optional.ofNullable(metadataSchema) .map(schema -> MetadataOptions.builder() .metadataEnabled(true) .defaultMetadataInstance(schema) .build()) .orElse(MetadataOptions.builder().build()); this.corfuTable = corfuRuntime.getObjectsView().build() .setTypeToken(CorfuTable.<K, CorfuRecord<V, M>>getTableType()) .setStreamName(this.fullyQualifiedTableName) .setSerializer(serializer) .setArguments(new ProtobufIndexer(valueSchema)) .open(); }
Source:
<code>private void initialize() { executeVoid( String.format( <START> "CREATE TABLE IF NOT EXISTS %s (seq BIGINT, val BLOB, CONSTRAINT pk_%s PRIMARY KEY (seq))", <END> logNamespace, logNamespace)); }</code><technical_language>Table namespace, interesting</technical_language>

Target:
private void initialize() { execute(dao -> dao.createTable(namespace)); }
Source:
<code>public void checkAttributeSemantics(PerunSessionImpl sess, Group group, Attribute attribute) throws WrongReferenceAttributeValueException { if (attribute.getValue() == null) throw new WrongReferenceAttributeValueException(attribute, "Attribute collectionID cannot be null."); if (attribute.valueAsString().isEmpty()) { throw new WrongReferenceAttributeValueException(attribute, "Attribute collectionID cannot be empty."); <START> } <END> }</code><technical_language>I empty attribute set in Perun this is needed all</technical_language>

Target:
public void checkAttributeSemantics(PerunSessionImpl sess, Group group, Attribute attribute) throws WrongReferenceAttributeValueException { if (attribute.getValue() == null) throw new WrongReferenceAttributeValueException(attribute, "Attribute collectionID cannot be null."); }
Source:
<code>public static synchronized void setMetricRegistries(MetricRegistry metricRegistry, TaggedMetricRegistry taggedMetricRegistry) { <START> if (!metricRegistry.equals(metrics.get())) { <END> log.warn("The MetricsRegistry was re-set to a different value: the previous registry will be ignored" + " and the metrics will be registered on the new one."); } if (!taggedMetricRegistry.equals(taggedMetrics.get())) { log.warn("The TaggedMetricsRegistry was re-set to a different value: the previous registry will be ignored" + " and the metrics will be registered on the new one."); } metrics.set(Preconditions.checkNotNull(metricRegistry, "Metric registry cannot be null")); taggedMetrics.set(Preconditions.checkNotNull(taggedMetricRegistry, "Tagged Metric registry cannot be null")); }</code><technical_language>I if this is a legitimate place == .equals? Right this is .equals this clear if is set this multiple times do object. If .equals method changed 2 MetricsRegistries equal if metrics create 2 equal initialisation metrics diverge if people call methods directly</technical_language>

Target:
public static synchronized void setMetricRegistries(MetricRegistry metricRegistry, TaggedMetricRegistry taggedMetricRegistry) { if (metricRegistry != metrics.get()) { log.warn("The MetricsRegistry was re-set to a different value: the previous registry will be ignored" + " and metrics may be lost."); } if (taggedMetricRegistry != taggedMetrics.get()) { log.warn("The TaggedMetricsRegistry was re-set to a different value: the previous registry will be ignored" + " and metrics may be lost."); } metrics.set(Preconditions.checkNotNull(metricRegistry, "Metric registry cannot be null")); taggedMetrics.set(Preconditions.checkNotNull(taggedMetricRegistry, "Tagged Metric registry cannot be null")); }
Source:
<code>public List<String> getChildren(String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException { DataNode n = nodes.get(path); if (n == null) { throw new KeeperException.NoNodeException(); } List<String> children; synchronized (n) { if (stat != null) { n.copyStat(stat); } children = new ArrayList<String>(n.getChildren()); if (watcher != null) { childWatches.addWatch(path, watcher); } } int bytes = 0; <START> bytes = children.stream().mapToInt(child -> child.length()).sum(); <END> updateReadStat(path, bytes); return children; }</code><technical_language>This is original code</technical_language>

Target:
public List<String> getChildren(String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException { DataNode n = nodes.get(path); if (n == null) { throw new KeeperException.NoNodeException(); } List<String> children; synchronized (n) { if (stat != null) { n.copyStat(stat); } children = new ArrayList<String>(n.getChildren()); if (watcher != null) { childWatches.addWatch(path, watcher); } } int bytes = 0; for (String child : children) { bytes += child.length(); } updateReadStat(path, bytes); return children; }
Source:
<code>public String getLogText() throws IOException { return Files.lines(new File(run.getRootDir(), FILE_NAME).toPath()) <START> .collect(Collectors.joining("\n")); <END> }</code><technical_language>I java return FileUtils.toString(new File(run.getRootDir(), FILE_NAME), StandardCharsets.UTF_8);</technical_language>

Target:
public String getLogText() throws IOException { return FileUtils.readFileToString(new File(run.getRootDir(), FILE_NAME), StandardCharsets.UTF_8); }
Source:
<code>public SystemEvent process(SystemEvent event, Session session) { Payload payload = event.getPayload(); ContentTypePayloadDataWrapper contentTypePayloadDataWrapper = (ContentTypePayloadDataWrapper) payload.getRawData(); Structure structure = contentTypePayloadDataWrapper.getStructure(); <START> ContentTypeView contentTypeView = ContentTypeView.getInstance(structure, contentTypePayloadDataWrapper.getActionUrl()); <END> return new SystemEvent(event.getId(), event.getEventType(), new Payload(contentTypeView, payload.getVisibility(), payload.getVisibilityId()), event.getCreationDate()); }</code><technical_language>ContentTypeView a class attribute instead of instance static</technical_language>

Target:
public SystemEvent process(SystemEvent event, Session session) { Payload payload = event.getPayload(); ContentTypePayloadDataWrapper contentTypePayloadDataWrapper = (ContentTypePayloadDataWrapper) payload.getRawData(); Structure structure = contentTypePayloadDataWrapper.getStructure(); ContentTypeView contentTypeView = new ContentTypeView(structure, contentTypePayloadDataWrapper.getActionUrl()); return new SystemEvent(event.getId(), event.getEventType(), new Payload(contentTypeView, payload.getVisibility(), payload.getVisibilityId()), event.getCreationDate()); }
Source:
<code>private List<ProductEntity> getAllEntitiesIncludingDeleted() { List<ProductEntity> result = entityManager.createQuery( "from ProductEntity pe " + "LEFT OUTER JOIN FETCH pe.developer " <START> + "LEFT OUTER JOIN FETCH pe.productCertificationStatuses ", <END> ProductEntity.class).getResultList(); logger.debug("SQL call: List<ProductEntity> getAllEntities()"); return result; }</code><technical_language>Similar Developer; joining in productCertificationStatuses object</technical_language>

Target:
private List<ProductEntity> getAllEntitiesIncludingDeleted() { List<ProductEntity> result = entityManager.createQuery( "from ProductEntity pe " + "LEFT OUTER JOIN FETCH pe.developer ", ProductEntity.class).getResultList(); logger.debug("SQL call: List<ProductEntity> getAllEntities()"); return result; }
Source:
<code>public void hashcodeTest() { VariantDeclaration a = new VariantDeclaration(); VariantDeclaration b = new VariantDeclaration(); b.addField("hi", StringDeclaration.getStringDeclaration(Encoding.UTF8)); VariantDeclaration c = new VariantDeclaration(); c.addField("hi", StringDeclaration.getStringDeclaration(Encoding.UTF8)); assertEquals(fixture.hashCode(), a.hashCode()); assertEquals(b.hashCode(), c.hashCode()); <START> assertNotEquals(fixture.hashCode(), c.hashCode()); <END> assertNotEquals(a.hashCode(), c.hashCode()); }</code><technical_language>test hashcode unequality, is guarantee. doc 2 patches</technical_language>

Target:
public void hashcodeTest() { VariantDeclaration a = new VariantDeclaration(); VariantDeclaration b = new VariantDeclaration(); b.addField("hi", StringDeclaration.getStringDeclaration(Encoding.UTF8)); VariantDeclaration c = new VariantDeclaration(); c.addField("hi", StringDeclaration.getStringDeclaration(Encoding.UTF8)); assertEquals(fixture.hashCode(), a.hashCode()); assertEquals(b.hashCode(), c.hashCode()); }
Source:
<code>public String toString() { StringBuilder sb = new StringBuilder(); Object object; for (int i = 0, length = valueTable.length; i < length; i++) { if ((object = valueTable[i]) != null) { <START> sb.append(new String(keyTable[i])); <END> sb.append(" -> "); sb.append(object.toString()); sb.append("\n"); } } return sb.toString(); }</code><technical_language>'String(keyTable[i])' sb.append(Object arg) is 'String.valueOf(arg), a null-safe Object-to-String conversion</technical_language>

Target:
public String toString() { StringBuilder sb = new StringBuilder(); Object object; for (int i = 0, length = valueTable.length; i < length; i++) { if ((object = valueTable[i]) != null) { sb.append(keyTable[i]); sb.append(" -> "); sb.append(object); sb.append("\n"); } } return sb.toString(); }
Source:
<code>public ClientPartitionServiceImpl(HazelcastClientInstanceImpl client) { this.client = client; this.logger = client.getLoggingService().getLogger(ClientPartitionService.class); clientExecutionService = (ClientExecutionServiceImpl) client.getClientExecutionService(); ClassLoader classLoader = client.getClientConfig().getClassLoader(); <START> final List<ListenerConfig> listenerConfigs = client.getClientConfig().getListenerConfigs(); <END> if (listenerConfigs != null && !listenerConfigs.isEmpty()) { for (ListenerConfig listenerConfig : listenerConfigs) { EventListener implementation = listenerConfig.getImplementation(); if (implementation == null) { try { implementation = ClassLoaderUtil.newInstance(classLoader, listenerConfig.getClassName()); } catch (Exception e) { logger.severe(e); } } if (implementation instanceof PartitionLostListener) { partitionLostListeners.add((PartitionLostListener) implementation); } } } }</code><technical_language>move this code start() avoid tracking listeners in partitionLostListeners</technical_language>

Target:
public ClientPartitionServiceImpl(HazelcastClientInstanceImpl client) { this.client = client; this.logger = client.getLoggingService().getLogger(ClientPartitionService.class); clientExecutionService = (ClientExecutionServiceImpl) client.getClientExecutionService(); }
Source:
<code>public static @Nullable Class<? extends Quantity<?>> parseDimension(String dimension) { if (StringUtils.isBlank(dimension)) { return null; } try { @SuppressWarnings("unchecked") Class<? extends Quantity<?>> dimensionClass = (Class<? extends Quantity<?>>) Class .forName(JAVAX_MEASURE_QUANTITY + dimension); return dimensionClass; } catch (ClassNotFoundException e) { <START> logger.error("Error creating a Class instance for name '{}'.", dimension); <END> } return null; }</code><technical_language>do log errors a util class. throw IAE log debug, if expected critical</technical_language>

Target:
public static @Nullable Class<? extends Quantity<?>> parseDimension(String dimension) { if (StringUtils.isBlank(dimension)) { return null; } try { return dimensionClass(FRAMEWORK_DIMENSION_PREFIX, dimension); } catch (ClassNotFoundException e1) { try { return dimensionClass(JAVAX_MEASURE_QUANTITY_PREFIX, dimension); } catch (ClassNotFoundException e2) { throw new IllegalArgumentException( "Error creating a dimension Class instance for name '" + dimension + "'."); } } }
Source:
<code>public Flux<MultiValueMap<String, String>> read(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, Map<String, Object> hints) { return Flux.error(new UnsupportedOperationException()); <START> } <END></code><technical_language>is form a Flux read sense method produce a Flux, i.e. Flux.from(readMono(..)), if more element.</technical_language>

Target:
public Flux<MultiValueMap<String, String>> read(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, Map<String, Object> hints) { return readMono(elementType, inputMessage, hints).flux(); }
Source:
<code>private void deleteEntities(SortedMap<EntityType, List<Entity>> entityMap, HttpServletRequest request) throws IOException, JAXBException { for (Map.Entry<EntityType, List<Entity>> entry : entityMap.entrySet()) { for (final Entity entity : entry.getValue()) { <START> final HttpServletRequest bufferedRequest = getEntityStream(entity, entity.getEntityType(), request); <END> final String entityType = entity.getEntityType().toString(); final String entityName = entity.getName(); new EntityProxy(entityType, entityName) { @Override protected APIResult doExecute(String colo) throws FalconException { return getConfigSyncChannel(colo).invoke("delete", bufferedRequest, entityType, entityName, colo); } }.execute(); if (!embeddedMode) { super.delete(bufferedRequest, entityType, entityName, currentColo); } } } }</code><technical_language>Move this Util method suggested in PR 331</technical_language>

Target:
private void deleteEntities(SortedMap<EntityType, List<Entity>> entityMap, HttpServletRequest request) throws IOException, JAXBException { for (Map.Entry<EntityType, List<Entity>> entry : entityMap.entrySet()) { for (final Entity entity : entry.getValue()) { final HttpServletRequest bufferedRequest = getEntityStream(entity, entity.getEntityType(), request); final String entityType = entity.getEntityType().toString(); final String entityName = entity.getName(); entityProxyUtil.proxyDelete(entityType, entityName, bufferedRequest); if (!embeddedMode) { super.delete(bufferedRequest, entityType, entityName, currentColo); } } } }
Source:
<code>public void testBooleanComparator() { <START> boolean[] values = {false, true}; <END> for (int i = 0; i < values.length; ++i) { for (int j = 0; j < values.length; ++j) { boolean vi = values[i]; boolean vj = values[j]; int exp = i - j; assertSignumEquals(vi, vj, exp, BOOLEAN_COMPARATOR.compare(vi, vj)); assertSignumEquals(vi, vj, exp, BOOLEAN_COMPARATOR.compare(Boolean.valueOf(vi), Boolean.valueOf(vj))); } } checkThrowingUnsupportedException(BOOLEAN_COMPARATOR, Boolean.TYPE); }</code><technical_language>I this is complicated for a boolean test 4 9 cases (true/false/null). smaller more clear assertTrue(comparator.compare(true, false) > 0). test null values for boxed compare method</technical_language>

Target:
public void testBooleanComparator() { Boolean[] valuesInAscendingOrder = { null, false, true }; for (int i = 0; i < valuesInAscendingOrder.length; ++i) { for (int j = 0; j < valuesInAscendingOrder.length; ++j) { Boolean vi = valuesInAscendingOrder[i]; Boolean vj = valuesInAscendingOrder[j]; int exp = i - j; assertSignumEquals(vi, vj, exp, BOOLEAN_COMPARATOR.compare(vi, vj)); if (vi != null && vj != null) { assertSignumEquals(vi, vj, exp, BOOLEAN_COMPARATOR.compare(vi.booleanValue(), vj.booleanValue())); } } } checkThrowingUnsupportedException(BOOLEAN_COMPARATOR, Boolean.TYPE); }
Source:
<code>private void testIsStudentsInSameTeam() { ______TS("non-existent student1"); CourseAttributes course1 = dataBundle.courses.get("typicalCourse1"); StudentAttributes student2InCourse1 = dataBundle.students.get("student2InCourse1"); String nonExistStudentEmail = "nonExist@google.tmt"; assertFalse(studentsLogic.isStudentsInSameTeam(course1.getId(), nonExistStudentEmail, student2InCourse1.email)); ______TS("students of different teams"); <START> StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1"); <END> assertTrue(studentsLogic.isStudentsInSameTeam(course1.getId(), student2InCourse1.email, student1InCourse1.email)); }</code><technical_language>is this removed</technical_language>

Target:
private void testIsStudentsInSameTeam() { ______TS("non-existent student1"); CourseAttributes course1 = dataBundle.courses.get("typicalCourse1"); StudentAttributes student2InCourse1 = dataBundle.students.get("student2InCourse1"); String nonExistStudentEmail = "nonExist@google.tmt"; assertFalse(studentsLogic.isStudentsInSameTeam(course1.getId(), nonExistStudentEmail, student2InCourse1.email)); ______TS("students of different teams"); StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1"); assertTrue(studentsLogic.isStudentsInSameTeam(course1.getId(), student2InCourse1.email, student1InCourse1.email)); StudentAttributes student5InCourse1 = dataBundle.students.get("student5InCourse1"); assertFalse(studentsLogic.isStudentsInSameTeam(course1.getId(), student2InCourse1.email, student5InCourse1.email)); }
Source:
<code>private void expandParent(ParentObject parentObject, int position) { ParentWrapper parentWrapper = (ParentWrapper) mExpandableRecyclerAdapterHelper.getHelperItemAtPosition(position); if (parentWrapper == null) { return; } if (parentWrapper.isExpanded()) { parentWrapper.setExpanded(false); <START> mExpandCollapseListener.onRecyclerViewItemCollapsed(position); <END> mStableIdMap.put(parentWrapper.getStableId(), false); List<Object> childObjectList = ((ParentObject) parentWrapper.getParentObject()).getChildObjectList(); if (childObjectList != null) { for (int i = childObjectList.size() - 1; i >= 0; i--) { mItemList.remove(position + i + 1); mExpandableRecyclerAdapterHelper.getHelperItemList().remove(position + i + 1); notifyItemRemoved(position + i + 1); Log.d(TAG, "Removed " + childObjectList.get(i).toString()); } } } else { parentWrapper.setExpanded(true); mExpandCollapseListener.onRecyclerViewItemExpanded(position); mStableIdMap.put(parentWrapper.getStableId(), true); List<Object> childObjectList = ((ParentObject) parentWrapper.getParentObject()).getChildObjectList(); if (childObjectList != null) { for (int i = 0; i < childObjectList.size(); i++) { mItemList.add(position + i + 1, childObjectList.get(i)); mExpandableRecyclerAdapterHelper.getHelperItemList().add(position + i + 1, childObjectList.get(i)); notifyItemInserted(position + i + 1); } } } }</code><technical_language>this give a NPE if listener is set user (which case)</technical_language>

Target:
private void expandParent(ParentObject parentObject, int position) { ParentWrapper parentWrapper = (ParentWrapper) mExpandableRecyclerAdapterHelper.getHelperItemAtPosition(position); if (parentWrapper == null) { return; } if (parentWrapper.isExpanded()) { parentWrapper.setExpanded(false); if (mExpandCollapseListener != null) { int expandedCountBeforePosition = getExpandedItemCount(position); mExpandCollapseListener.onRecyclerViewItemCollapsed(position - expandedCountBeforePosition); } mStableIdMap.put(parentWrapper.getStableId(), false); List<Object> childObjectList = ((ParentObject) parentWrapper.getParentObject()).getChildObjectList(); if (childObjectList != null) { for (int i = childObjectList.size() - 1; i >= 0; i--) { mItemList.remove(position + i + 1); mExpandableRecyclerAdapterHelper.getHelperItemList().remove(position + i + 1); notifyItemRemoved(position + i + 1); } } } else { parentWrapper.setExpanded(true); if (mExpandCollapseListener != null) { int expandedCountBeforePosition = getExpandedItemCount(position); mExpandCollapseListener.onRecyclerViewItemExpanded(position - expandedCountBeforePosition); } mStableIdMap.put(parentWrapper.getStableId(), true); List<Object> childObjectList = ((ParentObject) parentWrapper.getParentObject()).getChildObjectList(); if (childObjectList != null) { for (int i = 0; i < childObjectList.size(); i++) { mItemList.add(position + i + 1, childObjectList.get(i)); mExpandableRecyclerAdapterHelper.getHelperItemList().add(position + i + 1, childObjectList.get(i)); notifyItemInserted(position + i + 1); } } } }
Source:
<code>public synchronized void send(final EventualMessage msg) { assert msg.getTarget() == this; <START> if (VmSettings.ACTOR_TRACING && VmSettings.MESSAGE_TIMESTAMPS) { <END> mailbox.addMessageSendTime(); } mailbox.append(msg); logMessageAddedToMailbox(msg); if (!isExecuting) { isExecuting = true; executeOnPool(); } }</code><technical_language>discussion above, good imply VmSettings.ACTOR_TRACING true if MESSAGE_TIMESTAMPS is set. simplify check MESSAGE_TIMESTAMPS. (same below)</technical_language>

Target:
public synchronized void send(final EventualMessage msg) { assert msg.getTarget() == this; if (VmSettings.MESSAGE_TIMESTAMPS) { mailbox.addMessageSendTime(); } mailbox.append(msg); logMessageAddedToMailbox(msg); if (!isExecuting) { isExecuting = true; executeOnPool(); } }
Source:
<code>public void tearDown(final ManagementClient managementClient, final String containerId) { try { ServerReload.reloadIfRequired(managementClient.getControllerClient()); } catch (Exception e) { throw new RuntimeException(e); } try { <START> ServerReload.executeReloadAndWaitForCompletion(managementClient.getControllerClient()); <END> } catch (Exception e) { throw new RuntimeException(e); } applyRemoveAllowReload(managementClient.getControllerClient(), domainAddress, false); applyRemoveAllowReload(managementClient.getControllerClient(), realmAddress, false); }</code><technical_language>This moved applyRemoveAllowReload</technical_language>

Target:
public void tearDown(final ManagementClient managementClient, final String containerId) { applyRemoveAllowReload(managementClient.getControllerClient(), domainAddress, false); applyRemoveAllowReload(managementClient.getControllerClient(), realmAddress, false); }