auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testMaxTablets() throws Exception { String maxTablets = "0"; try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) { maxTablets = client.instanceOperations().getSystemConfiguration() .get(Property.MASTER_BULK_MAX_TABLETS.getKey()); <START> client.instanceOperations().setProperty(Property.MASTER_BULK_MAX_TABLETS.getKey(), "1"); <END> testBulkFile(false, false); fail("Expected IllegalArgumentException for " + Property.MASTER_BULK_MAX_TABLETS); } catch (IllegalArgumentException e) finally { try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) { client.instanceOperations().setProperty(Property.MASTER_BULK_MAX_TABLETS.getKey(), maxTablets); } } }</code><technical_language>I completely sure, lines work expected sometimes. I able happen is property is set tserver A line line reads props tserver B. If server B clear zoocache, return a stale copy w/o prop set line. I if client side code get props forces a prop cache clear</technical_language>

Target:
public void testMaxTablets() throws Exception { try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) { tableName = "testMaxTablets_table1"; NewTableConfiguration newTableConf = new NewTableConfiguration(); var props = Map.of(Property.TABLE_BULK_MAX_TABLETS.getKey(), "2"); newTableConf.setProperties(props); client.tableOperations().create(tableName, newTableConf); var thrown = assertThrows(RuntimeException.class, () -> testBulkFileMax(false)); var c = thrown.getCause(); assertTrue("Wrong exception: " + c, c instanceof ExecutionException); assertTrue("Wrong exception: " + c.getCause(), c.getCause() instanceof IllegalArgumentException); var msg = c.getCause().getMessage(); assertTrue("Bad File not in exception: " + msg, msg.contains("bad-file.rf")); c = assertThrows(AccumuloException.class, () -> testBulkFileMax(true)); msg = c.getMessage(); assertTrue("Bad File not in exception: " + msg, msg.contains("bad-file.rf")); } }
Source:
<code><START> public ArrayInterface setDouble(int index, double value) { <END> return setObject(index, value); }</code><technical_language>I return Array here</technical_language>

Target:
public Array setDouble(int index, double value) { return setObject(index, value); }
Source:
<code>public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); context.record( TransformLineageRecorderUtils.allInToOneOut(TransformLineageRecorderUtils.getFields(context.getInputSchema()), TransformLineageRecorderUtils.getFields(context.getOutputSchema()) <START> .get(0), <END> "jsonFormat", "Format data as a JSON string.")); }</code><technical_language>check if list is empty</technical_language>

Target:
public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); if (!TransformLineageRecorderUtils.getFields(context.getOutputSchema()).isEmpty()) { context.record(TransformLineageRecorderUtils.generateManyToOne( TransformLineageRecorderUtils.getFields(context.getInputSchema()), TransformLineageRecorderUtils.getFields(context.getOutputSchema()).get(0), "jsonFormat", "Formatted data as a JSON string.")); } }
Source:
<code>public String getName() { if (getTableAlias() == null) { return getAlias(); <START> } else if (getTableAlias().length() == 0) { <END> return getColumnName(); } else { return getTableAlias() + "." + getColumnName(); } }</code><technical_language>Is a table alias of length 0 a requiring special casing drop apparently unprefixed '.'</technical_language>

Target:
public String getName() { if (m_tableAlias == null) { return m_alias; } else if (m_tableAlias.length() == 0) { return m_columnName; } else { return m_tableAlias + "." + m_columnName; } }
Source:
<code>public AbstractDataView( SerializableSupplier<? extends DataProvider<T, ?>> dataProviderSupplier, Component component) { Objects.requireNonNull(dataProviderSupplier, "DataProvider supplier cannot be null"); this.dataProviderSupplier = dataProviderSupplier; this.component = component; final DataProvider<T, ?> dataProvider = dataProviderSupplier.get(); Objects.requireNonNull(dataProvider, <START> "Supplied DataProvider cannot be null"); <END> this.identityProvider = dataProvider::getId; verifyDataProviderType(dataProvider.getClass()); }</code><technical_language>presume this, is IMO fine user adds size change listener data view setting data provider <LINK_0></technical_language>

Target:
public AbstractDataView( SerializableSupplier<? extends DataProvider<T, ?>> dataProviderSupplier, Component component) { Objects.requireNonNull(dataProviderSupplier, "DataProvider supplier cannot be null"); this.dataProviderSupplier = dataProviderSupplier; this.component = component; verifyDataProviderType(dataProviderSupplier.get().getClass()); }
Source:
<code>public void testAppendNoMappingExists() { ServerStore store = newStore(); store.append(1, getPayload(1)); Chain chain = store.get(1); assertThat(chain.isEmpty(), is(false)); for (Element element : chain) { <START> assertThat(readPayLoad(element.getPayload()), is(Long.valueOf(1))); <END> } }</code><technical_language>Iterator return multiple items erroneously pass</technical_language>

Target:
public void testAppendNoMappingExists() { ServerStore store = newStore(); store.append(1, createPayload(1)); Chain chain = store.get(1); assertThat(chain.isEmpty(), is(false)); assertChainAndReverseChainOnlyHave(chain, 1); }
Source:
<code>void send( CatchUpRequest request ) throws CatchUpClientException { <START> if ( !nettyChannel.isActive() ) <END> { throw new CatchUpClientException( "Channel is not connected" ); } nettyChannel.write( request.messageType() ); nettyChannel.writeAndFlush( request ); }</code><technical_language>nice(r) if pool hand out inactive channels. This done sync() instead of await() connecting (perhaps catch wrap in CatchupClientException well), register nettyChannel.closeFuture() some call pool removes channel if is idle</technical_language>

Target:
void send( CatchUpRequest request ) throws ConnectException { if ( !isActive() ) { throw new ConnectException( "Channel is not connected" ); } nettyChannel.write( request.messageType() ); nettyChannel.writeAndFlush( request ).addListener( ChannelFutureListener.CLOSE_ON_FAILURE ); }
Source:
<code>public AdministrativeStatusType convertTo( final com.alliander.osgp.dto.valueobjects.smartmetering.AdministrativeStatusType source, final Type<AdministrativeStatusType> destinationType) { if (source == null) { return null; } if (source == com.alliander.osgp.dto.valueobjects.smartmetering.AdministrativeStatusType.OFF) { return AdministrativeStatusType.OFF; <START> } else if (source == com.alliander.osgp.dto.valueobjects.smartmetering.AdministrativeStatusType.ON) { <END> return AdministrativeStatusType.ON; } else { return AdministrativeStatusType.UNDEFINED; } }</code><technical_language>Nice this bug fixed. This code caused a critical SonarQube issue. However, for mapping of enums this approach preferred: java return AdministrativeStatusType.fromValue(source.name()); - work (given enums equal members) - matter members enums (an if() else if() else approach hard maintain for enums members) - previous mistake in this piece of code wich caused a critical SonarQube issue caused a bug enum.fromValue( otherEnum.name() );</technical_language>

Target:
public AdministrativeStatusType convertTo( final com.alliander.osgp.dto.valueobjects.smartmetering.AdministrativeStatusType source, final Type<AdministrativeStatusType> destinationType) { if (source == null) { return null; } return AdministrativeStatusType.fromValue(source.name()); }
Source:
<code><START> public static void applyWorkspaceOverride(boolean overrideWorkspaceSettings, boolean offlineMode, boolean buildScansEnabled, ILaunchConfigurationWorkingCopy launchConfiguration) { <END> launchConfiguration.setAttribute(OVERRIDE_WORKSPACE_SETTINGS, overrideWorkspaceSettings); if (overrideWorkspaceSettings) { launchConfiguration.setAttribute(OVERRIDDEN_OFFLINE_MODE, offlineMode); launchConfiguration.setAttribute(OVERRIDDEN_BUILD_SCANS_ENABLED, buildScansEnabled); } else { launchConfiguration.removeAttribute(OVERRIDDEN_OFFLINE_MODE); launchConfiguration.removeAttribute(OVERRIDDEN_BUILD_SCANS_ENABLED); } }</code><technical_language>methods public? callers single apply method</technical_language>

Target:
public static void applyWorkspaceOverride(boolean overrideWorkspaceSettings, boolean offlineMode, boolean buildScansEnabled, ILaunchConfigurationWorkingCopy launchConfiguration) { launchConfiguration.setAttribute(OVERRIDE_WORKSPACE_SETTINGS, overrideWorkspaceSettings); if (overrideWorkspaceSettings) { launchConfiguration.setAttribute(OFFLINE_MODE, offlineMode); launchConfiguration.setAttribute(BUILD_SCANS_ENABLED, buildScansEnabled); } else { launchConfiguration.removeAttribute(OFFLINE_MODE); launchConfiguration.removeAttribute(BUILD_SCANS_ENABLED); } }
Source:
<code>private void buildDeltaForFocusChangedEvent(VMDelta parentDelta, int nodeOffset, RequestMonitor rm) { <START> getSession().getExecutor().execute(new Runnable() { <END> @Override public void run() { IDMContext found = null; IGDBSynchronizer fGdbSync = getServicesTracker().getService(IGDBSynchronizer.class); Object[] elems = fGdbSync.getFocus(); for (Object elem : elems) { if (elem instanceof IExecutionDMContext) { found = (IDMContext)elem; break; } } final IDMContext newThread = found; if (newThread != null) { getVMCIndexForDmc( ThreadVMNode.this, newThread, parentDelta, new DataRequestMonitor<Integer>(getExecutor(), rm) { @Override protected void handleCompleted() { if (isSuccess()) { final int threadOffset = getData(); parentDelta.addNode( createVMContext(newThread), nodeOffset + threadOffset, IModelDelta.SELECT | IModelDelta.FORCE ); rm.done(); } } }); } } }); }</code><technical_language>DsfRunnable provide some traceability features</technical_language>

Target:
private void buildDeltaForFocusChangedEvent(VMDelta parentDelta, int nodeOffset, RequestMonitor rm) { getSession().getExecutor().execute(new DsfRunnable() { @Override public void run() { IDMContext found = null; IGDBSynchronizer fGdbSync = getServicesTracker().getService(IGDBSynchronizer.class); Object[] elems = fGdbSync.getFocus(); for (Object elem : elems) { if (elem instanceof IExecutionDMContext) { found = (IDMContext)elem; break; } } final IDMContext newThread = found; if (newThread != null) { getVMCIndexForDmc( ThreadVMNode.this, newThread, parentDelta, new DataRequestMonitor<Integer>(getExecutor(), rm) { @Override protected void handleSuccess() { final int threadOffset = getData(); parentDelta.addNode(createVMContext(newThread), nodeOffset + threadOffset, IModelDelta.SELECT | IModelDelta.FORCE); rm.done(); } }); } else { rm.done(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "ThreadVMNode, Unable to resolve thread context for focus changed event ", null)); } } }); }
Source:
<code>public void parseBlockComments(String text) { <START> blockComments = new ArrayList<int[]>(); <END> StringReader buffer = new StringReader(text); int ch; boolean blkComment = false; int cnt = 0; int[] offsets = new int[2]; boolean done = false; try { while (!done) { switch (ch = buffer.read()) { case -1 : { if (blkComment) { offsets[1] = cnt; blockComments.add(offsets); } done = true; break; } case '/' : { ch = buffer.read(); if ((ch == '*') && (!blkComment)) { offsets = new int[2]; offsets[0] = cnt; blkComment = true; cnt++; } else { cnt++; } cnt++; break; } case '*' : { if (blkComment) { ch = buffer.read(); cnt++; if (ch == '/') { blkComment = false; offsets[1] = cnt; blockComments.add(offsets); } } cnt++; break; } default : { cnt++; break; } } } } catch(IOException e) { } }</code><technical_language>need for type here</technical_language>

Target:
public void parseBlockComments(String text) { blockComments = new ArrayList<>(); StringReader buffer = new StringReader(text); int ch; boolean blkComment = false; int cnt = 0; int[] offsets = new int[2]; boolean done = false; try { while (!done) { switch (ch = buffer.read()) { case -1 : { if (blkComment) { offsets[1] = cnt; blockComments.add(offsets); } done = true; break; } case '/' : { ch = buffer.read(); if ((ch == '*') && (!blkComment)) { offsets = new int[2]; offsets[0] = cnt; blkComment = true; cnt++; } else { cnt++; } cnt++; break; } case '*' : { if (blkComment) { ch = buffer.read(); cnt++; if (ch == '/') { blkComment = false; offsets[1] = cnt; blockComments.add(offsets); } } cnt++; break; } default : { cnt++; break; } } } } catch(IOException e) { } }
Source:
<code>private static boolean checkFirstMiddleLastNameContents(EnExplicitFamily lastname, EnExplicitGiven firstname, EnExplicitGiven middlename, Personname personNameDBModel) { boolean namefound = false; if (lastname != null && lastname.getContent() != null) { personNameDBModel.setLastName(lastname.getContent()); <START> LOG.info("FamilyName : " + personNameDBModel.getLastName()); <END> namefound = true; } if (firstname != null && firstname.getContent() != null) { personNameDBModel.setFirstName(firstname.getContent()); LOG.info("GivenName(first) : " + personNameDBModel.getFirstName()); namefound = true; } if (middlename != null && middlename.getContent() != null) { personNameDBModel.setMiddleName(middlename.getContent()); LOG.info("GivenName(middle) : " + personNameDBModel.getMiddleName()); namefound = true; } return namefound; }</code><technical_language>parameterized log</technical_language>

Target:
private static boolean checkFirstMiddleLastNameContents(EnExplicitFamily lastname, EnExplicitGiven firstname, EnExplicitGiven middlename, Personname personNameDBModel) { boolean namefound = false; if (lastname != null && lastname.getContent() != null) { personNameDBModel.setLastName(lastname.getContent()); LOG.info("FamilyName : ", personNameDBModel.getLastName()); namefound = true; } if (firstname != null && firstname.getContent() != null) { personNameDBModel.setFirstName(firstname.getContent()); LOG.info("GivenName(first) : ", personNameDBModel.getFirstName()); namefound = true; } if (middlename != null && middlename.getContent() != null) { personNameDBModel.setMiddleName(middlename.getContent()); LOG.info("GivenName(middle) : ", personNameDBModel.getMiddleName()); namefound = true; } return namefound; }
Source:
<code>public ScenarioGridColumn build() { List<GridColumn.HeaderMetaData> headerMetaDataList = headerBuilder.build(); ScenarioGridColumnRenderer actualScenarioGridColumnRenderer = scenarioGridColumnRenderer != null ? scenarioGridColumnRenderer : new ScenarioGridColumnRenderer(); ScenarioGridColumn scenarioGridColumn = new ScenarioGridColumn(headerMetaDataList, actualScenarioGridColumnRenderer, width, isMovable, factoryCell, placeHolder ); scenarioGridColumn.setColumnWidthMode(GridColumn.ColumnWidthMode.auto); <START> scenarioGridColumn.setMinimumWidth(width); <END> return scenarioGridColumn; }</code><technical_language>If defaults for ScenarioGridColumn, set ScenarioGridColumn constructor</technical_language>

Target:
public ScenarioGridColumn build() { List<GridColumn.HeaderMetaData> headerMetaDataList = headerBuilder.build(); ScenarioGridColumnRenderer actualScenarioGridColumnRenderer = scenarioGridColumnRenderer != null ? scenarioGridColumnRenderer : new ScenarioGridColumnRenderer(); return new ScenarioGridColumn(headerMetaDataList, actualScenarioGridColumnRenderer, width, isMovable, factoryCell, placeHolder ); }
Source:
<code><START> public Builder(String host, int port) { <END> this.host = host; this.port = port; }</code><technical_language>A builder instantiation pattern Builder constructor private a static builder() method in outer class. usage pattern is like: java RestStreamClient.builder(host, port).create();</technical_language>

Target:
private Builder(String host, int port) { this.host = host; this.port = port; }
Source:
<code>public void setHardwareVersion(String value) { if (!ObjectUtils.objectsEqual(hardwareVersion, value)) { <START> hardwareVersion = StringUtils.isEmpty(value) ? constants.bracketedNotAvailableLabel() : value; <END> onPropertyChanged(new PropertyChangedEventArgs("hardwareVersion")); } }</code><technical_language>This is a side effect in model's setter method. Instead, this problem solved UI infra level. a "default value" API solve this problem, FormItem#resolveValueWidget I suggest solve this problem in way: * org.ovirt.engine.ui.common.widget.form.FormItem public static class EmptyTextCondition implements DefaultValueCondition { private final HasText hasText; public EmptyTextCondition(HasText hasText) { this.hasText = hasText; } @Override public boolean showDefaultValue() { return StringUtils.isEmpty(hasText.getText()); } } * org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabHostGeneralHardwareView // code // formBuilder.addFormItem(new FormItem(constants.hardwareVersionGeneral(), hardwareVersion, 1, 0)); // new code formBuilder.addFormItem(new FormItem(constants.hardwareVersionGeneral(), hardwareVersion, 1, 0) .withDefaultValue(constants.notAvailableLabel(), new EmptyTextCondition(hardwareVersion)) );</technical_language>

Target:
public void setHardwareVersion(String value) { if (!ObjectUtils.objectsEqual(hardwareVersion, value)) { hardwareVersion = value; onPropertyChanged(new PropertyChangedEventArgs("hardwareVersion")); } }
Source:
<code>public static void createZipFile(File zipFile, List<File> files, String rootPath, IProgressMonitor monitor) throws FileNotFoundException, IOException { if (rootPath == null) { rootPath = ""; } else if (!rootPath.endsWith("\\") || !rootPath.endsWith("/")) { rootPath += "/"; } <START> try (ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile))) { <END> for (File file : files) { try { addZipEntry(zipOut, rootPath, file); if (monitor != null) { monitor.worked(1); } } catch (Exception e) { StatusHandler.log(new Status(IStatus.ERROR, ICommonsCoreConstants.ID_PLUGIN, "Could not add " + file.getName() + " to zip", e)); } } } }</code><technical_language>wrap FileOutputStream in BufferedOutputStream</technical_language>

Target:
public static void createZipFile(File zipFile, List<File> files, String rootPath, IProgressMonitor monitor) throws FileNotFoundException, IOException { if (rootPath == null) { rootPath = ""; } else if (!rootPath.endsWith("\\") || !rootPath.endsWith("/")) { rootPath += "/"; } try (ZipOutputStream zipOut = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)))) { for (File file : files) { try { addZipEntry(zipOut, rootPath, file); if (monitor != null) { monitor.worked(1); } } catch (Exception e) { StatusHandler.log(new Status(IStatus.ERROR, ICommonsCoreConstants.ID_PLUGIN, "Could not add " + file.getName() + " to zip", e)); } } } }
Source:
<code>public void prepare() throws RestServiceException { if (!isOpen()) { nettyMetrics.multipartRequestAlreadyClosedError.inc(); throw new RestServiceException("Request is closed", RestServiceErrorCode.RequestChannelClosed); } else if (!readyForRead) { HttpDataFactory httpDataFactory = new DefaultHttpDataFactory(false); HttpPostMultipartRequestDecoder postRequestDecoder = new HttpPostMultipartRequestDecoder(httpDataFactory, request); try { HttpContent httpContent = rawRequestContents.peek(); while (httpContent != null) { postRequestDecoder.offer(httpContent); ReferenceCountUtil.release(rawRequestContents.poll()); httpContent = rawRequestContents.peek(); } for (InterfaceHttpData part : postRequestDecoder.getBodyHttpDatas()) { <START> processPart(part); <END> } allArgsReadOnly = Collections.unmodifiableMap(allArgs); requestContents.add(LastHttpContent.EMPTY_LAST_CONTENT); readyForRead = true; } catch (HttpPostRequestDecoder.ErrorDataDecoderException e) { nettyMetrics.multipartRequestDecodeError.inc(); throw new RestServiceException("There was an error decoding the request", e, RestServiceErrorCode.MalformedRequest); } finally { postRequestDecoder.destroy(); } } }</code><technical_language>for V1 this is fine. a suggestion though. processPart a separate thread decode part a separate thread avoid sequentiality</technical_language>

Target:
public void prepare() throws RestServiceException { if (!isOpen()) { nettyMetrics.multipartRequestAlreadyClosedError.inc(); throw new RestServiceException("Request is closed", RestServiceErrorCode.RequestChannelClosed); } else if (!readyForRead) { HttpDataFactory httpDataFactory = new DefaultHttpDataFactory(false); HttpPostMultipartRequestDecoder postRequestDecoder = new HttpPostMultipartRequestDecoder(httpDataFactory, request); try { HttpContent httpContent = rawRequestContents.poll(); while (httpContent != null) { try { if (httpContent != request) { postRequestDecoder.offer(httpContent); } } finally { ReferenceCountUtil.release(httpContent); } httpContent = rawRequestContents.poll(); } for (InterfaceHttpData part : postRequestDecoder.getBodyHttpDatas()) { processPart(part); } allArgsReadOnly = Collections.unmodifiableMap(allArgs); requestContents.add(LastHttpContent.EMPTY_LAST_CONTENT); readyForRead = true; } catch (HttpPostRequestDecoder.ErrorDataDecoderException e) { nettyMetrics.multipartRequestDecodeError.inc(); throw new RestServiceException("There was an error decoding the request", e, RestServiceErrorCode.MalformedRequest); } finally { postRequestDecoder.destroy(); } } }
Source:
<code>private void transferObjects(final Transferrer transferrer, final Objects objects) throws SignatureException, IOException, XmlProcessingException { final ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(this.maxParallelRequests)); try { <START> final Ds3Client client = this.clientFactory.GetClientForNodeId(objects.getNodeId()); <END> final List<ListenableFuture<?>> tasks = new ArrayList<>(); for (final BulkObject ds3Object : objects) { tasks.add(this.createTransferTask(transferrer, service, client, ds3Object)); } this.executeWithExceptionHandling(tasks); } finally { service.shutdown(); } }</code><technical_language>GetClientForNodeId this start a lowercase</technical_language>

Target:
private void transferObjects(final Transferrer transferrer, final Objects objects) throws SignatureException, IOException, XmlProcessingException { final ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(this.maxParallelRequests)); try { final Ds3Client client = this.clientFactory.getClientForNodeId(objects.getNodeId()); final List<ListenableFuture<?>> tasks = new ArrayList<>(); for (final BulkObject ds3Object : objects) { tasks.add(this.createTransferTask(transferrer, service, client, ds3Object)); } this.executeWithExceptionHandling(tasks); } finally { service.shutdown(); } }
Source:
<code>private void refreshDisplayPane() { JPanel pdfImagePanel = pdfDisplay.drawPreviewOnJPanel(); if(PDFDisplay.isDisableNextFlag()){ jButton2.setEnabled(false); } else{ jButton2.setEnabled(true); } if(PDFDisplay.isDisablePrevFlag()){ jButton1.setEnabled(false); } else{ jButton1.setEnabled(true); <START> } <END> if (pdfImagePanel != null) { JViewport vp = jScrollPane1.getViewport(); Point p = vp.getViewPosition(); vp.setView(pdfImagePanel); vp.setViewPosition(p); } jTextField1.setText(String.valueOf(pdfDisplay.getSelectedPage())); jLabel2.setText("of " + pdfDisplay.getTotalPages()); }</code><technical_language>set buttons enabled/disabled in places in this class places condition do so. This is good</technical_language>

Target:
private void refreshDisplayPane() { JPanel pdfImagePanel = pdfDisplay.drawPreviewOnJPanel(); if (pdfImagePanel != null) { JViewport vp = jScrollPane1.getViewport(); Point p = vp.getViewPosition(); vp.setView(pdfImagePanel); vp.setViewPosition(p); } jTextField1.setText(String.valueOf(pdfDisplay.getSelectedPage())); jLabel2.setText("of " + pdfDisplay.getTotalPages()); }
Source:
<code>private void validateConfiguration(RealmConfiguration newConfiguration) { if (configuration.equals(newConfiguration)) { return; } if (!Arrays.equals(configuration.getEncryptionKey(), newConfiguration.getEncryptionKey())) { throw new IllegalArgumentException(DIFFERENT_KEY_MESSAGE); } else { RealmMigration newMigration = newConfiguration.getMigration(); RealmMigration oldMigration = configuration.getMigration(); <START> if (oldMigration != null && newMigration != null && oldMigration.getClass().equals(newMigration.getClass())) { <END> throw new IllegalArgumentException("Configurations cannot be different if used to open the same file. " + "The most likely cause are that equals() and hashCode() are not overridden in the " + "migration class: " + newConfiguration.getMigration().getClass().getCanonicalName()); } throw new IllegalArgumentException("Configurations cannot be different if used to open the same file. " + "\nCached configuration: \n" + configuration + "\n\nNew configuration: \n" + newConfiguration); } }</code><technical_language>another condition !newMigration.equals(oldMigration)</technical_language>

Target:
private void validateConfiguration(RealmConfiguration newConfiguration) { if (configuration.equals(newConfiguration)) { return; } if (!Arrays.equals(configuration.getEncryptionKey(), newConfiguration.getEncryptionKey())) { throw new IllegalArgumentException(DIFFERENT_KEY_MESSAGE); } else { RealmMigration newMigration = newConfiguration.getMigration(); RealmMigration oldMigration = configuration.getMigration(); if (oldMigration != null && newMigration != null && oldMigration.getClass().equals(newMigration.getClass()) && !newMigration.equals(oldMigration)) { throw new IllegalArgumentException("Configurations cannot be different if used to open the same file. " + "The most likely cause is that equals() and hashCode() are not overridden in the " + "migration class: " + newConfiguration.getMigration().getClass().getCanonicalName()); } throw new IllegalArgumentException("Configurations cannot be different if used to open the same file. " + "\nCached configuration: \n" + configuration + "\n\nNew configuration: \n" + newConfiguration); } }
Source:
<code>public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { <START> IWorkspaceRunnable op = new IWorkspaceRunnable() { <END> @Override public void run(IProgressMonitor monitor) throws CoreException { IConfigurationElement[] projects = sample.getChildren("project"); SubMonitor subMonitor = SubMonitor.convert(monitor, PDEUIMessages.SampleOperation_creating, projects.length); createdProjects = new IProject[projects.length]; try { for (int i = 0; i < projects.length; i++) { IFile file = importProject(projectNames[i], projects[i], subMonitor.newChild(1)); if (file != null && sampleManifest == null) sampleManifest = file; if (file != null) { createdProjects[i] = file.getProject(); } if (cancel) break; } } catch (InterruptedException e) { throw new OperationCanceledException(); } catch (InvocationTargetException e) { throwCoreException(e); } } }; PDEPlugin.getWorkspace().run(op, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } catch (OperationCanceledException e) { throw e; } }</code><technical_language>Consider changing this ICoreRunnable</technical_language>

Target:
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { ICoreRunnable op = new ICoreRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { IConfigurationElement[] projects = sample.getChildren("project"); SubMonitor subMonitor = SubMonitor.convert(monitor, PDEUIMessages.SampleOperation_creating, projects.length); createdProjects = new IProject[projects.length]; try { for (int i = 0; i < projects.length; i++) { IFile file = importProject(projectNames[i], projects[i], subMonitor.newChild(1)); if (file != null && sampleManifest == null) sampleManifest = file; if (file != null) { createdProjects[i] = file.getProject(); } if (cancel) break; } } catch (InterruptedException e) { throw new OperationCanceledException(); } catch (InvocationTargetException e) { throwCoreException(e); } } }; PDEPlugin.getWorkspace().run(op, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } catch (OperationCanceledException e) { throw e; } }
Source:
<code>private Boolean hasMemberJoinedCluster(Entity member) { <START> return Optional.fromNullable(member.getAttribute(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER)).or(Boolean.FALSE); <END> }</code><technical_language>Java Boolean.TRUE.equals(member.getAttribute(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER));</technical_language>

Target:
private boolean hasMemberJoinedCluster(Entity member) { return ((RiakNode) member).hasJoinedCluster(); }
Source:
<code>public InputStream searchJSON(Context context, DiscoverQuery discoveryQuery, String jsonIdentifier) throws SearchServiceException { if(getSolr() == null) { return null; } SolrQuery solrQuery = resolveToSolrQuery(context, discoveryQuery, false); solrQuery.setParam("json.nl", "map"); solrQuery.setParam("json.wrf", jsonIdentifier); solrQuery.setParam(CommonParams.WT, "json"); StringBuilder urlBuilder = new StringBuilder(); urlBuilder.append(getSolr().getBaseURL()).append("/select"); NamedList<Object> solrParameters = solrQuery.toNamedList(); List<NameValuePair> postParameters = new ArrayList<>(); for (Map.Entry<String, Object> solrParameter : solrParameters) { if (solrParameter.getValue() instanceof String[]) { for(String val : (String[])solrParameter.getValue()) { postParameters.add(new BasicNameValuePair(solrParameter.getKey(), val)); } } <START> else if(solrParameter.getValue() instanceof String) {postParameters.add(new BasicNameValuePair(solrParameter.getKey(), solrParameter.getValue().toString())); <END> } else { } } try { HttpPost post = new HttpPost(urlBuilder.toString()); post.setEntity(new UrlEncodedFormEntity(postParameters)); HttpResponse response = new DefaultHttpClient().execute(post); return response.getEntity().getContent(); } catch (Exception e) { log.error("Error while getting json solr result for discovery search recommendation", e); } return null; }</code><technical_language>Weird code alignment here. postParameters.add() next line. While dspace-6_x complain, master (with new code style) will</technical_language>

Target:
public InputStream searchJSON(Context context, DiscoverQuery discoveryQuery, String jsonIdentifier) throws SearchServiceException { if(getSolr() == null) { return null; } SolrQuery solrQuery = resolveToSolrQuery(context, discoveryQuery, false); solrQuery.setParam("json.nl", "map"); solrQuery.setParam("json.wrf", jsonIdentifier); solrQuery.setParam(CommonParams.WT, "json"); StringBuilder urlBuilder = new StringBuilder(); urlBuilder.append(getSolr().getBaseURL()).append("/select"); NamedList<Object> solrParameters = solrQuery.toNamedList(); List<NameValuePair> postParameters = new ArrayList<>(); for (Map.Entry<String, Object> solrParameter : solrParameters) { if (solrParameter.getValue() instanceof String[]) { for(String val : (String[])solrParameter.getValue()) { postParameters.add(new BasicNameValuePair(solrParameter.getKey(), val)); } } else if(solrParameter.getValue() instanceof String) { postParameters.add(new BasicNameValuePair(solrParameter.getKey(), solrParameter.getValue().toString())); } else { log.warn("Search parameters contain non-string value: " + solrParameter.getValue().toString()); } } try { HttpPost post = new HttpPost(urlBuilder.toString()); post.setEntity(new UrlEncodedFormEntity(postParameters)); HttpResponse response = new DefaultHttpClient().execute(post); return response.getEntity().getContent(); } catch (Exception e) { log.error("Error while getting json solr result for discovery search recommendation", e); } return null; }
Source:
<code>public Boolean getDockerPrivilegedMode() { <START> return dockerPrivilegedMode != null ? dockerPrivilegedMode : false; <END> }</code><technical_language>return dockerPrivilegedMode directly</technical_language>

Target:
public Boolean getDockerPrivilegedMode() { return dockerPrivilegedMode; }
Source:
<code>public String fetchEvents(String tenantId, Map<String, List<String>> query) throws IOException { String url = String.format("%s/%s/%s/_search?routing=%s", baseUrl, EventElasticSearchIO.EVENT_INDEX, EventElasticSearchIO.ES_TYPE, tenantId); HttpPost httpPost = new HttpPost(url); httpPost.setHeaders(getHeaders()); String queryDslString = getDslString(query); CloseableHttpResponse response = null; try { HttpEntity httpEntity = new NStringEntity(queryDslString, ContentType.APPLICATION_JSON); httpPost.setEntity(httpEntity); response = closeableHttpClient.execute(httpPost); String str = EntityUtils.toString(response.getEntity()); EntityUtils.consume(response.getEntity()); return str; } catch(Exception e){ if((e instanceof HttpResponseException) && (response != null)) <START> logger.error("Status code: " + response.getStatusLine().getStatusCode() + " with msg: " + e.getMessage()); <END> throw new RuntimeException(e.getMessage(), e); } finally { response.close(); } }</code><technical_language>BF is slf4j a good convention placeholders string building, logger.error("Status code: msg: {}", response.getStatusLine().getStatusCode(), e.getMessage());</technical_language>

Target:
public String fetchEvents(String tenantId, Map<String, List<String>> query) throws IOException { String tempUrl = String.format("%s/%s/%s/_search?routing=%s&size=%d", getBaseUrl(), EventElasticSearchIO.EVENT_INDEX, EventElasticSearchIO.ES_TYPE, tenantId, MAX_RESULT_LIMIT); String queryDslString = getDslString(tenantId, query); HttpEntity httpEntity = new NStringEntity(queryDslString, ContentType.APPLICATION_JSON); Queue<String> callQ = new LinkedList<>(); callQ.add(tempUrl); int callCount = 0; while(!callQ.isEmpty() && callCount < MAX_CALL_COUNT) { callCount++; String url = callQ.remove(); logger.info("Using url [{}]", url); HttpPost httpPost = new HttpPost(url); httpPost.setHeaders(getHeaders()); CloseableHttpResponse response = null; try { httpPost.setEntity(httpEntity); response = closeableHttpClient.execute(httpPost); String str = EntityUtils.toString(response.getEntity()); EntityUtils.consume(response.getEntity()); return str; } catch (Exception e) { if(response == null){ logger.error("fetchEvents failed with message: {}", e.getMessage()); url = String.format("%s/%s/%s/_search?routing=%s&size=%d", getBaseUrl(), EventElasticSearchIO.EVENT_INDEX, EventElasticSearchIO.ES_TYPE, tenantId, MAX_RESULT_LIMIT); callQ.add(url); } else { logger.error("fetchEvents failed with status code: and exception message: {}", response.getStatusLine().getStatusCode(), e.getMessage()); } } finally { if(response != null) { response.close(); } } } return ""; }
Source:
<code>public void init(){ OriginalImage = new Image("/DataExamples/Mona_Lisa.png"); final int w = (int) OriginalImage.getWidth(); final int h = (int) OriginalImage.getHeight(); composition = new WritableImage(w, h); ds = generateDataSet(OriginalImage); nn = CreateNN(); <START> <END> int numPoints = h * w; xyOut = Nd4j.zeros(numPoints, 2); for (int i = 0; i < w; i++) { double xp = (double) i / (double) (w - 1); for (int j = 0; j < h; j++) { int index = i + w * j; double yp = (double) j / (double) (h - 1); xyOut.put(index, 0, xp); xyOut.put(index, 1, yp); } } DrawImage(); }</code><technical_language>camel case</technical_language>

Target:
public void init(){ originalImage = new Image("/DataExamples/Mona_Lisa.png"); final int w = (int) originalImage.getWidth(); final int h = (int) originalImage.getHeight(); composition = new WritableImage(w, h); ds = generateDataSet(originalImage); nn = createNN(); int numPoints = h * w; xyOut = Nd4j.zeros(numPoints, 2); for (int i = 0; i < w; i++) { double xp = (double) i / (double) (w - 1); for (int j = 0; j < h; j++) { int index = i + w * j; double yp = (double) j / (double) (h - 1); xyOut.put(index, 0, xp); xyOut.put(index, 1, yp); } } drawImage(); }
Source:
<code>private boolean addGitHubCommitter(Channel channel, User sender, String collaborator, String justForThisRepo) { boolean result = false; if (!isSenderAuthorized(channel,sender)) { insufficientPermissionError(channel); return false; } OutputChannel out = channel.send(); try { if (justForThisRepo == null) { out.message("I'm not longer managing the Everyone team. Please add committers to specific repos."); return false; } GitHub github = GitHub.connect(); GHUser c = github.getUser(collaborator); GHOrganization o = github.getOrganization(IrcBotConfig.GITHUB_ORGANIZATION); final GHTeam t; GHRepository forThisRepo = o.getRepository(justForThisRepo); if (forThisRepo == null) { out.message("Could not find repository: "+justForThisRepo); return false; } <START> t = getOrCreateRepoLocalTeam(o, forThisRepo, null); <END> if (t==null) { out.message("No team for "+justForThisRepo); return false; } t.add(c); String successMsg = "Added "+collaborator+" as a GitHub committer for repository " + justForThisRepo; out.message(successMsg); result = true; } catch (IOException e) { out.message("Failed to add user to team: "+e.getMessage()); e.printStackTrace(); } return result; }</code><technical_language>passing null issue in getOrCreateRepoLocalTeam githubUsers.isEmpty() is called</technical_language>

Target:
private boolean addGitHubCommitter(Channel channel, User sender, String collaborator, String justForThisRepo) { boolean result = false; if (!isSenderAuthorized(channel,sender)) { insufficientPermissionError(channel); return false; } OutputChannel out = channel.send(); try { if (justForThisRepo == null) { out.message("I'm not longer managing the Everyone team. Please add committers to specific repos."); return false; } GitHub github = GitHub.connect(); GHUser c = github.getUser(collaborator); GHOrganization o = github.getOrganization(IrcBotConfig.GITHUB_ORGANIZATION); final GHTeam t; GHRepository forThisRepo = o.getRepository(justForThisRepo); if (forThisRepo == null) { out.message("Could not find repository: "+justForThisRepo); return false; } t = getOrCreateRepoLocalTeam(o, forThisRepo, emptyList()); t.add(c); out.message("Added " + collaborator + " as a GitHub committer for repository " + justForThisRepo); result = true; } catch (IOException e) { out.message("Failed to add user to team: "+e.getMessage()); e.printStackTrace(); } return result; }
Source:
<code>public void generateReport_DisplaysContentAsEscapedText() { setUpWithJson(HTML_JSON); page = new FeatureReportPage(reportResult, configuration, features.get(0)); page.generatePage(); DocumentAssertion document = documentFrom(page.getWebPage()); assertThat(document.getFeature().getDescription()) .isEqualTo("<b>a bold statement</b>"); assertThat(document.getFeature().getElements()[0].getDescription()) <START> .isEqualTo("<b>a bold statement</b>"); <END> assertThat(document.getFeature().getElements()[0].getStepsSection().getSteps()[0].getDocString().text()) .isEqualTo("Doc string <b>a bold\nstatement</b>"); assertThat(document.getFeature().getElements()[0].getStepsSection().getSteps()[1].getArgumentsTable().getBodyRow().getCellsValues()[0]) .isEqualTo("<b>bold</b>"); }</code><technical_language>name of method data escaped while tests validates not-escaped content - more it</technical_language>

Target:
public void generateReport_DisplaysContentAsEscapedText() { page = new FeatureReportPage(reportResult, configuration, features.get(1)); page.generatePage(); DocumentAssertion document = documentFrom(page.getWebPage()); assertThat(document.getFeature().getDescription()) .isEqualTo("As an Account Holder I want to withdraw cash from an ATM,<br>so that I can get money when the bank is closed"); assertThat(document.getFeature().getElements()[0].getStepsSection().getSteps()[5].getEmbedding()[3].text()) .isEqualTo("Attachment 4 (HTML) <i>Hello</i> <b>World!</b>"); assertThat(document.getFeature().getElements()[0].getStepsSection().getSteps()[5].getMessage().text()) .isEqualTo("Error message java.lang.AssertionError: \n" + "Expected: is <80>\n" + " got: <90>\n" + "\n" + "\tat org.junit.Assert.assertThat(Assert.java:780)\n" + "\tat org.junit.Assert.assertThat(Assert.java:738)\n" + "\tat net.masterthought.example.ATMScenario.checkBalance(ATMScenario.java:69)\n" + "\tat ✽.And the account balance should be 90(net/masterthought/example/ATMK.feature:12)"); }
Source:
<code>public void testEnableSampling() { SamplerConfiguration samplerConfig = new SamplerConfiguration("test"); NewTableConfiguration ntcSample1 = new NewTableConfiguration().enableSampling(samplerConfig); assertTrue(ntcSample1.getProperties().containsValue("test")); <START> RowSampler rowSampler = new RowSampler(); <END> SamplerConfiguration sha1SamplerConfig = new SamplerConfiguration(rowSampler.getClass()); sha1SamplerConfig.setOptions(options); rowSampler.init(sha1SamplerConfig); NewTableConfiguration ntcSample2 = new NewTableConfiguration().enableSampling(sha1SamplerConfig); assertTrue(ntcSample2.getProperties().containsValue("murmur3_32")); }</code><technical_language>I row sampler removed checks stronger following. java SamplerConfiguration sha1SamplerConfig = new SamplerConfiguration("com.mysampler"); sha1SamplerConfig.setOptions(options); NewTableConfiguration ntcSample2 = new NewTableConfiguration().enableSampling(sha1SamplerConfig); assertEquals("com.mysampler", ntcSample2.getProperties().get("table.sampler")); assertEquals("5", ntcSample2.getProperties().get("table.sampler.opt.modulus")); assertEquals("murmur3_32", ntcSample2.getProperties().get("table.sampler.opt.hasher"));</technical_language>

Target:
public void testEnableSampling() { SamplerConfiguration sha1SamplerConfig = new SamplerConfiguration("com.mysampler"); sha1SamplerConfig.setOptions(options); NewTableConfiguration ntcSample2 = new NewTableConfiguration().enableSampling(sha1SamplerConfig); assertEquals("com.mysampler", ntcSample2.getProperties().get("table.sampler")); assertEquals("5", ntcSample2.getProperties().get("table.sampler.opt.modulus")); assertEquals("murmur3_32", ntcSample2.getProperties().get("table.sampler.opt.hasher")); }
Source:
<code>public static void viewBlogSharing(Context context, SiteModel site) { Intent intent = new Intent(context, PublicizeListActivity.class); intent.putExtra(WordPress.SITE, site); context.startActivity(intent); <START> <END> }</code><technical_language>Travis is failing due this empty line. Removing fix checkstyle.xml exception</technical_language>

Target:
public static void viewBlogSharing(Context context, SiteModel site) { Intent intent = new Intent(context, PublicizeListActivity.class); intent.putExtra(WordPress.SITE, site); context.startActivity(intent); AnalyticsUtils.trackWithSiteDetails(Stat.OPENED_SHARING_MANAGEMENT, site); }
Source:
<code>protected final void activateStripe(Collection<InetSocketAddress> newNodes, Cluster cluster, InetSocketAddress destination, Measure<TimeUnit> restartDelay, Measure<TimeUnit> restartWaitTime) { activateNomadSystem(newNodes, cluster, getLicenseContentFrom(destination).orElse(null)); runClusterActivation(newNodes, cluster); <START> logger.debug("Configuration directories have been created for all nodes"); <END> syncNomadChangesTo(newNodes, getAllNomadChangesFrom(destination)); restartNodes(newNodes, restartDelay, restartWaitTime); }</code><technical_language>this log line is duplicated: move runClusterActivation</technical_language>

Target:
protected final void activateStripe(Collection<InetSocketAddress> newNodes, Cluster cluster, InetSocketAddress destination, Measure<TimeUnit> restartDelay, Measure<TimeUnit> restartWaitTime) { activateNomadSystem(newNodes, cluster, getLicenseContentFrom(destination).orElse(null)); runClusterActivation(newNodes, cluster); syncNomadChangesTo(newNodes, getAllNomadChangesFrom(destination)); restartNodes(newNodes, restartDelay, restartWaitTime); }
Source:
<code>public static ByteBuffer serializeJsonToByteBuffer(ObjectMapper objectMapper, Object object) { try { ByteBufferOutputStream byteBufferOutputStream = new ByteBufferOutputStream(); <START> objectMapper.writeValue(byteBufferOutputStream, object); <END> return byteBufferOutputStream.asByteBuffer(); } catch (IOException e) { throw new IllegalArgumentException("Failed to serialize json", e); } }</code><technical_language>result in re-allocations (dynamic size)</technical_language>

Target:
public static ByteBuffer serializeJsonToByteBuffer(ObjectMapper objectMapper, Object object) { try { ByteBufferOutputStream byteBufferOutputStream = new ByteBufferOutputStream(ONE_KB); objectMapper.writeValue(byteBufferOutputStream, object); return byteBufferOutputStream.asByteBuffer(); } catch (IOException e) { throw new IllegalArgumentException("Failed to serialize the object into json", e); } }
Source:
<code>public void initialize() { logger.debug("Initializing the LIRC Bridge handler"); <START> updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE); <END> configuration = getConfigAs(LIRCBridgeConfiguration.class); if (connectorTask == null || connectorTask.isCancelled()) { connectorTask = scheduler.scheduleAtFixedRate(new Runnable() { @Override public void run() { logger.debug("Checking LIRC connection, thing status = {}", thing.getStatus()); if (thing.getStatus() != ThingStatus.ONLINE) { connect(); } } }, 0, 60, TimeUnit.SECONDS); } }</code><technical_language>OFFLINE-BRIDGE_OFFLINE sense here. This bridge a bridge itself! leave status set framework (i.e. INITIALIZING) connector task able figure out correct state</technical_language>

Target:
public void initialize() { logger.debug("Initializing the LIRC Bridge handler"); configuration = getConfigAs(LIRCBridgeConfiguration.class); if (connectorTask == null || connectorTask.isCancelled()) { connectorTask = scheduler.scheduleAtFixedRate(new Runnable() { @Override public void run() { logger.debug("Checking LIRC connection, thing status = {}", thing.getStatus()); if (thing.getStatus() != ThingStatus.ONLINE) { connect(); } } }, 0, 60, TimeUnit.SECONDS); } }
Source:
<code><START> public String getAttributeValue(@Nullable String name) { <END> return name; }</code><technical_language>public @Nullable String..</technical_language>

Target:
public @Nullable String getAttributeValue(@Nullable String name) { return name; }
Source:
<code>public ApplicationRecord[] appRecordArray() { <START> SqlStorage<ApplicationRecord> appList = CommCareApplication._().getInstalledAppRecords(); <END> ApplicationRecord[] appArray = new ApplicationRecord[appList.getNumRecords()]; int index = 0; for (ApplicationRecord r : appList) { appArray[index++] = r; } return appArray; }</code><technical_language>rest of this function appList.toArray(new ApplicationRecord[0])</technical_language>

Target:
public ApplicationRecord[] appRecordArray() { ArrayList<ApplicationRecord> appList = CommCareApplication._().getInstalledAppRecords(); ApplicationRecord[] appArray = new ApplicationRecord[appList.size()]; int index = 0; for (ApplicationRecord r : appList) { appArray[index++] = r; } return appArray; }