auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void process(Element elm, JID actorJID, IQ reqIQ, Element rsm) throws Exception { response = IQ.createResultIQ(reqIQ); request = reqIQ; actor = actorJID; node = request.getChildElement().element("affiliations").attributeValue(XMLConstants.NODE_ATTR); if (!Configuration.getInstance().isLocalJID(request.getFrom())) { response.getElement().addAttribute(XMLConstants.REMOTE_SERVER_DISCOVER_ATTR, Boolean.FALSE.toString()); } String namespace = JabberPubsub.NAMESPACE_URI; if (node == null) { namespace = JabberPubsub.NS_PUBSUB_OWNER; } Element pubsub = response.setChildElement(XMLConstants.PUBSUB_ELEM, namespace); Element affiliations = pubsub.addElement(XMLConstants.AFFILIATIONS_ELEM); if (actor == null) { actor = request.getFrom(); } boolean isProcessedLocally = true; <START> if (node == null) { <END> isProcessedLocally = getUserMemberships(affiliations); } else { isProcessedLocally = getNodeAffiliations(affiliations); } if (!isProcessedLocally) { return; } outQueue.put(response); }</code><technical_language>woulnd't a ternary conditional verbose in here</technical_language>

Target:
public void process(Element elm, JID actorJID, IQ reqIQ, Element rsm) throws Exception { response = IQ.createResultIQ(reqIQ); request = reqIQ; actor = actorJID; node = request.getChildElement().element("affiliations").attributeValue(XMLConstants.NODE_ATTR); if (!Configuration.getInstance().isLocalJID(request.getFrom())) { response.getElement().addAttribute(XMLConstants.REMOTE_SERVER_DISCOVER_ATTR, Boolean.FALSE.toString()); } String namespace = JabberPubsub.NAMESPACE_URI; if (node == null) { namespace = JabberPubsub.NS_PUBSUB_OWNER; } Element pubsub = response.setChildElement(XMLConstants.PUBSUB_ELEM, namespace); Element affiliations = pubsub.addElement(XMLConstants.AFFILIATIONS_ELEM); if (actor == null) { actor = request.getFrom(); } boolean isProcessedLocally = (node == null) ? getUserMemberships(affiliations) : getNodeAffiliations(affiliations); if (!isProcessedLocally) { return; } outQueue.put(response); }
Source:
<code>public int compare(Slice slice1, Slice slice2) { int thisMarker = 0; int thatMarker = 0; String s1 = slice1.getSequence(); String s2 = slice2.getSequence(); int s1Length = s1.length(); int s2Length = s2.length(); while (thisMarker < s1Length && thatMarker < s2Length) { String thisChunk = getChunk(s1, s1Length, thisMarker); thisMarker += thisChunk.length(); String thatChunk = getChunk(s2, s2Length, thatMarker); thatMarker += thatChunk.length(); int result = 0; if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) { int thisChunkLength = thisChunk.length(); result = thisChunkLength - thatChunk.length(); if (result == 0) { for (int i = 0; i < thisChunkLength; i++) <START> { <END> result = thisChunk.charAt(i) - thatChunk.charAt(i); if (result != 0) { return result; } } } } else { result = thisChunk.compareTo(thatChunk); } if (result != 0) return result; } return s1Length - s2Length; }</code><technical_language>Please put starting braces )</technical_language>

Target:
public int compare(Slice slice1, Slice slice2) { int thisMarker = 0; int thatMarker = 0; String s1 = slice1.getSequence(); String s2 = slice2.getSequence(); int s1Length = s1.length(); int s2Length = s2.length(); while ((thisMarker < s1Length) && (thatMarker < s2Length)) { String thisChunk = getChunk(s1, s1Length, thisMarker); thisMarker += thisChunk.length(); String thatChunk = getChunk(s2, s2Length, thatMarker); thatMarker += thatChunk.length(); int result = 0; if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) { int thisChunkLength = thisChunk.length(); result = thisChunkLength - thatChunk.length(); if (result == 0) { for (int i = 0; i < thisChunkLength; i++) { result = thisChunk.charAt(i) - thatChunk.charAt(i); if (result != 0) { return result; } } } } else { result = thisChunk.compareTo(thatChunk); } if (result != 0) { return result; } } return s1Length - s2Length; }
Source:
<code>public SshKeyInfo apply(SshKey rsrc) { SshKeyInfo info = new SshKeyInfo(); <START> AccountSshKey sshKey = rsrc.getSshKey(); <END> info.id = sshKey.getKey().get(); info.sshPublicKey = sshKey.getSshPublicKey(); info.encodedKey = sshKey.getEncodedKey(); info.algorithm = sshKey.getAlgorithm(); info.comment = Strings.emptyToNull(sshKey.getComment()); info.valid = sshKey.isValid(); return info; }</code><technical_language>Move this constructor of SshKeyInfo reused GetSshKeys</technical_language>

Target:
public SshKeyInfo apply(SshKey rsrc) { return new SshKeyInfo(rsrc.getSshKey()); }
Source:
<code>protected FormGroup getFormGroup(RenderMode renderMode) { FormRenderingContext nestedContext = renderingContext.getCopyFor(field.getNestedForm(), null); if (field.getReadOnly()) { nestedContext.setRenderMode(RenderMode.READ_ONLY_MODE); } subFormWidget.render(nestedContext); AbstractNestedFormFormGroup formGroup; <START> if(Container.COLLAPSIBLE.equals(field.getContainer())) { <END> formGroup = formGroupsInstance.select(CollapseFormGroup.class).get(); } else { formGroup = formGroupsInstance.select(FieldSetFormGroup.class).get(); } formGroup.render(subFormWidget, field); return formGroup; }</code><technical_language>formatting, missing space if bracket</technical_language>

Target:
protected FormGroup getFormGroup(RenderMode renderMode) { FormRenderingContext nestedContext = renderingContext.getCopyFor(field.getNestedForm(), null); if (field.getReadOnly()) { nestedContext.setRenderMode(RenderMode.READ_ONLY_MODE); } subFormWidget.render(nestedContext); AbstractNestedFormFormGroup formGroup; if (Container.COLLAPSIBLE.equals(field.getContainer())) { formGroup = formGroupsInstance.select(CollapsibleFormGroup.class).get(); } else { formGroup = formGroupsInstance.select(FieldSetFormGroup.class).get(); } formGroup.render(subFormWidget, field); return formGroup; }
Source:
<code>public void testHeaders1() throws Exception { BitcoinSerializer bs = new BitcoinSerializer(MainNetParams.get()); String headersMessageBytesHex = "f9beb4d9686561" + "646572730000000000520000005d4fab8101010000006fe28c0ab6f1b372c1a6a246ae6" + "3f74f931e8365e15a089c68d6190000000000982051fd1e4ba744bbbe680e1fee14677b" + "a1a3c3540bf7b1cdb606e857233e0e61bc6649ffff001d01e3629900"; byte[] headersMessageBytes = HEX.decode(headersMessageBytesHex); <START> HeadersMessage hm = (HeadersMessage) bs.deserialize(ByteBuffer.wrap(HEX.decode(headersMessageBytesHex))); <END> Block block = hm.getBlockHeaders().get(0); String hash = block.getHashAsString(); assertEquals(hash, "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"); assertNull(block.transactions); assertEquals(Utils.HEX.encode(block.getMerkleRoot().getBytes()), "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bs.serialize(hm, byteArrayOutputStream); byte[] serializedBytes = byteArrayOutputStream.toByteArray(); String serializedBytesHex = new String(HEX.encode(serializedBytes)); assertEquals(headersMessageBytes.length, serializedBytes.length); assertEquals(true, Arrays.equals(headersMessageBytes, serializedBytes)); }</code><technical_language>wrap headersMessageBytes here? a common subexpression</technical_language>

Target:
public void testHeaders1() throws Exception { BitcoinSerializer bs = new BitcoinSerializer(MainNetParams.get()); String headersMessageBytesHex = "f9beb4d9686561" + "646572730000000000520000005d4fab8101010000006fe28c0ab6f1b372c1a6a246ae6" + "3f74f931e8365e15a089c68d6190000000000982051fd1e4ba744bbbe680e1fee14677b" + "a1a3c3540bf7b1cdb606e857233e0e61bc6649ffff001d01e3629900"; byte[] headersMessageBytes = HEX.decode(headersMessageBytesHex); HeadersMessage hm = (HeadersMessage) bs.deserialize(ByteBuffer.wrap(headersMessageBytes)); Block block = hm.getBlockHeaders().get(0); String hash = block.getHashAsString(); assertEquals(hash, "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"); assertNull(block.transactions); assertEquals(Utils.HEX.encode(block.getMerkleRoot().getBytes()), "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bs.serialize(hm, byteArrayOutputStream); byte[] serializedBytes = byteArrayOutputStream.toByteArray(); String serializedBytesHex = new String(HEX.encode(serializedBytes)); assertEquals(headersMessageBytes.length, serializedBytes.length); assertEquals(true, Arrays.equals(headersMessageBytes, serializedBytes)); }
Source:
<code>public BigDecimal convertTemp(BigDecimal value) { if (this == DEFAULT_UNIT_SYSTEM) { return value; } <START> return value.multiply(new BigDecimal(9)).divide(new BigDecimal(5)).add(new BigDecimal(32)); <END> }</code><technical_language>private static final BigDecimal values NINE, FIVE, THIRTY_TWO avoid creating new objects conversion</technical_language>

Target:
public BigDecimal convertTemp(BigDecimal value) { if (this == DEFAULT_UNIT_SYSTEM) { return value; } return value.multiply(ONE_POINT_EIGHT).add(THIRTY_TWO); }
Source:
<code>public boolean match(OsmPrimitive osm) { for (TaggingPreset p : ps) { <START> if (p.test(osm)) return true; <END> } return false; }</code><technical_language>{}</technical_language>

Target:
public boolean match(OsmPrimitive osm) { for (TaggingPreset p : this.presets) { if (p.test(osm)) { return true; } } return false; }
Source:
<code>private static boolean isValidGroupId(String idStr) { <START> return idStr.matches("^G[0-9a-fA-F]{40}$") && !idStr.matches("^G00*$"); <END> }</code><technical_language>I need !idStr.matches("^G00*$") this one. I is a hack for bug in eclipse create change ids. groupids yet, I fine this hack (you wanna check Shawn)</technical_language>

Target:
private static boolean isValidGroupId(String idStr) { return idStr.matches("^G[0-9a-fA-F]{40}$"); }
Source:
<code>public ProcessStatus check() { if (resource.isLocked()) return ProcessStatus.NOTHING_TO_DO; Transact currentTransact = inputDock.pullTransact(); if (currentTransact == null) return ProcessStatus.NOTHING_TO_DO; System.out.println(Simulator.getTime() + ": seize body " + currentTransact.getNumber()); if (!outputDock.pushTransact(currentTransact)) { System.out.println(Simulator.getTime() + ": seize failed to give " + currentTransact.getNumber()); inputDock.rollBack(currentTransact); return ProcessStatus.FAILURE; <START> } <END> currentTransact = null; resource.lock(); return ProcessStatus.SUCCESS; }</code><technical_language>java if (outputDock.hasTransact()) return ProcessStatus.CHECK_AGAIN; Transact transact = inputDock.pullTransact(); if (transact == null) return ProcessStatus.NOTHING_TO_DO; outputDock.pushTransact(transact);</technical_language>

Target:
public BlockStatus check() { if (resource.isLocked()) return BlockStatus.NOTHING_TO_DO; if (outputDock.hasTransact()) return BlockStatus.CHECK_AGAIN; Transact transact = inputDock.pullTransact(); if (transact == null) return BlockStatus.NOTHING_TO_DO; System.out.println(Simulator.getTime() + ": seize body " + transact.getNumber()); outputDock.pushTransact(transact); resource.lock(); return BlockStatus.SUCCESS; }
Source:
<code>public boolean contains(Patient patient) { <START> return getMembers() != null && getMembers().stream() <END> .anyMatch(m -> m.getPatientId().getPatientId().equals(patient.getPatientId())); }</code><technical_language>add a TODO item this needs changed compare Patient objects instead of ids finally remove deprecated methods ids</technical_language>

Target:
public boolean contains(Patient patient) { return contains(patient.getPatientId()); }
Source:
<code>private ListenableFuture<PrestoThriftSplitBatch> sendSplitRequest(PrestoThriftService client, @Nullable PrestoThriftId nextToken) { long start = System.nanoTime(); ListenableFuture<PrestoThriftSplitBatch> future = client.getLookupSplits( <START> schemaTableName, lookupColumnNames, outputColumnNames, keys, outputConstraint, MAX_SPLIT_COUNT, new PrestoThriftNullableToken(nextToken)); <END> future.addListener(() -> readTimeNanos.addAndGet(System.nanoTime() - start), directExecutor()); return future; }</code><technical_language>line argument</technical_language>

Target:
private ListenableFuture<PrestoThriftSplitBatch> sendSplitRequest(PrestoThriftService client, @Nullable PrestoThriftId nextToken) { long start = System.nanoTime(); ListenableFuture<PrestoThriftSplitBatch> future = client.getIndexSplits( schemaTableName, lookupColumnNames, outputColumnNames, keys, outputConstraint, MAX_SPLIT_COUNT, new PrestoThriftNullableToken(nextToken)); future.addListener(() -> readTimeNanos.addAndGet(System.nanoTime() - start), directExecutor()); return future; }
Source:
<code>public void testLargeMessageFileLeak() throws Exception { <START> Assume.assumeTrue(File.separatorChar == '/'); <END> OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); long fdBaseline = ((UnixOperatingSystemMXBean) os).getOpenFileDescriptorCount(); final int SIZE = 2 * 1024; SimpleString dla = new SimpleString("DLA"); SimpleString qName = new SimpleString("q1"); SimpleString adName = new SimpleString("ad1"); AddressSettings addressSettings = new AddressSettings().setMaxDeliveryAttempts(1).setDeadLetterAddress(dla); server.getAddressSettingsRepository().addMatch(adName.toString(), addressSettings); SimpleString dlq = new SimpleString("DLQ1"); clientSession.createQueue(dla, dlq, null, false); clientSession.createQueue(adName, qName, null, false); for (int i = 0; i < 10; i++) { ClientProducer producer = clientSession.createProducer(adName); ClientMessage clientFile = clientSession.createMessage(true); clientFile.setBodyInputStream(ActiveMQTestBase.createFakeLargeStream(SIZE)); producer.send(clientFile); clientSession.start(); ClientConsumer clientConsumer = clientSession.createConsumer(qName); ClientMessage m = clientConsumer.receive(500); m.acknowledge(); Assert.assertNotNull(m); clientSession.rollback(); m = clientConsumer.receiveImmediate(); Assert.assertNull(m); clientConsumer.close(); } assertEquals("File descriptors are leaking", 0, ((UnixOperatingSystemMXBean) os).getOpenFileDescriptorCount() - fdBaseline); }</code><technical_language>I tested windows compile fine... change this some sort of instanceof</technical_language>

Target:
public void testLargeMessageFileLeak() throws Exception { OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); Assume.assumeTrue(os instanceof UnixOperatingSystemMXBean); long fdBaseline = ((UnixOperatingSystemMXBean) os).getOpenFileDescriptorCount(); final int SIZE = 2 * 1024; SimpleString dla = new SimpleString("DLA"); SimpleString qName = new SimpleString("q1"); SimpleString adName = new SimpleString("ad1"); AddressSettings addressSettings = new AddressSettings().setMaxDeliveryAttempts(1).setDeadLetterAddress(dla); server.getAddressSettingsRepository().addMatch(adName.toString(), addressSettings); SimpleString dlq = new SimpleString("DLQ1"); clientSession.createQueue(dla, dlq, null, false); clientSession.createQueue(adName, qName, null, false); for (int i = 0; i < 10; i++) { ClientProducer producer = clientSession.createProducer(adName); ClientMessage clientFile = clientSession.createMessage(true); clientFile.setBodyInputStream(ActiveMQTestBase.createFakeLargeStream(SIZE)); producer.send(clientFile); clientSession.start(); ClientConsumer clientConsumer = clientSession.createConsumer(qName); ClientMessage m = clientConsumer.receive(500); m.acknowledge(); Assert.assertNotNull(m); clientSession.rollback(); m = clientConsumer.receiveImmediate(); Assert.assertNull(m); clientConsumer.close(); } assertEquals("File descriptors are leaking", 0, ((UnixOperatingSystemMXBean) os).getOpenFileDescriptorCount() - fdBaseline); }
Source:
<code>private void updateAlerts() { setHasAnyAlert(false); setHasUpgradeAlert(false); setHasManualFenceAlert(false); setHasNoPowerManagementAlert(false); setHasReinstallAlertNonResponsive(false); setHasReinstallAlertInstallFailed(false); setHasReinstallAlertMaintenance(false); setHasNICsAlert(false); <START> getEditHostCommand().setIsExecutionAllowed(canExecuteCommand(VdcActionType.UpdateVds)); <END> setHasNICsAlert((getEntity().getNetConfigDirty() == null ? false : getEntity().getNetConfigDirty())); if (getEntity().getStatus() == VDSStatus.NonResponsive && !getEntity().isPmEnabled() && ((getEntity().getVmActive() == null ? 0 : getEntity().getVmActive()) > 0 || getEntity().getSpmStatus() == VdsSpmStatus.SPM)) { setHasManualFenceAlert(true); } else if (!getEntity().isPmEnabled()) { setHasNoPowerManagementAlert(true); } if (getEntity().getStatus() == VDSStatus.NonResponsive) { setHasReinstallAlertNonResponsive(true); } else if (getEntity().getStatus() == VDSStatus.InstallFailed) { setHasReinstallAlertInstallFailed(true); } else if (getEntity().getStatus() == VDSStatus.Maintenance) { setHasReinstallAlertMaintenance(true); } getUpgradeHostCommand().setIsExecutionAllowed(getEntity().isUpdateAvailable() && canExecuteCommand(VdcActionType.UpgradeHost)); setNonOperationalReasonEntity((getEntity().getNonOperationalReason() == NonOperationalReason.NONE ? null : (NonOperationalReason) getEntity().getNonOperationalReason())); setHasAnyAlert(); }</code><technical_language>extract 'updateActionsAvailability' method</technical_language>

Target:
private void updateAlerts() { setHasAnyAlert(false); setHasUpgradeAlert(false); setHasManualFenceAlert(false); setHasNoPowerManagementAlert(false); setHasReinstallAlertNonResponsive(false); setHasReinstallAlertInstallFailed(false); setHasReinstallAlertMaintenance(false); setHasNICsAlert(false); setHasNICsAlert((getEntity().getNetConfigDirty() == null ? false : getEntity().getNetConfigDirty())); if (getEntity().getStatus() == VDSStatus.NonResponsive && !getEntity().isPmEnabled() && ((getEntity().getVmActive() == null ? 0 : getEntity().getVmActive()) > 0 || getEntity().getSpmStatus() == VdsSpmStatus.SPM)) { setHasManualFenceAlert(true); } else if (!getEntity().isPmEnabled()) { setHasNoPowerManagementAlert(true); } if (getEntity().getStatus() == VDSStatus.NonResponsive) { setHasReinstallAlertNonResponsive(true); } else if (getEntity().getStatus() == VDSStatus.InstallFailed) { setHasReinstallAlertInstallFailed(true); } else if (getEntity().getStatus() == VDSStatus.Maintenance) { setHasReinstallAlertMaintenance(true); } setNonOperationalReasonEntity((getEntity().getNonOperationalReason() == NonOperationalReason.NONE ? null : (NonOperationalReason) getEntity().getNonOperationalReason())); updateActionAvailability(); setHasAnyAlert(); }
Source:
<code>protected boolean canDoAction() { if (!super.canDoAction()) { return false; } GlusterVolumeEntity volume = getGlusterVolumeDao().getById(getGlusterVolumeId()); if (volume != null && volume.getStatus() == GlusterStatus.DOWN) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_DOWN); } if (!GlusterUtil.getInstance().isVolumeThinlyProvisioned(volume)) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_NOT_THINLY_PROVISIONED); } Date currentDate = new Date(); if (!(schedule.getRecurrence() == null || schedule.getRecurrence() == GlusterVolumeSnapshotScheduleRecurrence.UNKNOWN)) { <START> if (schedule.getStartDate() != null && schedule.getStartDate().compareTo(currentDate) < 0) { <END> return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_START_DATE_BEFORE_CURRENT_DATE); } if (schedule.getEndByDate() != null) { if (schedule.getEndByDate().compareTo(currentDate) < 0) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_CURRENT_DATE); } if (schedule.getStartDate() != null && schedule.getEndByDate().compareTo(schedule.getStartDate()) <= 0) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_START_DATE); } } } return true; }</code><technical_language>schedule.getStartDate() converted engine timezone compared</technical_language>

Target:
protected boolean canDoAction() { if (!super.canDoAction()) { return false; } GlusterVolumeEntity volume = getGlusterVolume(); if (volume != null && volume.getStatus() == GlusterStatus.DOWN) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_DOWN); } if (!GlusterUtil.getInstance().isVolumeThinlyProvisioned(volume)) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_NOT_THINLY_PROVISIONED); } Date currentDate = new Date(); Date convertedStartDate = convertDate(schedule.getStartDate(), schedule.getTimeZone()); Date convertedEndByDate = convertDate(schedule.getEndByDate(), schedule.getTimeZone()); if (!(schedule.getRecurrence() == null || schedule.getRecurrence() == GlusterVolumeSnapshotScheduleRecurrence.UNKNOWN)) { if (schedule.getStartDate() != null && convertedStartDate.compareTo(currentDate) < 0) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_START_DATE_BEFORE_CURRENT_DATE); } if (schedule.getEndByDate() != null) { if (convertedEndByDate.compareTo(currentDate) < 0) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_CURRENT_DATE); } if (schedule.getStartDate() != null && convertedEndByDate.compareTo(convertedStartDate) <= 0) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_START_DATE); } } } return true; }
Source:
<code><START> public void checkError() { <END> if(startAnchor.isPresent() && endAnchor.isPresent()) { try { endAnchor.get().getBlock().asExpr().analyze(new Env(), new GenSet()); this.setStyle("-fx-stroke: black;"); } catch (HaskellTypeError e) { this.setStyle("-fx-stroke: red;"); } catch (HaskellException e) { } } }</code><technical_language>Waarom public</technical_language>

Target:
private void checkError() { if(startAnchor.isPresent() && endAnchor.isPresent()) { try { endAnchor.get().getBlock().asExpr().analyze(new Env(), new GenSet()); this.getStyleClass().remove("error"); } catch (HaskellTypeError e) { this.getStyleClass().add("error"); } catch (HaskellException e) { e.printStackTrace(); } } }
Source:
<code>void <START> replaceScriptOne(StringBuilder <END> scriptOne) { translate(scriptOne, scriptOneToScriptTwo); }</code><technical_language>nit: public</technical_language>

Target:
public void replaceScriptOne(StringBuilder scriptOne) { translate(scriptOne, scriptOneToScriptTwo); }
Source:
<code>public Conversation build() { <START> return new Conversation(this.location, <END> this.protocol, this.lowerIp, this.upperIp, this.lowerHostname, this.upperHostname, this.application); }</code><technical_language>If switch single-arg constructor, pass instance of builder return new Conversation(this)</technical_language>

Target:
public Conversation build() { return new Conversation(this); }
Source:
<code>public MicrosoftOAuth2AP(String aClientId, String aClientSecret){ <START> this.id = "microsoft"; <END> this.title = "Microsoft"; this.clientId = aClientId; this.clientSecret = aClientSecret; this.scope = Arrays.asList("openid User.Read"); this.baseUserEndpoint = "<LINK_0>"; }</code><technical_language>ID correspond class name, if is changed, this change well</technical_language>

Target:
public MicrosoftOAuth2AP(String aClientId, String aClientSecret){ this.id = "microsoft"; this.title = "Microsoft"; this.clientId = aClientId; this.clientSecret = aClientSecret; this.scope = Arrays.asList("User.Read"); this.baseUserEndpoint = "<LINK_0>"; }
Source:
<code>public void validateItemType(Item item, String bindingConfig) throws BindingConfigParseException { if (!(item instanceof SwitchItem || item instanceof RollershutterItem)) { throw new BindingConfigParseException( "item '" + item.getName() + "' is of type '" + item.getClass().getSimpleName() <START> + "', this Item is not allowed - please check your *.items configuration"); <END> } }</code><technical_language>please add allowed item types in order give</technical_language>

Target:
public void validateItemType(Item item, String bindingConfig) throws BindingConfigParseException { if (!(item instanceof SwitchItem || item instanceof RollershutterItem)) { throw new BindingConfigParseException( "item '" + item.getName() + "' is of type '" + item.getClass().getSimpleName() + "', this Item is not allowed - please check your *.items configuration" + ", only SwitchItem and RollershutterItem are allowed / supported for now"); } }
Source:
<code>public void testFoo() throws Exception { <START> assumeTrue(postgresIsInstalled); <END> DAO dao = dbi.open(DAO.class); Long brian_id = dao.insert("Brian"); long keith_id = dao.insert("Keith"); assertThat(dao.findNameById(brian_id), equalTo("Brian")); assertThat(dao.findNameById(keith_id), equalTo("Keith")); dao.close(); }</code><technical_language>this in @Before ? rid of if (!postgresIsInstalled) blocks entirely, work same: <LINK_0></technical_language>

Target:
public void testFoo() throws Exception { DAO dao = dbi.open(DAO.class); Long brian_id = dao.insert("Brian"); long keith_id = dao.insert("Keith"); assertThat(dao.findNameById(brian_id), equalTo("Brian")); assertThat(dao.findNameById(keith_id), equalTo("Keith")); dao.close(); }
Source:
<code>private boolean reportShortcutBinding(String message) { <START> if (reportShortcutBinding_) <END> events_.fireEvent(new ReportShortcutBindingEvent(message)); return reportShortcutBinding_; }</code><technical_language>unchecked, checkable menu items regular menu items I people time invoke this mode need menu turn off. I this (a) self-cancelling (it reports shortcut quits) advertise a quit in message (a special shortcut a reference menu item)</technical_language>

Target:
private boolean reportShortcutBinding(String message) { if (reportShortcutBinding_) { events_.fireEvent(new ReportShortcutBindingEvent(message)); reportedPending_ = false; } return reportShortcutBinding_; }
Source:
<code>public void testEnumConstantDeclaration1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null); StringBuilder buf= new StringBuilder(); buf.append("package test;\n"); buf.append("\n"); buf.append("public enum TestEnum {\n"); buf.append(" A(11);\n"); buf.append("\n"); buf.append(" TestEnum(int value) {}\n"); buf.append("\n"); buf.append(" private static int getDefaultValue() {\n"); buf.append(" return -1;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit compilationUnit= pack1.createCompilationUnit("TestEnum.java", buf.toString(), false, null); CompilationUnit astRoot= createAST(compilationUnit); assertNoProblems(astRoot); { String str= "11"; int offset= buf.toString().indexOf(str); int flags= ScopeAnalyzer.METHODS; <START> for (IBinding re : new ScopeAnalyzer(astRoot).getDeclarationsInScope(offset, flags)) { <END> if ("getDefaultValue".equals(re.getName())) { return; } } assertFalse("getDefaultValue not found", true); } }</code><technical_language>change binding</technical_language>

Target:
public void testEnumConstantDeclaration1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null); StringBuilder buf= new StringBuilder(); buf.append("package test;\n"); buf.append("\n"); buf.append("public enum TestEnum {\n"); buf.append(" A(11);\n"); buf.append("\n"); buf.append(" TestEnum(int value) {}\n"); buf.append("\n"); buf.append(" private static int getDefaultValue() {\n"); buf.append(" return -1;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit compilationUnit= pack1.createCompilationUnit("TestEnum.java", buf.toString(), false, null); CompilationUnit astRoot= createAST(compilationUnit); assertNoProblems(astRoot); { String str= "11"; int offset= buf.toString().indexOf(str); int flags= ScopeAnalyzer.METHODS; for (IBinding binding : new ScopeAnalyzer(astRoot).getDeclarationsInScope(offset, flags)) { if ("getDefaultValue".equals(binding.getName())) { return; } } assertFalse("getDefaultValue not found", true); } }
Source:
<code><START> public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream) throws Http2Exception { <END> Http2ClientStream stream = (Http2ClientStream) streams.get(streamId); stream.setStreamDependency(streamDependency); stream.setWeight(weight); onHeadersRead(ctx, streamId, headers, padding, endOfStream); }</code><technical_language>synchronized</technical_language>

Target:
public synchronized void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream) throws Http2Exception { Http2ClientStream stream = (Http2ClientStream) streams.get(streamId); if (stream != null) { context.executeFromIO(v -> { stream.handleHeaders(headers, new StreamPriority(streamDependency, weight, exclusive), endOfStream); }); } }
Source:
<code>public static <T> Query<T> verifyMaxQueryTimeout(Query<T> query, long maxQueryTimeout) { <START> Object obj = query.getContextValue(TIMEOUT_KEY); <END> if (obj == null) { return query; } else { long curr = ((Number) obj).longValue(); if (curr > maxQueryTimeout) { throw new IAE( "configured [%s = %s] is more than enforced limit of maxQueryTimeout [%s].", TIMEOUT_KEY, curr, maxQueryTimeout ); } else { return query; } } }</code><technical_language>This getTimeout(query) accept Strings (which getTimeout pains accept)</technical_language>

Target:
public static <T> Query<T> verifyMaxQueryTimeout(Query<T> query, long maxQueryTimeout) { long timeout = getTimeout(query); if (timeout > maxQueryTimeout) { throw new IAE( "configured [%s = %s] is more than enforced limit of maxQueryTimeout [%s].", TIMEOUT_KEY, timeout, maxQueryTimeout ); } else { return query; } }
Source:
<code>public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException { String restOfPath = req.getRestOfPath(); if (restOfPath.isEmpty()) { String url = Jenkins.get().getRootUrl() + browserUrl; rsp.sendRedirect(302, url); return; } AccessControlled requestRoot = Jenkins.get(); String requestUrlSuffix = this.browserUrl; <START> if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Performing a request as authentication: " + authenticationName + " to object: " + requestRoot + " and restOfUrl: " + requestUrlSuffix + " and restOfPath: " + restOfPath); <END> } Authentication auth = Jenkins.ANONYMOUS; if (authenticationName != null) { User user = User.getById(authenticationName, false); if (user != null) { auth = user.impersonate(); } } try (ACLContext ignored = ACL.as(auth)) { Stapler.getCurrent().invoke(req, rsp, requestRoot, requestUrlSuffix + restOfPath); } catch (AccessDeniedException ade) { LOGGER.log(Level.INFO, "Failed permission check for resource URL access", ade); rsp.sendError(403, "Failed permission check: " + ade.getMessage()); } catch (Exception e) { LOGGER.log(Level.INFO, "Something else failed for resource URL access", e); rsp.sendError(404, "Failed: " + e.getMessage()); } }</code><technical_language>Nit: this lambda API a liner</technical_language>

Target:
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException { String restOfPath = req.getRestOfPath(); String requestUrlSuffix = this.browserUrl; LOGGER.fine(() -> "Performing a request as authentication: " + authenticationName + " and restOfUrl: " + requestUrlSuffix + " and restOfPath: " + restOfPath); Authentication auth = Jenkins.ANONYMOUS; if (authenticationName != null) { User user = User.getById(authenticationName, false); if (user != null) { try { auth = user.impersonate(); LOGGER.fine(() -> "Successfully impersonated " + authenticationName); } catch (UsernameNotFoundException ex) { LOGGER.log(Level.FINE, "Failed to impersonate " + authenticationName, ex); rsp.sendError(403, "No such user: " + authenticationName); return; } } } try (ACLContext ignored = ACL.as(auth)) { try { Stapler.getCurrent().invoke(req, rsp, Jenkins.get(), requestUrlSuffix + restOfPath); } catch (Exception ex) { Throwable cause = ex.getCause(); while (cause != null) { if (cause instanceof AccessDeniedException) { throw (AccessDeniedException) cause; } cause = cause.getCause(); } throw ex; } } catch (AccessDeniedException ade) { LOGGER.log(Level.FINE, "Failed permission check for resource URL access", ade); rsp.sendError(403, "Failed permission check: " + ade.getMessage()); } catch (Exception e) { LOGGER.log(Level.FINE, "Something else failed for resource URL access", e); rsp.sendError(404); } }
Source:
<code>private void respondToQuery(HttpServletRequest req, HttpServletResponse resp) throws IOException { RDFService rdfService = ModelAccess.on(getServletContext()) .getRDFService(); String queryString = req.getParameter("query"); boolean download = Boolean.parseBoolean(req.getParameter("download")); Query query = SparqlQueryUtils.create(queryString); try { String format = interpretRequestedFormats(req, query); SparqlQueryApiExecutor core = SparqlQueryApiExecutor.instance( rdfService, queryString, format); resp.setContentType(core.getMediaType()); if (download) { String extension = getFilenameExtension(req, query, format); resp.setHeader("Content-Transfer-Encoding", "binary"); <START> resp.setHeader("Content-disposition", "attachment; filename=sparqlquery." + extension); <END> } core.executeAndFormat(resp.getOutputStream()); } catch (InvalidQueryTypeException e) { do400BadRequest("Query type is not SELECT, ASK, CONSTRUCT, " + "or DESCRIBE: '" + queryString + "'", resp); } catch (QueryParseException e) { do400BadRequest("Failed to parse query: '" + queryString + "''", e, resp); } catch (NotAcceptableException | AcceptHeaderParsingException e) { do500InternalServerError("Problem with the page fields: the " + "selected fields do not include an " + "acceptable content type.", e, resp); } catch (RDFServiceException e) { do500InternalServerError("Problem executing the query.", e, resp); } }</code><technical_language>This works well. minor suggestion is potentially change downloaded filename "query-results" ... instead of "sparqlquery"</technical_language>

Target:
private void respondToQuery(HttpServletRequest req, HttpServletResponse resp) throws IOException { RDFService rdfService = ModelAccess.on(getServletContext()) .getRDFService(); String queryString = req.getParameter("query"); boolean download = Boolean.parseBoolean(req.getParameter("download")); Query query = SparqlQueryUtils.create(queryString); try { String format = interpretRequestedFormats(req, query); SparqlQueryApiExecutor core = SparqlQueryApiExecutor.instance( rdfService, queryString, format); resp.setContentType(core.getMediaType()); if (download) { String extension = getFilenameExtension(req, query, format); resp.setHeader("Content-Transfer-Encoding", "binary"); resp.setHeader("Content-disposition", "attachment; filename=query-results." + extension); } core.executeAndFormat(resp.getOutputStream()); } catch (InvalidQueryTypeException e) { do400BadRequest("Query type is not SELECT, ASK, CONSTRUCT, " + "or DESCRIBE: '" + queryString + "'", resp); } catch (QueryParseException e) { do400BadRequest("Failed to parse query: '" + queryString + "''", e, resp); } catch (NotAcceptableException | AcceptHeaderParsingException e) { do500InternalServerError("Problem with the page fields: the " + "selected fields do not include an " + "acceptable content type.", e, resp); } catch (RDFServiceException e) { do500InternalServerError("Problem executing the query.", e, resp); } }
Source:
<code>public void load(long position, BufferReference bufferReference, int length) { if (position < 0 || position + length > totalLength) { throw new IllegalArgumentException(); } int sliceIndex = 0; while (position >= slices.get(sliceIndex).length()) { <START> position -= slices.get(sliceIndex).length(); <END> sliceIndex++; } int slicePosition = toIntExact(position); Slice outputSlice = bufferReference.getSlice(); int destinationIndex = 0; while (length > 0) { Slice currentSlice = slices.get(sliceIndex); int loadSize = Math.min(currentSlice.length() - slicePosition, length); currentSlice.getBytes(slicePosition, outputSlice, destinationIndex, loadSize); length -= loadSize; destinationIndex += loadSize; if (length == 0) { break; } sliceIndex++; slicePosition = 0; } }</code><technical_language>I find this code hard read due mutation of position. code changes meaning of variable, "read set current slice". Instead of modifying this variable, I suggest variables named: currentSliceIndex: Index if slice is considered currentSliceGlobalOffset: Offset of slice in global ordered stream outputSliceOffset: write offset outputSlice Modifying length fine retains meaning "remaining number of bytes copy"</technical_language>

Target:
public void load(long position, BufferReference bufferReference, int length) { if (position < 0 || position + length > totalLength) { throw new IllegalArgumentException(); } int currentSliceIndex = 0; long globalOffset = 0; while (globalOffset + slices.get(currentSliceIndex).length() <= position) { globalOffset += slices.get(currentSliceIndex).length(); currentSliceIndex++; } int currentSliceOffset = toIntExact(position - globalOffset); Slice outputSlice = bufferReference.getSlice(); int outputSliceOffset = 0; while (length > 0) { Slice currentSlice = slices.get(currentSliceIndex); int loadSize = Math.min(currentSlice.length() - currentSliceOffset, length); currentSlice.getBytes(currentSliceOffset, outputSlice, outputSliceOffset, loadSize); length -= loadSize; outputSliceOffset += loadSize; currentSliceIndex++; currentSliceOffset = 0; } }
Source:
<code>public Reply<?> fetchEncodings() { List<Encoding> encodings = catalog.findAll(); <START> List<String> list = adapt(encodings); <END> return Reply.with(list).as(Json.class).ok(); }</code><technical_language>rename list dto</technical_language>

Target:
public Reply<?> fetchEncodings() { List<Encoding> encodings = catalog.findAll(); List<String> dto = adapt(encodings); return Reply.with(dto).as(Json.class).ok(); }
Source:
<code>public ResourceResponse<Document> upsertMetadata(CloudBlobMetadata blobMetadata) throws DocumentClientException { RequestOptions options = getRequestOptions(blobMetadata.getPartitionId()); return retryOperationWithThrottling( <START> () -> documentClient.upsertDocument(cosmosCollectionLink, blobMetadata, null, true), <END> azureMetrics.documentCreateTime); }</code><technical_language>do need options partition key. need debug error values are. bring in debugger set a breakpoint there</technical_language>

Target:
public ResourceResponse<Document> upsertMetadata(CloudBlobMetadata blobMetadata) throws DocumentClientException { RequestOptions options = getRequestOptions(blobMetadata.getPartitionId()); return retryOperationWithThrottling( () -> documentClient.upsertDocument(cosmosCollectionLink, blobMetadata, options, true), azureMetrics.documentCreateTime); }
Source:
<code>private boolean isEditable(Object element, MergeViewerSide side) { <START> final boolean isEditibleInConfiguration = isEditableInConfiguration(side); <END> if (isEditibleInConfiguration && isCompareInputAdapterHoldingADiff(element)) { final CompareInputAdapter inputAdapter = (CompareInputAdapter)element; final IModelUpdateStrategy modelUpdateStrategy = inputAdapter.getModelUpdateStrategy(); final Diff diff = (Diff)inputAdapter.getComparisonObject(); return modelUpdateStrategy.canUpdate(diff, side); } return isEditibleInConfiguration; }</code><technical_language>isEditable... instead of isEditible ;)</technical_language>

Target:
private boolean isEditable(Object element, MergeViewerSide side) { final boolean isEditableInConfiguration = isEditableInConfiguration(side); if (isEditableInConfiguration && isCompareInputAdapterHoldingADiff(element)) { final CompareInputAdapter inputAdapter = (CompareInputAdapter)element; final IModelUpdateStrategy modelUpdateStrategy = inputAdapter.getModelUpdateStrategy(); final Diff diff = (Diff)inputAdapter.getComparisonObject(); return modelUpdateStrategy.canUpdate(diff, side); } return isEditableInConfiguration; }
Source:
<code>public static Map<String, Long> subtract(Map<String, Long> xs, Map<String, Long> ys) { assert xs.keySet().equals(ys.keySet()); final Map<String, Long> zs = new HashMap<String, Long>(); for (Map.Entry<String, Long> entry : xs.entrySet()) { <START> zs.put(entry.getKey(), xs.get(entry.getKey()) - ys.get(entry.getKey())); <END> } return zs; }</code><technical_language>xs.get(entry.getKey()) -> entry.getValue()</technical_language>

Target:
public static Map<String, Long> subtract(Map<String, Long> xs, Map<String, Long> ys) { assert xs.keySet().equals(ys.keySet()); final Map<String, Long> zs = new HashMap<String, Long>(); for (Map.Entry<String, Long> entry : xs.entrySet()) { zs.put(entry.getKey(), entry.getValue() - ys.get(entry.getKey())); } return zs; }
Source:
<code>public void testResumeTxInAnotherThread() throws Exception { executeTestForAllCaches(new CI2Exc<Ignite, IgniteCache<Integer, Integer>>() { @Override public void applyx(Ignite ignite, final IgniteCache<Integer, Integer> cache) throws Exception { for (TransactionIsolation isolation : TransactionIsolation.values()) { final Transaction tx = ignite.transactions().txStart(transactionConcurrency(), isolation); final AtomicInteger cntr = new AtomicInteger(0); for (int j = -1; j > -10; j--) cache.put(j, j); cache.put(cntr.get(), cntr.getAndIncrement()); tx.suspend(); assertEquals(SUSPENDED, tx.state()); assertNull("Thread already have tx", ignite.transactions().tx()); assertNull(cache.get(-1)); assertNull(cache.get(cntr.get())); for (int i = 0; i < 10; i++) { <START> GridTestUtils.runAsync(new Runnable() { <END> @Override public void run() { assertEquals(SUSPENDED, tx.state()); tx.resume(); assertEquals(ACTIVE, tx.state()); for (int j = -1; j > -10; j--) cache.put(j, j); cache.put(cntr.get(), cntr.getAndIncrement()); tx.suspend(); } }).get(FUT_TIMEOUT); } tx.resume(); for (int j = -1; j > -10; j--) cache.remove(j); tx.commit(); assertEquals(COMMITTED, tx.state()); for (int i = 0; i < cntr.get(); i++) assertEquals(i, (int)cache.get(i)); assertFalse(cache.containsKey(-1)); cache.removeAll(); } } }); }</code><technical_language>replaced lambda</technical_language>

Target:
public void testResumeTxInAnotherThread() throws Exception { executeTestForAllCaches(new CI2Exc<Ignite, IgniteCache<Integer, Integer>>() { @Override public void applyx(Ignite ignite, final IgniteCache<Integer, Integer> cache) throws Exception { for (TransactionIsolation isolation : TransactionIsolation.values()) { final Transaction tx = ignite.transactions().txStart(transactionConcurrency(), isolation); final AtomicInteger cntr = new AtomicInteger(0); for (int j = -1; j > -10; j--) cache.put(j, j); cache.put(cntr.get(), cntr.getAndIncrement()); tx.suspend(); assertEquals(SUSPENDED, tx.state()); assertNull("Thread already have tx", ignite.transactions().tx()); assertNull(cache.get(-1)); assertNull(cache.get(cntr.get())); for (int i = 0; i < 10; i++) { GridTestUtils.runAsync(() -> { assertEquals(SUSPENDED, tx.state()); tx.resume(); assertEquals(ACTIVE, tx.state()); for (int j = -1; j > -10; j--) cache.put(j, j); cache.put(cntr.get(), cntr.getAndIncrement()); tx.suspend(); }).get(FUT_TIMEOUT); } tx.resume(); for (int j = -1; j > -10; j--) cache.remove(j); tx.commit(); assertEquals(COMMITTED, tx.state()); for (int i = 0; i < cntr.get(); i++) assertEquals(i, (int)cache.get(i)); assertFalse(cache.containsKey(-1)); cache.removeAll(); } } }); }
Source:
<code>private boolean isKeyExpired() { <START> return System.nanoTime() - lastGenerationNanos > keyLifetime; <END> }</code><technical_language>while counting nanoseconds ... store time created key calculate time of expiration create key simply compare System.nanoTime() expiration time. save recurring calculation of expiration time ..</technical_language>

Target:
private boolean isKeyExpired() { return (System.nanoTime() - nextKeyGenerationNanos) >= 0; }
Source:
<code>void tzidsOrderMustNotChange() throws URISyntaxException, IOException { Path path = Paths.get( TimeZones.class.getResource( "/TZIDS" ).toURI() ); <START> String timeZonesInfo = Files.readString( path ).replace( System.lineSeparator(), "\n" ); <END> byte[] timeZonesHash = DigestUtils.sha256( timeZonesInfo ); assertThat( timeZonesHash, equalTo( new byte[]{-9, 121, 49, -61, 86, 11, 77, -117, 77, 105, -15, -16, 4, 109, 62, 107, -118, 99, 9, -121, -58, 76, -41, 29, 43, 86, -68, 118, -86, 34, 99, 63} ) ); }</code><technical_language>Git change line endings of TZIDS checkout? is this necessary? suspicious this reading file a string is relying platform encoding, encodings sha256 of file stay same</technical_language>

Target:
void tzidsOrderMustNotChange() throws URISyntaxException, IOException { Path path = Paths.get( TimeZones.class.getResource( "/TZIDS" ).toURI() ); String timeZonesInfo = Files.readString( path ).replace( "\r\n", "\n" ); byte[] timeZonesHash = DigestUtils.sha256( timeZonesInfo ); assertThat( timeZonesHash ).isEqualTo( new byte[]{-9, 121, 49, -61, 86, 11, 77, -117, 77, 105, -15, -16, 4, 109, 62, 107, -118, 99, 9, -121, -58, 76, -41, 29, 43, 86, -68, 118, -86, 34, 99, 63} ); }
Source:
<code>private void cleanupExpiredInflightRequests() { Iterator<Map.Entry<Integer, InflightRequestInfo>> itr = inflightRequestInfos.entrySet().iterator(); while (itr.hasNext()) { InflightRequestInfo inflightRequestInfo = itr.next().getValue(); if (time.milliseconds() - inflightRequestInfo.submissionTime > routerConfig.routerRequestTimeoutMs) { itr.remove(); resolveRouterError(RouterErrorCode.OperationTimedOut); <START> operationTracker.onResponse(inflightRequestInfo.replica, false); <END> } } }</code><technical_language>updateOperationStatus here</technical_language>

Target:
private void cleanupExpiredInflightRequests() { Iterator<Map.Entry<Integer, InflightRequestInfo>> itr = inflightRequestInfos.entrySet().iterator(); while (itr.hasNext()) { InflightRequestInfo inflightRequestInfo = itr.next().getValue(); if (time.milliseconds() - inflightRequestInfo.submissionTime > routerConfig.routerRequestTimeoutMs) { itr.remove(); updateOperationState(inflightRequestInfo.replica, RouterErrorCode.OperationTimedOut); } } }
Source:
<code>public void actionPerformed(AnActionEvent event) { Optional<VirtualFile> maybeBuildRoot = PantsUtil.findBuildRoot(event.getProject()); Optional<VirtualFile> maybeFile = PantsUtil.getFileForEvent(event); <START> if (!maybeBuildRoot.isPresent() || !maybeFile.isPresent()) { <END> return; } VirtualFile buildRoot = maybeBuildRoot.get(); VirtualFile file = maybeFile.get(); Path filePath = Paths.get(file.getPath()); Path buildRootPath = Paths.get(buildRoot.getPath()); String relativePath = buildRootPath.relativize(filePath).toString(); Toolkit.getDefaultToolkit().getSystemClipboard().setContents( new StringSelection(relativePath), null ); }</code><technical_language>DeMorgans this !(mBR.isPresent() && mF.isPresent()). I that'd clearer mirror expression in update</technical_language>

Target:
public void actionPerformed(AnActionEvent event) { Optional<VirtualFile> maybeBuildRoot = PantsUtil.findBuildRoot(event.getProject()); Optional<VirtualFile> maybeFile = PantsUtil.getFileForEvent(event); if (!(maybeBuildRoot.isPresent() && maybeFile.isPresent())) { return; } VirtualFile buildRoot = maybeBuildRoot.get(); VirtualFile file = maybeFile.get(); Path filePath = Paths.get(file.getPath()); Path buildRootPath = Paths.get(buildRoot.getPath()); String relativePath = buildRootPath.relativize(filePath).toString(); Toolkit.getDefaultToolkit().getSystemClipboard().setContents( new StringSelection(relativePath), null ); }
Source:
<code>static synchronized SnappyApi loadSnappyApi() { if (snappyApi != null) { return snappyApi; } ByteOrder order = ByteOrder.nativeOrder(); try { if(Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_PUREJAVA, "false"))) { if (order.equals(ByteOrder.LITTLE_ENDIAN)) setSnappyApi(new PureJavaSnappy()); else setSnappyApi(new PureJavaSnappyBE()); } else { loadNativeLibrary(); setSnappyApi(new SnappyNative()); } } catch(Exception e) { <START> if (order.equals(ByteOrder.LITTLE_ENDIAN)) setSnappyApi(new PureJavaSnappy()); else setSnappyApi(new PureJavaSnappyBE()); <END> } return snappyApi; }</code><technical_language>This is a duplicated code. extract this part, for example, private static void loadPureJavaSnappy() { ... }</technical_language>

Target:
static synchronized SnappyApi loadSnappyApi() { if (snappyApi != null) { return snappyApi; } try { if(Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_PUREJAVA, "false"))) { setSnappyApi(new PureJavaSnappy()); } else { loadNativeLibrary(); setSnappyApi(new SnappyNative()); } } catch(Exception e) { setSnappyApi(new PureJavaSnappy()); } return snappyApi; }