auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public RemoveMembersFromConsumerGroupResult removeMembersFromConsumerGroup(String groupId, RemoveMembersFromConsumerGroupOptions options) { final long startFindCoordinatorMs = time.milliseconds(); final long deadline = calcDeadlineMs(startFindCoordinatorMs, options.timeoutMs()); KafkaFutureImpl<Map<MemberIdentity, Errors>> future = new KafkaFutureImpl<>(); ConsumerGroupOperationContext<Map<MemberIdentity, Errors>, RemoveMembersFromConsumerGroupOptions> context = new ConsumerGroupOperationContext<>(groupId, options, deadline, future); Call findCoordinatorCall; if (options.removeAll()) { List<MemberIdentity> members = getMembersFromGroup(groupId); findCoordinatorCall = getFindCoordinatorCall(context, <START> () -> getRemoveMembersFromGroupCall(context, members)); <END> } else { findCoordinatorCall = getFindCoordinatorCall(context, () -> getRemoveMembersFromGroupCall(context, new ArrayList<>())); } runnable.call(findCoordinatorCall, startFindCoordinatorMs); return new RemoveMembersFromConsumerGroupResult(future, options.members(), options.removeAll()); }</code><technical_language>pass members context</technical_language>

Target:
public RemoveMembersFromConsumerGroupResult removeMembersFromConsumerGroup(String groupId, RemoveMembersFromConsumerGroupOptions options) { final long startFindCoordinatorMs = time.milliseconds(); final long deadline = calcDeadlineMs(startFindCoordinatorMs, options.timeoutMs()); KafkaFutureImpl<Map<MemberIdentity, Errors>> future = new KafkaFutureImpl<>(); ConsumerGroupOperationContext<Map<MemberIdentity, Errors>, RemoveMembersFromConsumerGroupOptions> context = new ConsumerGroupOperationContext<>(groupId, options, deadline, future); List<MemberIdentity> members; if (options.removeAll()) { members = getMembersFromGroup(groupId); } else { members = options.members().stream().map(MemberToRemove::toMemberIdentity).collect(Collectors.toList()); } Call findCoordinatorCall = getFindCoordinatorCall(context, () -> getRemoveMembersFromGroupCall(context, members)); runnable.call(findCoordinatorCall, startFindCoordinatorMs); return new RemoveMembersFromConsumerGroupResult(future, options.members()); }
Source:
<code>void shouldReturnFalseWhenForwardedIpAddressIsNotInAllowedIpAddresses() { final String forwardedIpAddresses = "1.1.1.1, 102.108.0.6"; final String payload = notificationPayloadForTransaction( payId, EPDQ_PAYMENT_REQUESTED); <START> final boolean result = notificationService.handleNotificationFor(payload, forwardedIpAddresses); assertFalse(result); <END> }</code><technical_language>inlined</technical_language>

Target:
void shouldReturnFalseWhenForwardedIpAddressIsNotInAllowedIpAddresses() { final String forwardedIpAddresses = "1.1.1.1, 102.108.0.6"; final String payload = notificationPayloadForTransaction( payId, EPDQ_PAYMENT_REQUESTED); assertFalse(notificationService.handleNotificationFor(payload, forwardedIpAddresses)); }
Source:
<code>public void setAction(Action action) { <START> switch (action) { <END> case ALLOW: setDeny(false); break; case DENY: setDeny(true); break; default: throw new IllegalArgumentException(); } }</code><technical_language>switch statement? I propose: if (action == null) { throw new NullPointerException(); } setDeny(action == Action.DENY);</technical_language>

Target:
public void setAction(Action action) { if (action == null) { throw new NullPointerException("action"); } setDeny(action == Action.DENY); }
Source:
<code>public static boolean verify(String json, JsonPathVerify jsonPathVerify) { Object leftObject = jsonPathVerify.getLeft(); Object rightObject = jsonPathVerify.getRight(); if (jsonPathVerify.getLeft().matches("\\$.*")) { leftObject= JsonPath.read(json, jsonPathVerify.getLeft()); } if (jsonPathVerify.getRight().matches("\\$.*")) { rightObject = JsonPath.read(json, jsonPathVerify.getRight()); } boolean result; switch (jsonPathVerify.getOperator()) { case EQ: result = leftObject.toString().equals(rightObject.toString()); break; case LT: result = compareTo(leftObject.toString(), rightObject.toString()) < 0; break; <START> case GR: <END> result = compareTo(leftObject.toString(), rightObject.toString()) > 0; break; default: throw new IllegalStateException("Unsupported operator: " + jsonPathVerify.getOperator()); } return result; }</code><technical_language>Convention is GT (greater than)</technical_language>

Target:
public static boolean verify(String json, JsonPathVerify jsonPathVerify) { Object leftObject = jsonPathVerify.getLeft(); Object rightObject = jsonPathVerify.getRight(); if (jsonPathVerify.getLeft().matches("\\$.*")) { leftObject= JsonPath.read(json, jsonPathVerify.getLeft()); } if (jsonPathVerify.getRight().matches("\\$.*")) { rightObject = JsonPath.read(json, jsonPathVerify.getRight()); } boolean result; switch (jsonPathVerify.getOperator()) { case EQ: result = leftObject.toString().equals(rightObject.toString()); break; case NE: result = !leftObject.toString().equals(rightObject.toString()); break; case LT: result = compareTo(leftObject.toString(), rightObject.toString()) < 0; break; case GT: result = compareTo(leftObject.toString(), rightObject.toString()) > 0; break; default: throw new IllegalStateException("Unsupported operator: " + jsonPathVerify.getOperator()); } return result; }
Source:
<code>public void consume(Iterator<KeyMessage<String, String>> updateIterator) throws IOException { while (updateIterator.hasNext()) { KeyMessage<String, String> km = updateIterator.next(); String key = km.getKey(); String message = km.getMessage(); switch (key) { case "UP": <START> if (model != null) { <END> List<?> update = MAPPER.readValue(message, List.class); int id = Integer.parseInt(update.get(0).toString()); double[] vector = MAPPER.convertValue(update.get(1), double[].class); model.update(id, vector); } break; case "MODEL": PMML pmml; try { pmml = PMMLUtils.fromString(message); } catch (JAXBException e) { throw new IOException(e); } KMeansPMMLUtils.validatePMMLVsSchema(pmml, inputSchema); List<ClusterInfo> clusters = KMeansPMMLUtils.read(pmml); model = new KMeansServingModel(clusters, inputSchema); break; default: throw new IllegalStateException("Bad model " + message); } } }</code><technical_language>this sense, in other implementations is a lot of code follows, I simpler care of null case upfront leave for consistency</technical_language>

Target:
public void consume(Iterator<KeyMessage<String, String>> updateIterator) throws IOException { while (updateIterator.hasNext()) { KeyMessage<String, String> km = updateIterator.next(); String key = km.getKey(); String message = km.getMessage(); switch (key) { case "UP": if (model == null) { continue; } List<?> update = MAPPER.readValue(message, List.class); int id = Integer.parseInt(update.get(0).toString()); double[] vector = MAPPER.convertValue(update.get(1), double[].class); model.update(id, vector); break; case "MODEL": PMML pmml; try { pmml = PMMLUtils.fromString(message); } catch (JAXBException e) { throw new IOException(e); } KMeansPMMLUtils.validatePMMLVsSchema(pmml, inputSchema); List<ClusterInfo> clusters = KMeansPMMLUtils.read(pmml); model = new KMeansServingModel(clusters, inputSchema); break; default: throw new IllegalStateException("Bad model " + message); } } }
Source:
<code>protected Boolean doTaskBackground(String... params) { if(records == null){ return true; } Log.d(TAG, "Wiping sent form records"); for (FormRecord record : records) { <START> record.logPendingDeletion(TAG, "we are about to initiate a wifi direct transfer"); <END> FormRecordCleanupTask.wipeRecord(c, record); } Log.d(TAG, "Successfully wiped: " + records.length + " FormRecords."); return true; }</code><technical_language>This Wi-Fi Direct completes (not initiation)</technical_language>

Target:
protected Boolean doTaskBackground(String... params) { if(records == null){ return true; } Log.d(TAG, "Wiping sent form records"); for (FormRecord record : records) { record.logPendingDeletion(TAG, "we have just completed a wifi direct transfer"); FormRecordCleanupTask.wipeRecord(c, record); } Log.d(TAG, "Successfully wiped: " + records.length + " FormRecords."); return true; }
Source:
<code>private void close(final boolean clean) { if (state() == State.CREATED) { transitionTo(State.CLOSING); } else { if (state() == State.RUNNING) { if (clean) { commit(); } transitionTo(State.CLOSING); } <START> if (state() == State.CLOSING || state() == State.RESTORING) { <END> final boolean wipeStateStore = !clean && !eosDisabled; executeAndMaybeSwallow(clean, () -> StateManagerUtil.closeStateManager(log, logPrefix, clean, wipeStateStore, stateMgr, stateDirectory, TaskType.STANDBY), "state manager close", log); } else { throw new IllegalStateException("Illegal state " + state() + " while closing standby task " + id); } } closeTaskSensor.record(); transitionTo(State.CLOSED); }</code><technical_language>Standby task in RESTORING transit CREATED -> RUNNING -> RESTORING in call. observe this case failed system tests? in unclean close case I possible.</technical_language>

Target:
private void close(final boolean clean) { if (state() == State.CREATED || state() == State.RUNNING) { if (clean) { stateMgr.checkpoint(Collections.emptyMap()); offsetSnapshotSinceLastCommit = new HashMap<>(stateMgr.changelogOffsets()); } final boolean wipeStateStore = !clean && eosEnabled; log.info("standby task clean {}, eos enabled {}", clean, eosEnabled); executeAndMaybeSwallow(clean, () -> StateManagerUtil.closeStateManager( log, logPrefix, clean, wipeStateStore, stateMgr, stateDirectory, TaskType.STANDBY), "state manager close", log ); } else { throw new IllegalStateException("Illegal state " + state() + " while closing standby task " + id); } closeTaskSensor.record(); transitionTo(State.CLOSED); }
Source:
<code>public int compareTo(FileAndName o) { <START> return getFile().compareTo(o.getFile()); <END> }</code><technical_language>consistent. In equals configuration element is considered. name is considered all. Consider this: 2 FileAndName instances file confguration element. equals method return false compareTo return 0. correct</technical_language>

Target:
public int compareTo(FileAndName o) { int retVal = getFile().compareTo(o.getFile()); if (retVal == 0) { if (getTraceTypeId() != null) { if (getTraceTypeId() != null) { if( o.getTraceTypeId() != null) { retVal = getTraceTypeId().compareTo(o.getTraceTypeId()); } } } } return retVal; }
Source:
<code>private static ITmfEventField[] generatePacketFields(Packet packet) { List<ITmfEventField> fieldList = new ArrayList<>(); List<ITmfEventField> subfieldList = new ArrayList<>(); Packet localPacket = packet.getPacket(PcapProtocol.PCAP); while (localPacket != null) { subfieldList.clear(); for (Map.Entry<String, String> entry : localPacket.getFields().entrySet()) { <START> String key = nullToEmptyString(entry.getKey()); <END> String value = entry.getValue(); subfieldList.add(new TmfEventField(key, value, null)); } ITmfEventField[] subfieldArray = subfieldList.toArray(new ITmfEventField[subfieldList.size()]); fieldList.add(new PcapEventField(localPacket.getProtocol().getName(), EMPTY_STRING, subfieldArray, localPacket)); localPacket = localPacket.getChildPacket(); } ITmfEventField[] fieldArray = fieldList.toArray(new ITmfEventField[fieldList.size()]); if (fieldArray == null) { return EMPTY_FIELD_ARRAY; } return fieldArray; }</code><technical_language>this checkNotNull? null I think. If is, assigning "" is a good thing</technical_language>

Target:
private static ITmfEventField[] generatePacketFields(Packet packet) { List<ITmfEventField> fieldList = new ArrayList<>(); List<ITmfEventField> subfieldList = new ArrayList<>(); Packet localPacket = packet.getPacket(PcapProtocol.PCAP); while (localPacket != null) { subfieldList.clear(); for (Map.Entry<String, String> entry : localPacket.getFields().entrySet()) { String key = entry.getKey(); String value = entry.getValue(); subfieldList.add(new TmfEventField(nullToEmptyString(key), value, null)); } ITmfEventField[] subfieldArray = subfieldList.toArray(new ITmfEventField[subfieldList.size()]); fieldList.add(new PcapEventField(localPacket.getProtocol().getName(), EMPTY_STRING, subfieldArray, localPacket)); localPacket = localPacket.getChildPacket(); } ITmfEventField[] fieldArray = fieldList.toArray(new ITmfEventField[fieldList.size()]); if (fieldArray == null) { return EMPTY_FIELD_ARRAY; } return fieldArray; }
Source:
<code>public Object visitReadWriteKeyCommand(InvocationContext ctx, ReadWriteKeyCommand command) throws Throwable { if (isUsingAsyncStore(ctx, command)) { checkMarshallable(command.getKey()); <START> checkMarshallable(command.getFunction()); <END> } return invokeNext(ctx, command); }</code><technical_language>point of async store, is necessary *function* serializable resulting entry. check belong here. holds for compute commands</technical_language>

Target:
public Object visitReadWriteKeyCommand(InvocationContext ctx, ReadWriteKeyCommand command) throws Throwable { if (isUsingAsyncStore(ctx, command)) { checkMarshallable(command.getKey()); } return invokeNext(ctx, command); }
Source:
<code>public double parRate(ResolvedSwap swap, RatesProvider provider) { ResolvedSwapLeg fixedLeg = fixedLeg(swap); Currency ccyFixedLeg = fixedLeg.getCurrency(); double otherLegsConvertedPv = 0.0; for (ResolvedSwapLeg leg : swap.getLegs()) { if (leg != fixedLeg) { double pvLocal = legPricer.presentValueInternal(leg, provider); otherLegsConvertedPv += (pvLocal * provider.fxRate(leg.getCurrency(), ccyFixedLeg)); } } double fixedLegEventsPv = legPricer.presentValueEventsInternal(fixedLeg, provider); if (fixedLeg.getPaymentPeriods().size() > 1) { double pvbpFixedLeg = legPricer.pvbp(fixedLeg, provider); return -(otherLegsConvertedPv + fixedLegEventsPv) / pvbpFixedLeg; } PaymentPeriod firstPeriod = fixedLeg.getPaymentPeriods().get(0); ArgChecker.isTrue(firstPeriod instanceof RatePaymentPeriod, "PaymentPeriod must be instance of RatePaymentPeriod"); RatePaymentPeriod payment = (RatePaymentPeriod) firstPeriod; if (payment.getAccrualPeriods().size() == 1) { double pvbpFixedLeg = legPricer.pvbp(fixedLeg, provider); return -(otherLegsConvertedPv + fixedLegEventsPv) / pvbpFixedLeg; } Triple<Boolean, Integer, Double> fixedCompounded = checkFixedCompounded(fixedLeg); <START> double notional = payment.getNotional(); <END> double df = provider.discountFactor(ccyFixedLeg, payment.getPaymentDate()); return Math.pow(-(otherLegsConvertedPv + fixedLegEventsPv) / (notional * df) + 1.0d, 1.0 / fixedCompounded.getSecond()) - 1.0d; }</code><technical_language>Need ArgChecker element of Triple</technical_language>

Target:
public double parRate(ResolvedSwap swap, RatesProvider provider) { ResolvedSwapLeg fixedLeg = fixedLeg(swap); Currency ccyFixedLeg = fixedLeg.getCurrency(); double otherLegsConvertedPv = 0.0; for (ResolvedSwapLeg leg : swap.getLegs()) { if (leg != fixedLeg) { double pvLocal = legPricer.presentValueInternal(leg, provider); otherLegsConvertedPv += (pvLocal * provider.fxRate(leg.getCurrency(), ccyFixedLeg)); } } double fixedLegEventsPv = legPricer.presentValueEventsInternal(fixedLeg, provider); if (fixedLeg.getPaymentPeriods().size() > 1) { double pvbpFixedLeg = legPricer.pvbp(fixedLeg, provider); return -(otherLegsConvertedPv + fixedLegEventsPv) / pvbpFixedLeg; } PaymentPeriod firstPeriod = fixedLeg.getPaymentPeriods().get(0); ArgChecker.isTrue(firstPeriod instanceof RatePaymentPeriod, "PaymentPeriod must be instance of RatePaymentPeriod"); RatePaymentPeriod payment = (RatePaymentPeriod) firstPeriod; if (payment.getAccrualPeriods().size() == 1) { double pvbpFixedLeg = legPricer.pvbp(fixedLeg, provider); return -(otherLegsConvertedPv + fixedLegEventsPv) / pvbpFixedLeg; } Triple<Boolean, Integer, Double> fixedCompounded = checkFixedCompounded(fixedLeg); ArgChecker.isTrue(fixedCompounded.getFirst(), "Swap should have a fixed leg and for one payment it should be based on compunding witout spread."); double notional = payment.getNotional(); double df = provider.discountFactor(ccyFixedLeg, payment.getPaymentDate()); return Math.pow(-(otherLegsConvertedPv + fixedLegEventsPv) / (notional * df) + 1.0d, 1.0 / fixedCompounded.getSecond()) - 1.0d; }
Source:
<code>protected List<MeasurementRow> extractExcelFileData(final Workbook workbook, final UserSelection userSelection, final Map<Integer, MeasurementVariable> variableIndexMap, final boolean discardInvalidValues) { final Sheet sheet = workbook.getSheetAt(userSelection.getSelectedSheet()); final List<MeasurementRow> rows = new ArrayList<MeasurementRow>(userSelection.getObservationRows()); for (int i = userSelection.getContentRowIndex(); i <= userSelection.getContentRowIndex() + userSelection.getObservationRows() - 1; i++) { final MeasurementRow row = new MeasurementRow(); <START> row.setDataList(this.convertRow(sheet, i, variableIndexMap, discardInvalidValues, this.retrieveAvailableEntryTypes(this.contextUtil.getCurrentProgramUUID()))); <END> rows.add(row); } return rows; }</code><technical_language>retrieving entry types observation row? this one-off retrieval for rows</technical_language>

Target:
protected List<MeasurementRow> extractExcelFileData(final Workbook workbook, final UserSelection userSelection, final Map<Integer, MeasurementVariable> variableIndexMap, final boolean discardInvalidValues) { final Sheet sheet = workbook.getSheetAt(userSelection.getSelectedSheet()); final List<MeasurementRow> rows = new ArrayList<>(userSelection.getObservationRows()); final Map<String, Integer> availableEntryTypes = this .retrieveAvailableEntryTypes(this.contextUtil.getCurrentProgramUUID()); for (int i = userSelection.getContentRowIndex(); i <= userSelection.getContentRowIndex() + userSelection.getObservationRows() - 1; i++) { final MeasurementRow row = new MeasurementRow(); row.setDataList(this.convertRow(sheet, i, variableIndexMap, discardInvalidValues, availableEntryTypes)); rows.add(row); } return rows; }
Source:
<code>public void makeBucket(String bucketName) throws ErrorResponseException, IllegalArgumentException, InsufficientDataException, InternalException, InvalidBucketNameException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, RegionConflictException, XmlParserException { MakeBucketArgs.Builder makeBucketArgs = new MakeBucketArgs.Builder(); makeBucketArgs.bucket(bucketName); MakeBucketArgs args = makeBucketArgs.build(); <START> this.makeBucket(args); <END> }</code><technical_language>this.makeBucket(MakeBucketArgs.newBuilder().bucket(bucketName).build()) everywhere</technical_language>

Target:
public void makeBucket(String bucketName) throws ErrorResponseException, IllegalArgumentException, InsufficientDataException, InternalException, InvalidBucketNameException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, RegionConflictException, XmlParserException { this.makeBucket(new MakeBucketArgs.Builder().bucket(bucketName).build()); }
Source:
<code>public RegistrationScreenInteractor observeRegistrationScreen() { final MainApplication app = MainApplication.instance(); final CharSequence title = ResourceUtil.getFormattedString(app.getResources(), R.string.register_title, "platform_name", app.getInjector().getInstance(Config.class).getPlatformName()); <START> return this; <END> }</code><technical_language>this assertion, this method accomplishes :( Again, update this check title is correct</technical_language>

Target:
public RegistrationScreenInteractor observeRegistrationScreen() { final MainApplication app = MainApplication.instance(); final CharSequence title = ResourceUtil.getFormattedString(app.getResources(), R.string.register_title, "platform_name", app.getInjector().getInstance(Config.class).getPlatformName()); onView(allOf(isInActionBar(), withText(title.toString()))).check(matches(isCompletelyDisplayed())); return this; }
Source:
<code>public void testGetDirectAdmins() throws Exception { System.out.println(CLASS_NAME + "testGetDirectAdmins"); setUpSecurityTeams(); setUpUsers(); securityTeamsManagerEntry.addAdmin(sess, st0, u0); <START> assertTrue(securityTeamsManagerEntry.getDirectAdmins(sess, st0).contains(u0)); <END> }</code><technical_language>getAdmins true parameter instead of this deprecated method</technical_language>

Target:
public void testGetDirectAdmins() throws Exception { System.out.println(CLASS_NAME + "testGetDirectAdmins"); setUpSecurityTeams(); setUpUsers(); List<User> expected = setUpAdmins(u1, u2, setUpGroup(u3, u4)); expected.remove(u3); expected.remove(u4); List<User> actual = securityTeamsManagerEntry.getAdmins(sess, st0, true); Collections.sort(expected); Collections.sort(actual); assertEquals(expected, actual); }
Source:
<code>public OnkyoConnection(String ip, int port) { this.ip = ip; this.port = port; <START> connection = (EiscpInterface)new Eiscp(ip, port); <END> }</code><technical_language>casting necessary here, is it</technical_language>

Target:
public OnkyoConnection(String ip, int port) { this.ip = ip; this.port = port; connection = new Eiscp(ip, port); }
Source:
<code>private int decompressDirectBuf() throws IOException { if (compressedDirectBufLen == 0) { return 0; } else { compressedDirectBuf.limit(compressedDirectBufLen).position(0); int size = Snappy.uncompress((ByteBuffer) compressedDirectBuf, (ByteBuffer) uncompressedDirectBuf); compressedDirectBufLen = 0; <START> compressedDirectBuf.limit(compressedDirectBuf.capacity()).position(0); <END> return size; } }</code><technical_language>nit: call compressedDirectBuf.clear()</technical_language>

Target:
private int decompressDirectBuf() throws IOException { if (compressedDirectBufLen == 0) { return 0; } else { compressedDirectBuf.limit(compressedDirectBufLen).position(0); int size = Snappy.uncompress((ByteBuffer) compressedDirectBuf, (ByteBuffer) uncompressedDirectBuf); compressedDirectBufLen = 0; compressedDirectBuf.clear(); return size; } }
Source:
<code>public ExternalConditionEval(ExternalCondition condition, Data data) { super(Type.EXTERNAL, condition.match(data.getValue()), data.getTimestamp(), data.getContext()); this.condition = condition; this.value = data.getValue(); <START> this.typeValue = TypeValue.EVENT; <END> }</code><technical_language>if this field, I this DATA</technical_language>

Target:
public ExternalConditionEval(ExternalCondition condition, Data data) { super(Type.EXTERNAL, condition.match(data.getValue()), data.getTimestamp(), data.getContext()); this.condition = condition; this.value = data.getValue(); }
Source:
<code>public CommentAttributes(Comment comment) { this.commentId = comment.getId(); this.courseId = comment.getCourseId(); this.giverEmail = comment.getGiverEmail(); this.recipientType = comment.getRecipientType(); this.status = comment.getStatus(); this.sendingState = comment.getSendingState() != null? comment.getSendingState() : CommentSendingState.SENT; this.showCommentTo = comment.getShowCommentTo(); this.showGiverNameTo = comment.getShowGiverNameTo(); this.showRecipientNameTo = comment.getShowRecipientNameTo(); this.recipients = comment.getRecipients(); this.createdAt = comment.getCreatedAt(); this.commentText = comment.getCommentText(); this.lastEditorEmail = comment.getLastEditorEmail(); <START> this.lastEditedAt = comment.getLastEditedAt(); <END> }</code><technical_language>prevent NPE other developers</technical_language>

Target:
public CommentAttributes(Comment comment) { this.commentId = comment.getId(); this.courseId = comment.getCourseId(); this.giverEmail = comment.getGiverEmail(); this.recipientType = comment.getRecipientType(); this.status = comment.getStatus(); this.sendingState = comment.getSendingState() != null? comment.getSendingState() : CommentSendingState.SENT; this.showCommentTo = comment.getShowCommentTo(); this.showGiverNameTo = comment.getShowGiverNameTo(); this.showRecipientNameTo = comment.getShowRecipientNameTo(); this.recipients = comment.getRecipients(); this.createdAt = comment.getCreatedAt(); this.commentText = comment.getCommentText(); this.lastEditorEmail = comment.getLastEditorEmail() != null ? comment.getLastEditorEmail() : comment.getGiverEmail(); this.lastEditedAt = comment.getLastEditedAt() != null ? comment.getLastEditedAt() : comment.getCreatedAt(); }
Source:
<code>public void select(E element) { <START> int elementIndex = this.elements.indexOf(element); <END> if (elementIndex >= 0) { mappedToggleButtons.get(elementIndex).fire(); } else { throw new IllegalArgumentException(String.format("Element %s doesn't exist", element.toString())); } }</code><technical_language>pass index directly</technical_language>

Target:
public void select(E element) { this.select(this.elements.indexOf(element)); }
Source:
<code>public static List<CitationStyle> discoverCitationStyles() { if (!STYLES.isEmpty()) { return STYLES; } <START> URL url = CitationStyle.class.getResource("/modules/org.jabref/csl-styles"); <END> Objects.requireNonNull(url); if (url == null) { return Collections.emptyList(); } try { URI uri = url.toURI(); LOGGER.debug("Uri " + uri); try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) { Path path = fs.getPath(STYLES_ROOT); STYLES.addAll(discoverCitationStylesInPath(path)); } catch (FileSystemAlreadyExistsException e) { try (FileSystem fs = FileSystems.getFileSystem(uri)) { Path path = fs.getPath(STYLES_ROOT); STYLES.addAll(discoverCitationStylesInPath(path)); } catch (FileSystemException ex) { LOGGER.error("Failed to discover csl styles ", ex); } } return STYLES; } catch (URISyntaxException | IOException e) { LOGGER.error("something went wrong while searching available CitationStyles. Are you running directly from source code?", e); return Collections.emptyList(); } }</code><technical_language>I guess problem is "csl-styles" is of module boundaries. try load a) a single csl file b) if works if copy file "src\main\java\org\jabref\logic\citationstyle" load CitationStyle.class.getResource("file.csl"); finally c) if place file in resource folder "src\main\resources\org\jabref\logic\citationstyle"</technical_language>

Target:
public static List<CitationStyle> discoverCitationStyles() { if (!STYLES.isEmpty()) { return STYLES; } URL url = CitationStyle.class.getResource("csl-styles/academy-of-management-review.csl"); Objects.requireNonNull(url); if (url == null) { return Collections.emptyList(); } try { URI uri = url.toURI(); LOGGER.debug("Uri " + uri); System.out.println(uri); Path path = Path.of(uri).getParent(); STYLES.addAll(discoverCitationStylesInPath(path)); return STYLES; } catch (URISyntaxException | IOException e) { LOGGER.error("something went wrong while searching available CitationStyles. Are you running directly from source code?", e); return Collections.emptyList(); } }
Source:
<code>static public PermissionRule <START> allow(ProjectConfig <END> project, String capabilityName, AccountGroup.UUID group) { PermissionRule rule = newRule(project, group); project.getAccessSection(AccessSection.GLOBAL_CAPABILITIES, true) .getPermission(capabilityName, true) .add(rule); return rule; }</code><technical_language>I tests similar call grant()? switch this convenience method too</technical_language>

Target:
public static PermissionRule allow(ProjectConfig project, String capabilityName, AccountGroup.UUID group) { PermissionRule rule = newRule(project, group); project.getAccessSection(AccessSection.GLOBAL_CAPABILITIES, true) .getPermission(capabilityName, true) .add(rule); return rule; }
Source:
<code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApp = (Gh4Application) getApplicationContext(); mActionBar = getSupportActionBar(); mActionBar.setTitle(mRepoOwner + "/" + mRepoName); mActionBar.setDisplayHomeAsUpEnabled(true); setContentShown(false); <START> this.loadRepository().subscribe(o -> {}, e -> {}); <END> if (Gh4Application.get().isAuthorized()) { this.isWatching(); this.isStarring(); } }</code><technical_language>Code style: do prefix method this. Applies other places in code too</technical_language>

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mActionBar = getSupportActionBar(); mActionBar.setTitle(mRepoOwner + "/" + mRepoName); mActionBar.setDisplayHomeAsUpEnabled(true); setContentShown(false); loadRepository(false); if (Gh4Application.get().isAuthorized()) { loadWatchingStatus(false); loadStarringStatus(false); } }
Source:
<code>protected CellList<Bookmark> createDataDisplayWidget(BookmarkModelProvider modelProvider) { ApplicationTemplates templates = ClientGinjectorProvider.instance().getApplicationTemplates(); final CellList<Bookmark> display = new CellList<Bookmark>(new BookmarkListItemCell(templates)); display.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); display.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); display.addDomHandler(new KeyDownHandler() { @Override @SuppressWarnings("unchecked") public void onKeyDown(KeyDownEvent event) { SingleSelectionModel<Bookmark> selectionModel = (SingleSelectionModel<Bookmark>) display.getSelectionModel(); if (selectionModel.getSelectedObject() != null) { Bookmark item = null; int index = display.getVisibleItems().indexOf(selectionModel.getSelectedObject()); int key = event.getNativeEvent().getKeyCode(); if (key == KeyCodes.KEY_UP) { item = display.getVisibleItems().get(index - 1); } else if (key == KeyCodes.KEY_DOWN) { item = display.getVisibleItems().get(index + 1); } if (item != null) { selectionModel.setSelected(item, true); event.stopPropagation(); event.preventDefault(); } } } }, KeyDownEvent.getType()); display.sinkEvents(Event.ONKEYDOWN); <START> <END> modelProvider.addDataDisplay(display); return display; }</code><technical_language>Separate patch for this</technical_language>

Target:
protected CellList<Bookmark> createDataDisplayWidget(BookmarkModelProvider modelProvider) { ApplicationTemplates templates = ClientGinjectorProvider.instance().getApplicationTemplates(); CellList<Bookmark> display = new CellList<Bookmark>(new BookmarkListItemCell(templates)); display.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); display.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); modelProvider.addDataDisplay(display); return display; }
Source:
<code>public void retriesOnExceptionTillCount() throws Exception { final int count = 3; final int delay = 1000; final Take take = Mockito.mock(Take.class); final Request req = new RqFake(RqMethod.GET); Mockito.when(take.act(Mockito.any(Request.class))).thenThrow( new IOException() ); <START> final long startTime = System.currentTimeMillis(); <END> try { new TkRetry(count, delay, take).act(req); } catch (final IOException exception) { MatcherAssert.assertThat( new Long(count * delay), Matchers.lessThanOrEqualTo( System.currentTimeMillis() - startTime ) ); throw exception; } }</code><technical_language>@HDouss avoid composite names: start is fine</technical_language>

Target:
public void retriesOnExceptionTillCount() throws Exception { final int count = Tv.THREE; final int delay = Tv.THOUSAND; final Take take = Mockito.mock(Take.class); Mockito .when(take.act(Mockito.any(Request.class))) .thenThrow(new IOException()); final long start = System.nanoTime(); try { new TkRetry(count, delay, take).act( new RqFake(RqMethod.GET) ); } catch (final IOException exception) { final long spent = System.nanoTime() - start; MatcherAssert.assertThat( new Long(count * delay - Tv.HUNDRED) * Tv.MILLION, Matchers.lessThanOrEqualTo(spent) ); throw exception; } }
Source:
<code>public static void processMultipleFiles(ArrayList<File> specFiles) throws MOPException { String aspectName; if(options.outputDir == null){ options.outputDir = getTargetDir(specFiles); } if(options.aspectname != null) { aspectName = options.aspectname; } else { if(specFiles.size() == 1) { aspectName = Tool.getFileName(specFiles.get(0).getAbsolutePath()); } else { int suffixNumber = 0; File aspectFile; do{ suffixNumber++; aspectFile = new File(options.outputDir.getAbsolutePath() + File.separator + "MultiSpec_" + suffixNumber + "MonitorAspect.aj"); } while(aspectFile.exists()); aspectName = "MultiSpec_" + suffixNumber; } options.aspectname = aspectName; } MOPProcessor processor = new MOPProcessor(aspectName); MOPNameSpace.init(); ArrayList<MOPSpecFile> specs = new ArrayList<MOPSpecFile>(); for(File file : specFiles){ String specStr = SpecExtractor.process(file); MOPSpecFile spec = SpecExtractor.parse(specStr); <START> writeFile(processor.generateRVFile(spec), file.getAbsolutePath(), ".rvm"); <END> specs.add(spec); } MOPSpecFile combinedSpec = FileCombiner.combineSpecFiles(specs); writeCombinedAspectFile(processor.generateAJFile(combinedSpec), aspectName); }</code><technical_language>extract .rvm, MonitorAspect.aj, similar static final String, sice starting in multiple places</technical_language>

Target:
public static void processMultipleFiles(ArrayList<File> specFiles) throws MOPException { String aspectName; if(options.outputDir == null){ options.outputDir = getTargetDir(specFiles); } if(options.aspectname != null) { aspectName = options.aspectname; } else { if(specFiles.size() == 1) { aspectName = Tool.getFileName(specFiles.get(0).getAbsolutePath()); } else { int suffixNumber = 0; File aspectFile; do{ suffixNumber++; aspectFile = new File(options.outputDir.getAbsolutePath() + File.separator + "MultiSpec_" + suffixNumber + AJ_FILE_SUFFIX); } while(aspectFile.exists()); aspectName = "MultiSpec_" + suffixNumber; } options.aspectname = aspectName; } MOPProcessor processor = new MOPProcessor(aspectName); MOPNameSpace.init(); ArrayList<MOPSpecFile> specs = new ArrayList<MOPSpecFile>(); for(File file : specFiles){ String specStr = SpecExtractor.process(file); MOPSpecFile spec = SpecExtractor.parse(specStr); writeFile(processor.generateRVFile(spec), file.getAbsolutePath(), RVM_FILE_SUFFIX); specs.add(spec); } MOPSpecFile combinedSpec = FileCombiner.combineSpecFiles(specs); writeCombinedAspectFile(processor.generateAJFile(combinedSpec), aspectName); }
Source:
<code>protected String getJobStatusFieldColor(ListGridRecord record, int rowNum, int colNum, String base) { String fieldName = this.getFieldName(colNum); base = highlightRowHavingIssues(rowNum, base); if (fieldName.equals(STATE_ATTR.getName())) { try { switch (getJobStatus(record)) { case KILLED: return "color:#BE2D1C;font-weight:bold;" + base; case CANCELED: <START> return "color:#C50000;font-weight:bold;" + base; END> case FAILED: return "color:#850003;" + base; case IN_ERROR: return "color:#E94504;font-weight:bold;" + base; case RUNNING: return "color:#1a8bba;font-weight:bold;" + base; case PENDING: return "color:#F0E130;font-weight:bold;" + base; case STALLED: return "color:#62cef7;" + base; case PAUSED: return "color:#ff9933;font-weight:bold;" + base; case FINISHED: return base; default: return base; } } catch (NullPointerException npe) { return base; } } return base; }</code><technical_language>C50000 is gray</technical_language>

Target:
protected String getJobStatusFieldColor(ListGridRecord record, int rowNum, int colNum, String base) { String fieldName = this.getFieldName(colNum); base = highlightRowHavingIssues(rowNum, base); if (fieldName.equals(STATE_ATTR.getName())) { try { switch (getJobStatus(record)) { case KILLED: return "color:#BE2D1C;font-weight:bold;" + base; case CANCELED: return "color:#C50000;font-weight:bold;" + base; case FAILED: return "color:#850003;font-weight:bold;" + base; case IN_ERROR: return "color:#E94504;font-weight:bold;" + base; case RUNNING: return "color:#2051F4;font-weight:bold;" + base; case PENDING: return "color:#F0E130;" + base; case STALLED: return "color:#1B89B8;font-weight:bold;" + base; case PAUSED: return "color:#ff9933;font-weight:bold;" + base; case FINISHED: return base; default: return base; } } catch (NullPointerException npe) { return base; } } return base; }
Source:
<code>public FEELFnResult<TemporalAccessor> invoke(@ParameterName( "date" ) Temporal date, @ParameterName( "time" ) Temporal time) { if ( date == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "date", "cannot be null")); } if ( !(date instanceof LocalDate) ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "date", "must be an instance of LocalDate")); } if ( time == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "time", "cannot be null")); } if ( !(time instanceof LocalTime || time instanceof OffsetTime) ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "time", "must be an instance of LocalTime or OffsetTime")); } if( time instanceof LocalTime ) { return FEELFnResult.ofResult( LocalDateTime.of( (LocalDate) date, (LocalTime) time ) ); } else { <START> return FEELFnResult.ofResult( ZonedDateTime.of( (LocalDate) date, LocalTime.from( time ), ZoneOffset.from( time ) ) ); <END> } }</code><technical_language>@baldimir I eliminate try/catch here... a number of problems happen date/time manipulations is pretty impossible predict all... is I left try/catch..</technical_language>

Target:
public FEELFnResult<TemporalAccessor> invoke(@ParameterName( "date" ) Temporal date, @ParameterName( "time" ) Temporal time) { if ( date == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "date", "cannot be null")); } if ( !(date instanceof LocalDate) ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "date", "must be an instance of LocalDate")); } if ( time == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "time", "cannot be null")); } if ( !(time instanceof LocalTime || time instanceof OffsetTime) ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "time", "must be an instance of LocalTime or OffsetTime")); } try { if ( time instanceof LocalTime ) { return FEELFnResult.ofResult(LocalDateTime.of((LocalDate) date, (LocalTime) time)); } else { return FEELFnResult.ofResult(ZonedDateTime.of((LocalDate) date, LocalTime.from(time), ZoneOffset.from(time))); } } catch ( DateTimeException e ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "input parameters date-parsing exception", e)); } }
Source:
<code>public KuduClientConfig setMasterAddresses(String... contactPoints) { <START> this.masterAddresses = Arrays.asList(contactPoints); <END> return this; }</code><technical_language>ImmutableList</technical_language>

Target:
public KuduClientConfig setMasterAddresses(String... contactPoints) { this.masterAddresses = ImmutableList.copyOf(contactPoints); return this; }
Source:
<code>public static PreallocationType getPreallocationType(final Storage.ProvisioningType provisioningType){ switch (provisioningType){ case THIN: return PreallocationType.Off; case SPARSE: return PreallocationType.Metadata; case FAT: return PreallocationType.Full; default: <START> throw new NotImplementedProvisioningTypeException(); <END> } }</code><technical_language>if instead, throw a cloud runtime a message describing problem/error here</technical_language>

Target:
public static PreallocationType getPreallocationType(final Storage.ProvisioningType provisioningType){ switch (provisioningType){ case THIN: return PreallocationType.Off; case SPARSE: return PreallocationType.Metadata; case FAT: return PreallocationType.Full; default: throw new NotImplementedException(String.format("type %s not defined as member-value of PreallocationType", provisioningType)); } }
Source:
<code>private WebXml parseWebXml(ServletContext servletContext) { <START> InputStream inputStream = servletContext.getResourceAsStream(webXmlPath); <END> if (inputStream == null) { throw new IllegalStateException(String.format("Could not read %s!", webXmlPath)); } WebXmlParser parser = new WebXmlParser(false, false, true); WebXml webXml = new WebXml(); boolean success = parser.parseWebXml(new InputSource(inputStream), webXml, false); if (!success) { throw new IllegalStateException("Something went wrong registering precompiled JSPs"); } LOG.info("Parsed including servlets and servletMappings!", webXmlPath, webXml.getServlets().size(), webXml.getServletMappings().size()); return webXml; }</code><technical_language>knnte man autoclosable try(inputstream...) machen</technical_language>

Target:
private WebXml parseWebXml(ServletContext servletContext) { final WebXml webXml = new WebXml(); try (InputStream inputStream = servletContext.getResourceAsStream(webXmlPath)) { if (inputStream == null) { throw new IllegalStateException(String.format("Could not read %s!", webXmlPath)); } final WebXmlParser parser = new WebXmlParser(false, false, true); final boolean success = parser.parseWebXml(new InputSource(inputStream), webXml, false); if (!success) { throw new IllegalStateException("Something went wrong registering precompiled JSPs"); } LOG.info("Parsed including servlets and servletMappings!", webXmlPath, webXml.getServlets().size(), webXml.getServletMappings().size()); } catch (IOException e) { throw new IllegalStateException("Could not close the web.xml input stream to precompile jsps"); } return webXml; }
Source:
<code>void fixSshKeyOnWindows(File key) throws GitException { if (launcher.isUnix()) return; Path file = Paths.get(key.toURI()); AclFileAttributeView fileAttributeView = Files.getFileAttributeView(file, AclFileAttributeView.class); if (fileAttributeView == null) return; String username = getWindowsUserName(fileAttributeView); if (StringUtils.isBlank(username)) return; try { UserPrincipalLookupService userPrincipalLookupService = file.getFileSystem().getUserPrincipalLookupService(); UserPrincipal userPrincipal = userPrincipalLookupService.lookupPrincipalByName(username); AclEntry aclEntry = AclEntry.newBuilder() .setType(AclEntryType.ALLOW) .setPrincipal(userPrincipal) .setPermissions(ACL_ENTRY_PERMISSIONS) .build(); fileAttributeView.setAcl(Collections.singletonList(aclEntry)); } catch (IOException | UnsupportedOperationException e) { <START> throw new GitException("Error updating file permission", e); <END> } }</code><technical_language>exception message include name of file failed permission setting operation? more quickly diagnose failure in cases caller shows exception message showing entire exception stack trace</technical_language>

Target:
void fixSshKeyOnWindows(File key) throws GitException { if (launcher.isUnix()) return; Path file = Paths.get(key.toURI()); AclFileAttributeView fileAttributeView = Files.getFileAttributeView(file, AclFileAttributeView.class); if (fileAttributeView == null) return; String username = getWindowsUserName(fileAttributeView); if (StringUtils.isBlank(username)) return; try { UserPrincipalLookupService userPrincipalLookupService = file.getFileSystem().getUserPrincipalLookupService(); UserPrincipal userPrincipal = userPrincipalLookupService.lookupPrincipalByName(username); AclEntry aclEntry = AclEntry.newBuilder() .setType(AclEntryType.ALLOW) .setPrincipal(userPrincipal) .setPermissions(ACL_ENTRY_PERMISSIONS) .build(); fileAttributeView.setAcl(Collections.singletonList(aclEntry)); } catch (IOException | UnsupportedOperationException e) { throw new GitException("Error updating file permission for \"" + key.getAbsolutePath() + "\""); } }
Source:
<code>IonManagedBinaryWriter(final _Private_IonManagedBinaryWriterBuilder builder, final OutputStream out) throws IOException { super(builder.optimization); symbols = new IonRawBinaryWriter( builder.provider, builder.symbolsBlockSize, out, WriteValueOptimization.NONE, StreamCloseMode.NO_CLOSE, StreamFlushMode.NO_FLUSH, builder.preallocationMode, builder.isFloatBinary32Enabled ); user = new IonRawBinaryWriter( builder.provider, builder.userBlockSize, out, WriteValueOptimization.NONE, StreamCloseMode.CLOSE, StreamFlushMode.FLUSH, builder.preallocationMode, builder.isFloatBinary32Enabled ); currentWriter = user; catalog = builder.catalog; if(builder.imports == null) { fallbackImports = new ArrayList<SymbolTable>(); } else { fallbackImports = new ArrayList(builder.imports); } if (builder.initialSymbolTable != null) { lstIndex = builder.initialSymbolTable.getImportedMaxId(); <START> ArrayList temp = new ArrayList<String>(); <END> final Iterator<String> symbolIter = builder.initialSymbolTable.iterateDeclaredSymbolNames(); while (symbolIter.hasNext()) { temp.add(symbolIter.next()); } lstWriter = new LSTWriter(new ArrayList(Arrays.asList(builder.initialSymbolTable.getImportedTables())), temp, catalog); lst = lstWriter.getSymbolTable(); lstIndex = lst.getImportedMaxId(); } else { lstWriter = new LSTWriter(fallbackImports, new ArrayList<String>(), catalog); lst = lstWriter.getSymbolTable(); lstIndex = lst.getImportedMaxId(); } maxSysId = lst.getSystemSymbolTable().getMaxId(); }</code><technical_language>ArrayList<String> temp. a more descriptive variable name</technical_language>

Target:
IonManagedBinaryWriter(final _Private_IonManagedBinaryWriterBuilder builder, final OutputStream out) throws IOException { super(builder.optimization); symbols = new IonRawBinaryWriter( builder.provider, builder.symbolsBlockSize, out, _Private_WriteValueOptimization.NONE, StreamCloseMode.NO_CLOSE, StreamFlushMode.NO_FLUSH, builder.preallocationMode, builder.isFloatBinary32Enabled ); user = new IonRawBinaryWriter( builder.provider, builder.userBlockSize, out, _Private_WriteValueOptimization.NONE, StreamCloseMode.CLOSE, StreamFlushMode.FLUSH, builder.preallocationMode, builder.isFloatBinary32Enabled ); currentWriter = user; catalog = builder.catalog; if(builder.imports == null) { fallbackImports = new ArrayList<SymbolTable>(); } else { fallbackImports = new ArrayList<SymbolTable>(builder.imports); } if (builder.initialSymbolTable != null) { lstIndex = builder.initialSymbolTable.getImportedMaxId(); ArrayList<String> temp = new ArrayList<String>(); final Iterator<String> symbolIter = builder.initialSymbolTable.iterateDeclaredSymbolNames(); while (symbolIter.hasNext()) { temp.add(symbolIter.next()); } lstWriter = new _Private_LSTWriter(new ArrayList(Arrays.asList(builder.initialSymbolTable.getImportedTables())), temp, catalog); lst = lstWriter.getSymbolTable(); lstIndex = lst.getImportedMaxId(); } else { lstWriter = new _Private_LSTWriter(fallbackImports, Collections.<String>emptyList(), catalog); lst = lstWriter.getSymbolTable(); lstIndex = lst.getImportedMaxId(); } maxSysId = lst.getSystemSymbolTable().getMaxId(); }
Source:
<code>void testBingTileEncoding() { Random random = new Random(1491); for (int zoom = 0; zoom <= MAX_ZOOM_LEVEL; zoom++) { int numIterations = Math.min(1000, (int) Math.pow(4, zoom)); for (int iter = 0; iter < numIterations; iter++) { <START> BingTile expected = BingTile.fromCoordinates( <END> random.nextInt(1 << zoom), random.nextInt(1 << zoom), zoom); BingTile actual = BingTile.decode(expected.encode()); assertEquals(actual, expected); } } }</code><technical_language>nit: extract 3 lines testRoundTrip(BingTile tile)</technical_language>

Target:
public void testBingTileEncoding() { for (int zoom = 0; zoom <= MAX_ZOOM_LEVEL; zoom++) { int maxValue = (1 << zoom) - 1; testEncodingRoundTrip(0, 0, zoom); testEncodingRoundTrip(0, maxValue, zoom); testEncodingRoundTrip(maxValue, 0, zoom); testEncodingRoundTrip(maxValue, maxValue, zoom); } }