auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected GlusterVolumeTaskStatusEntity fetchTaskStatusDetails() { VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeRemoveBricksStatus, new GlusterVolumeRemoveBricksVDSParameters(getUpServerId(clusterId), volume.getName(), getParameters().getBricks(), volume.getReplicaCount())); <START> GlusterVolumeTaskStatusEntity entity = setStartTime((GlusterVolumeTaskStatusEntity) returnValue.getReturnValue()); <END> updateHostIP(entity); return entity.sort(); }</code><technical_language>Is difference in setting StartTime for rebalance remove-brick</technical_language>

Target:
protected GlusterVolumeTaskStatusEntity fetchTaskStatusDetails() { VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeRemoveBricksStatus, new GlusterVolumeRemoveBricksVDSParameters(getUpServerId(clusterId), volume.getName(), getParameters().getBricks(), volume.getReplicaCount())); GlusterVolumeTaskStatusEntity entity = setStartTime((GlusterVolumeTaskStatusEntity) returnValue.getReturnValue()); return updateHostDetails(entity); }
Source:
<code>public void testGetList() { server.enqueue( new MockResponse().setBody(stringFromResource("/datacenter/list.json")) ); List<DataCenter> list = dataCenterApi().list(new DepthOptions().depth(1)); assertNotNull(list); assertEquals(list.size(), 3); <START> assertEquals(list.get(0).properties().name(), "vea"); <END> }</code><technical_language>need verify recorded request. MockWebServer return enqueued request _any_ request. need verify generated request is expected one: expected request uri, method, headers body. applied in methods in this class</technical_language>

Target:
public void testGetList() throws InterruptedException { server.enqueue( new MockResponse().setBody(stringFromResource("/datacenter/list.json")) ); List<DataCenter> list = dataCenterApi().list(); assertNotNull(list); assertEquals(list.size(), 3); assertEquals(list.get(0).properties().name(), "vea"); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/datacenters"); }
Source:
<code>public CachedTransition(final Node node, final Timeline timeline) { this.node = node; this.timeline.set(timeline); mementos = node == null ? mementos : new CacheMemento[]{new CacheMemento(node)}; statusProperty().addListener(observable -> { <START> switch (getStatus()) { case RUNNING: starting(); break; default: stopping(); break; } }); } <END></code><technical_language>If case is covered prefer if/else</technical_language>

Target:
public CachedTransition(final Node node, final Timeline timeline) { this.node = node; this.timeline.set(timeline); mementos = node == null ? new CacheMemento[0] : new CacheMemento[]{new CacheMemento(node)}; statusProperty().addListener(observable -> { if (getStatus() == Status.RUNNING) { starting(); } else { stopping(); } }); }
Source:
<code>public Response getClusterServers() <START> { <END> ImmutableMap.Builder<String, Object> entityBuilder = new ImmutableMap.Builder<>(); entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_COORDINATOR, druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_COORDINATOR) .getAllNodes() ); entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_OVERLORD, druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_OVERLORD) .getAllNodes() ); entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_BROKER, druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_BROKER) .getAllNodes() ); entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_HISTORICAL, druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_HISTORICAL) .getAllNodes() ); Set<DiscoveryDruidNode> mmNodes = druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_MM) .getAllNodes(); if (!mmNodes.isEmpty()) { entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_MM, mmNodes); } Set<DiscoveryDruidNode> routerNodes = druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_ROUTER) .getAllNodes(); if (!routerNodes.isEmpty()) { entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_ROUTER, routerNodes); } return Response.status(Response.Status.OK).entity(entityBuilder.build()).build(); }</code><technical_language>nice endpoints return type of service stuff do. While necessary, a simple addition benefits operator (I think). Or, a parameter filter types care about, similar</technical_language>

Target:
public Response getClusterServers() { ImmutableMap.Builder<String, Object> entityBuilder = new ImmutableMap.Builder<>(); entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_COORDINATOR, druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_COORDINATOR) .getAllNodes() ); entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_OVERLORD, druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_OVERLORD) .getAllNodes() ); entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_BROKER, druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_BROKER) .getAllNodes() ); entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_HISTORICAL, druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_HISTORICAL) .getAllNodes() ); Collection<DiscoveryDruidNode> mmNodes = druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_MM) .getAllNodes(); if (!mmNodes.isEmpty()) { entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_MM, mmNodes); } Collection<DiscoveryDruidNode> routerNodes = druidNodeDiscoveryProvider.getForNodeType(DruidNodeDiscoveryProvider.NODE_TYPE_ROUTER) .getAllNodes(); if (!routerNodes.isEmpty()) { entityBuilder.put(DruidNodeDiscoveryProvider.NODE_TYPE_ROUTER, routerNodes); } return Response.status(Response.Status.OK).entity(entityBuilder.build()).build(); }
Source:
<code>protected String parseResourceName(String line) { if (line == null) { return null; } if (compilerPatterns.isEmpty()) { for (int i = 0; i < COMPILER_COMMAND_PATTERN_TEMPLATES.length; i++) { String patternTemplate = COMPILER_COMMAND_PATTERN_TEMPLATES[i]; String patternString = makePattern(patternTemplate); compilerPatterns.put(patternString, Pattern.compile(patternString)); } } <START> Pattern pattern = compilerPatterns.get(line); <END> Matcher fileMatcher = pattern != null ? pattern.matcher(line) : null; if (fileMatcher != null && fileMatcher.matches()) { int fileGroup = adjustFileGroup(); String sourceFileName = fileMatcher.group(fileGroup); return sourceFileName; } return null; }</code><technical_language>Doug advice was? <LINK_0> Instead of storing patterns in array I a hashmap check patterns time retrieved wanted pattern if exists is lower</technical_language>

Target:
protected String parseResourceName(String line) { if (line == null) { return null; } if (compilerPatterns == null) { compilerPatterns = new Pattern[COMPILER_COMMAND_PATTERN_TEMPLATES.length]; for (int i = 0; i < COMPILER_COMMAND_PATTERN_TEMPLATES.length; i++) { String patternTemplate = COMPILER_COMMAND_PATTERN_TEMPLATES[i]; String patternString = makePattern(patternTemplate); compilerPatterns[i] = Pattern.compile(patternString); } } for (Pattern pattern : compilerPatterns) { Matcher fileMatcher = pattern.matcher(line); if (fileMatcher.matches()) { int fileGroup = adjustFileGroup(); String sourceFileName = fileMatcher.group(fileGroup); return sourceFileName; } } return null; }
Source:
<code><START> public boolean mkdirs(Path path) throws IOException { <END> return getVolumeByPath(path).getFileSystem().mkdirs(path); }</code><technical_language>Do expense of methods? RPCs namenode</technical_language>

Target:
public boolean mkdirs(Path path) throws IOException { return getFileSystemByPath(path).mkdirs(path); }
Source:
<code>public void create(@PathVariable("entityTypeId") String entityTypeId, @RequestBody Map<String, Object> entityMap, HttpServletResponse response) { if (entityMap == null) { <START> throw new MissingValueException("entity", "body"); <END> } createInternal(entityTypeId, entityMap, response); }</code><technical_language>happen. @RequestBody is required default. Remove check</technical_language>

Target:
public void create(@PathVariable("entityTypeId") String entityTypeId, @RequestBody Map<String, Object> entityMap, HttpServletResponse response) { createInternal(entityTypeId, entityMap, response); }
Source:
<code><START> private DocumentModel addTags(CoreSession session, DocumentModel targetDoc, String tagString) { <END> String[] tagList = tagString.split("\\|"); List<Map<String, Serializable>> tags = new ArrayList<>(); for (String tag : tagList) { Map<String, Serializable> tagMap = new HashMap<>(); tagMap.put("label", tag); tagMap.put("username", session.getPrincipal().getName()); tags.add(tagMap); } targetDoc.setPropertyValue("nxtag:tags", (Serializable) tags); return targetDoc; }</code><technical_language>do protected</technical_language>

Target:
protected DocumentModel addTags(CoreSession session, DocumentModel targetDoc, String tagString) { String[] tagList = tagString.split("\\|"); String userName = session.getPrincipal().getName(); var tags = Arrays.stream(tagList) .map(s -> Map.of("label", s, "username", userName)) .collect(Collectors.toList()); targetDoc.setPropertyValue("nxtag:tags", (Serializable) tags); return targetDoc; }
Source:
<code>public ModelAndView uploadFile(@PathVariable("candidateId") Long candidateId, @RequestParam(value = "file") final MultipartFile multipartFile, RedirectAttributes redirectAttributes) throws IOException { ModelAndView modelAndView = new ModelAndView(REDIRECT_URL_CANDIDATE_PAGE + "/" + candidateId); String fileName = multipartFile.getOriginalFilename(); try { CandidateDTO candidateDTO = candidateService.getCandidate(candidateId); String candidateCVFilename = candidateDTO.getCvFilename(); <START> if (candidateCVFilename != null && !candidateCVFilename.isEmpty()) { <END> throw new CandidateAlreadyHasCVFileException(); } fileValidator.validate(multipartFile); File file = createFile(candidateDTO, fileName); FileCopyUtils.copy(multipartFile.getBytes(), file); redirectAttributes.addFlashAttribute(FILE, fileName); redirectAttributes.addFlashAttribute(VALIDATION_SUCCESS_KEY, VALIDATION_FILE_SUCCESS_MESSAGE_KEY); candidateDTO.setCvFilename(fileName); candidateService.saveOrUpdate(candidateDTO); } catch (CandidateAlreadyHasCVFileException e) { log.error(FileUploadController.class.getName(), e); redirectAttributes.addFlashAttribute(VALIDATION_ERROR_KEY, CANDIDATE_ALREADY_HAS_CV_FILE_MESSAGE_KEY); } catch (FileValidationException e) { log.error(FileUploadController.class.getName(), e); redirectAttributes.addFlashAttribute(VALIDATION_ERROR_KEY, fileValidationRuleMapper.getMessageKeyByException(e)); } return modelAndView; }</code><technical_language>I suggest this method: org.apache.commons.lang3.StringUtils.isNotEmpty</technical_language>

Target:
public ModelAndView uploadFile(@PathVariable("candidateId") Long candidateId, @RequestParam(value = "file") final MultipartFile multipartFile, RedirectAttributes redirectAttributes) throws IOException { ModelAndView modelAndView = new ModelAndView(REDIRECT_URL_CANDIDATE_PAGE + "/" + candidateId); String fileName = multipartFile.getOriginalFilename(); try { CandidateDTO candidateDTO = candidateService.getCandidate(candidateId); String candidateCVFilename = candidateDTO.getCvFilename(); if (StringUtils.isNotBlank(candidateCVFilename)) { throw new CandidateAlreadyHasCVFileException(); } fileValidator.validate(multipartFile); File file = createFile(candidateId, fileName); FileCopyUtils.copy(multipartFile.getBytes(), file); redirectAttributes.addFlashAttribute(FILE, fileName); redirectAttributes.addFlashAttribute(VALIDATION_SUCCESS_KEY, VALIDATION_FILE_SUCCESS_MESSAGE_KEY); candidateDTO.setCvFilename(fileName); candidateService.saveOrUpdate(candidateDTO); } catch (CandidateAlreadyHasCVFileException e) { log.error(FileUploadController.class.getName(), e); redirectAttributes.addFlashAttribute(VALIDATION_ERROR_KEY, CANDIDATE_ALREADY_HAS_CV_FILE_MESSAGE_KEY); } catch (FileValidationException e) { log.error(FileUploadController.class.getName(), e); redirectAttributes.addFlashAttribute(VALIDATION_ERROR_KEY, fileValidationRuleMapper.getMessageKeyByException(e)); } return modelAndView; }
Source:
<code>@Test public void concurrentSingletonAccess() throws Exception { final List<Future<Long>> futures = new ArrayList<Future<Long>>(); final ObjectGraph graph = ObjectGraph.create(new LatchingModule(latch)); <START> for (int i = 0 ; i < PERCALE ; i++) { <END> futures.add(es.submit(new Callable<Long>() { @Override public Long call() { latch.countDown(); return graph.get(Long.class); } })); } latch.countDown(); for (Future<Long> future : futures) { assertThat(future.get(1, TimeUnit.SECONDS)) .overridingErrorMessage("Lock failure - count should never increment") .isEqualTo(0); } }</code><technical_language>extra spaces ;</technical_language>

Target:
@Test public void concurrentSingletonAccess() throws Exception { final List<Future<Long>> futures = new ArrayList<Future<Long>>(); final ObjectGraph graph = ObjectGraph.create(new LatchingModule(latch)); for (int i = 0; i < THREAD_COUNT; i++) { futures.add(es.submit(new Callable<Long>() { @Override public Long call() { latch.countDown(); return graph.get(Long.class); } })); } latch.countDown(); for (Future<Long> future : futures) { assertThat(future.get(1, TimeUnit.SECONDS)) .overridingErrorMessage("Lock failure - count should never increment") .isEqualTo(0); } }
Source:
<code>public void run(boolean resetDB, int replicationFactor, boolean updateVersion) { <START> URI script = getScript(); <END> Map<String, ?> vars = this.getVars(resetDB, replicationFactor, true); buildCassalogIfNeeded(); cassalog.execute(script, this.getTags(), vars); if (updateVersion) { updateVersion(0, 0); } }</code><technical_language>SchemaService evolved a bit originally written. If want feel free refactor this inject resetDB, replicationFactor, updateVersion in constructor and/or setter methods. call buildCassalogIfNeeded in multiple places</technical_language>

Target:
public void run(boolean resetDB, int replicationFactor, boolean updateVersion) { URI script = getScript(); Map<String, ?> vars = this.getVars(resetDB, replicationFactor); cassalog.execute(script, this.getTags(), vars); if (updateVersion) { updateVersion(0, 0); } }
Source:
<code>Mono<Response<RecognizeLinkedEntitiesResult>> recognizeLinkedEntitiesWithResponse(String text, String language, Context context) { Objects.requireNonNull(text, "'text' cannot be null."); return recognizeBatchLinkedEntitiesWithResponse( Collections.singletonList(new TextDocumentInput("0", text, language)), null, context) .map(response -> { Iterator<RecognizeLinkedEntitiesResult> linkedEntitiesResultIterator = response.getValue().iterator(); RecognizeLinkedEntitiesResult linkedEntitiesResult = null; if (response.getStatusCode() == 200 && linkedEntitiesResultIterator.hasNext()) { linkedEntitiesResult = linkedEntitiesResultIterator.next(); if (linkedEntitiesResult.isError()) { <START> toTextAnalyticsException(linkedEntitiesResult.getError(), logger); <END> } } return new SimpleResponse<>(response, linkedEntitiesResult); }); }</code><technical_language>This method throws exception, however, clear this code method ends here. I assuming continue return SimpleResponse toTextAnalyticsException() method. Instead, return exception toTextAnalyticsException() change this throw toTextAnalyticsException()</technical_language>

Target:
Mono<Response<RecognizeLinkedEntitiesResult>> recognizeLinkedEntitiesWithResponse(String text, String language, Context context) { Objects.requireNonNull(text, "'text' cannot be null."); return recognizeBatchLinkedEntitiesWithResponse( Collections.singletonList(new TextDocumentInput("0", text, language)), null, context) .map(Transforms::processSingleResponseErrorResult); }
Source:
<code>public int getClusterCount(String clusterName, String scheme, int partitionId) throws ServiceUnavailableException { FutureCallback<Integer> clusterCountFutureCallback = new FutureCallback<>(); <START> Runnable callback = () -> <END> { Set<URI> uris = _state.getUriProperties(clusterName).getProperty().getUriBySchemeAndPartition(scheme, partitionId); clusterCountFutureCallback.onSuccess((uris != null) ? uris.size() : 0); }; _state.listenToCluster(clusterName, (type, name) -> callback.run()); try { return clusterCountFutureCallback.get(_timeout, _unit); } catch (ExecutionException | TimeoutException | InterruptedException e) { die("ClusterInfo", "PEGA_1017, unable to retrieve cluster count for cluster: " + clusterName + ", scheme: " + scheme + ", partition: " + partitionId + ", exception: " + e.getMessage()); return -1; } }</code><technical_language>inline this</technical_language>

Target:
public int getClusterCount(String clusterName, String scheme, int partitionId) throws ServiceUnavailableException { FutureCallback<Integer> clusterCountFutureCallback = new FutureCallback<>(); _state.listenToCluster(clusterName, (type, name) -> { if (_state.getUriProperties(clusterName).getProperty() != null) { Set<URI> uris = _state.getUriProperties(clusterName).getProperty().getUriBySchemeAndPartition(scheme, partitionId); clusterCountFutureCallback.onSuccess((uris != null) ? uris.size() : 0); } else { clusterCountFutureCallback.onSuccess(0); } }); try { return clusterCountFutureCallback.get(_timeout, _unit); } catch (ExecutionException | TimeoutException | IllegalStateException | InterruptedException e ) { die("ClusterInfo", "PEGA_1017, unable to retrieve cluster count for cluster: " + clusterName + ", scheme: " + scheme + ", partition: " + partitionId + ", exception: " + e); return -1; } }
Source:
<code>public void onLocationChanged(Location location) { if (!inViewMode && !isManualSelectedLocation) { <START> this.location = location; <END> if (this.location != null && location.getAccuracy() < lastLocationAccuracy) { lastLocationAccuracy = location.getAccuracy(); drawMarker(); } } }</code><technical_language>I this change if accuracy better, updating location in background changing reflection of</technical_language>

Target:
public void onLocationChanged(Location location) { if (!inViewMode && !isManualSelectedLocation) { if (location != null && (this.location == null || (location.getAccuracy() < this.location.getAccuracy()))) { this.location = location; drawMarker(); } } }
Source:
<code>public ResourceManager getResourceManager() { <START> synchronized (this) { <END> if (resourceManager == null) { Display display = Display.getCurrent(); if (display == null && PlatformUI.isWorkbenchRunning()) { display = PlatformUI.getWorkbench().getDisplay(); } if (display == null) { throw new SWTError(SWT.ERROR_THREAD_INVALID_ACCESS); } resourceManager = new LocalResourceManager( JFaceResources.getResources(display)); } } return resourceManager; }</code><technical_language>Please simply this method synchronized</technical_language>

Target:
public synchronized ResourceManager getResourceManager() { if (resourceManager == null) { Display display = PlatformUI.getWorkbench().getDisplay(); if (display == null) { throw new IllegalStateException(); } resourceManager = new LocalResourceManager(JFaceResources .getResources(display)); } return resourceManager; }
Source:
<code>private void deleteBlob(final String blobId, FutureResult<Void> futureResult, final Callback<Void> callback) { deleteManager.submitDeleteBlobOperation(blobId, futureResult, new Callback<Void>() { @Override public void onCompletion(Void result, Exception exception) { if (exception == null) { backgroundDeleter.initiateChunkDeletesIfAny(blobId); } <START> callback.onCompletion(result, exception); <END> } }); readyForPollCallback.onPollReady(); }</code><technical_language>callback null</technical_language>

Target:
private void deleteBlob(final String blobId, FutureResult<Void> futureResult, final Callback<Void> callback) { deleteManager.submitDeleteBlobOperation(blobId, futureResult, new Callback<Void>() { @Override public void onCompletion(Void result, Exception exception) { if (exception == null) { backgroundDeleter.initiateChunkDeletesIfAny(blobId); } if (callback != null) { callback.onCompletion(result, exception); } } }); readyForPollCallback.onPollReady(); }
Source:
<code>public SonarLintHotspotsListPanel(Project project) { this.project = project; treeModel = new DefaultTreeModel(null); hotspotsTree = new Tree(treeModel); hotspotsTree.setCellRenderer(new HotspotCellRenderer()); <START> hotspotsTree.getEmptyText().setText("No hotspot to display, open one from SonarQube"); <END> EditSourceOnDoubleClickHandler.install(hotspotsTree, this::navigateToLocation); EditSourceOnEnterKeyHandler.install(hotspotsTree, this::navigateToLocation); }</code><technical_language>Typo suggestion hotspotsTree.getEmptyText().setText("No hotspots display, open SonarQube");</technical_language>

Target:
public SonarLintHotspotsListPanel(Project project) { this.project = project; treeModel = new DefaultTreeModel(null); hotspotsTree = new Tree(treeModel); hotspotsTree.setCellRenderer(new HotspotCellRenderer()); hotspotsTree.getEmptyText().setText("No hotspots to display, open one from SonarQube"); EditSourceOnDoubleClickHandler.install(hotspotsTree, this::navigateToLocation); EditSourceOnEnterKeyHandler.install(hotspotsTree, this::navigateToLocation); }
Source:
<code>static void detectLanguagesCountryHintRunner(BiConsumer<List<String>, String> testRunner) { <START> final List<String> inputs = new ArrayList<>(Arrays.asList( <END> "This is written in English", "Este es un document escrito en Español.", "~@!~:)")); testRunner.accept(inputs, "US"); }</code><technical_language>is this wrapped in ArrayList? in below</technical_language>

Target:
static void detectLanguagesCountryHintRunner(BiConsumer<List<String>, String> testRunner) { final List<String> inputs = Arrays.asList( "This is written in English", "Este es un document escrito en Español.", "~@!~:)"); testRunner.accept(inputs, "en"); }
Source:
<code>public void connectionObserverTests() { final String url = "tcp://123.123.123.123"; final String name = "TestName12@!"; MqttBrokerConnection a; try { a = new MqttBrokerConnection(name, url, false); } catch (ConfigurationException e) { fail(); return; } assertFalse(a.isConnectionObservers()); isConnected = true; MqttConnectionObserver connectionObserver = new MqttConnectionObserver() { @Override public void setConnected(boolean connected) { isConnected = connected; } }; a.addConnectionObserver(connectionObserver); <START> assertFalse(isConnected); <END> assertTrue(a.isConnectionObservers()); a.removeConnectionObserver(connectionObserver); assertFalse(a.isConnectionObservers()); }</code><technical_language>alternative path a mock: MqttConnectionObserver connectionObserver = mock(MqttConnectionObserver.class); a.addConnectionObserver(connectionObserver); verify(connectionObserver).setConnected(false); wdyt</technical_language>

Target:
public void connectionObserverTests() throws ConfigurationException { final String url = "tcp://123.123.123.123"; final String name = "TestName12@!"; MqttBrokerConnection a = new MqttBrokerConnection(name, url, false); assertFalse(a.isConnectionObservers()); MqttConnectionObserver connectionObserver = mock(MqttConnectionObserver.class); a.addConnectionObserver(connectionObserver); verify(connectionObserver).setConnected(false); assertTrue(a.isConnectionObservers()); a.removeConnectionObserver(connectionObserver); assertFalse(a.isConnectionObservers()); }
Source:
<code>void populate(final int row, final PluginInfo plugin) { if (plugin.disabled() || plugin.indexUrl() == null) { table.setText(row, 1, plugin.name()); } else { table.setWidget(row, 1, new Anchor(plugin.name(), Gerrit.selfRedirect(plugin.indexUrl()), "_blank")); if (new ExtensionScreen(plugin.name() + "/settings").isFound()) { <START> Anchor adminScreenAcnhcor = new Anchor(new ImageResourceRenderer().render(Gerrit.RESOURCES.gear()), Gerrit.selfRedirect("#/x/" + plugin.name() + "/settings")); <END> adminScreenAcnhcor.setTitle(Util.C.pluginSettingsToolTip()); table.setWidget(row, 2, adminScreenAcnhcor); } } table.setText(row, 3, plugin.version()); table.setText(row, 4, plugin.disabled() ? Util.C.pluginDisabled() : Util.C.pluginEnabled()); final FlexCellFormatter fmt = table.getFlexCellFormatter(); fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().dataCell()); fmt.addStyleName(row, 2, Gerrit.RESOURCES.css().dataCell()); fmt.addStyleName(row, 3, Gerrit.RESOURCES.css().dataCell()); fmt.addStyleName(row, 4, Gerrit.RESOURCES.css().dataCell()); setRowItem(row, plugin); }</code><technical_language>Anchor this. Instead InlineHyperlink target set "/x/" + plugin.name() + "/settings". allow screen build content in background navigating</technical_language>

Target:
void populate(final int row, final PluginInfo plugin) { if (plugin.disabled() || plugin.indexUrl() == null) { table.setText(row, 1, plugin.name()); } else { table.setWidget(row, 1, new Anchor(plugin.name(), Gerrit.selfRedirect(plugin.indexUrl()), "_blank")); if (new ExtensionScreen(plugin.name() + "/settings").isFound()) { InlineHyperlink adminScreenLink = new InlineHyperlink(); adminScreenLink.setHTML(new ImageResourceRenderer().render(Gerrit.RESOURCES.gear())); adminScreenLink.setTargetHistoryToken("/x/" + plugin.name() + "/settings"); adminScreenLink.setTitle(Util.C.pluginSettingsToolTip()); table.setWidget(row, 2, adminScreenLink); } } table.setText(row, 3, plugin.version()); table.setText(row, 4, plugin.disabled() ? Util.C.pluginDisabled() : Util.C.pluginEnabled()); final FlexCellFormatter fmt = table.getFlexCellFormatter(); fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().dataCell()); fmt.addStyleName(row, 2, Gerrit.RESOURCES.css().dataCell()); fmt.addStyleName(row, 3, Gerrit.RESOURCES.css().dataCell()); fmt.addStyleName(row, 4, Gerrit.RESOURCES.css().dataCell()); setRowItem(row, plugin); }
Source:
<code>public void testAnswerQuestion() { DateData ans; FormEntryController fec = fpi.getFormEntryController(); FormEntryPrompt prompt; fec.jumpToIndex(FormIndex.createBeginningOfFormIndex()); Localizer l = fpi.getFormDef().getLocalizer(); l.setDefaultLocale(l.getAvailableLocales()[0]); l.setLocale(l.getAvailableLocales()[0]); <START> do { <END> QuestionDef q = fpi.getCurrentQuestion(); if (q == null) { continue; } ans = new DateData(new Date()); fec.answerQuestion(ans); fec.stepToNextEvent(); prompt = fpi.getFormEntryModel().getQuestionPrompt(); String unwrappedDateString = prompt.getLongText(); String javaDateString = new SimpleDateFormat("dd MMM, yyyy").format(new Date()); assertEquals(javaDateString, unwrappedDateString); fec.stepToNextEvent(); prompt = fpi.getFormEntryModel().getQuestionPrompt(); unwrappedDateString = prompt.getLongText(); javaDateString = new SimpleDateFormat("dd MMM, yyyy").format(new Date()); assertEquals(javaDateString, unwrappedDateString); } while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM); }</code><technical_language>do/while/continue needed if add additional fec.stepToNextEvent() call</technical_language>

Target:
public void testAnswerQuestion() { DateData ans; FormEntryController fec = fpi.getFormEntryController(); FormEntryPrompt prompt; fec.jumpToIndex(FormIndex.createBeginningOfFormIndex()); Localizer l = fpi.getFormDef().getLocalizer(); l.setDefaultLocale(l.getAvailableLocales()[0]); l.setLocale(l.getAvailableLocales()[0]); fec.stepToNextEvent(); ans = new DateData(new Date()); fec.answerQuestion(ans); fec.stepToNextEvent(); prompt = fpi.getFormEntryModel().getQuestionPrompt(); String unwrappedDateString = prompt.getLongText(); String javaDateString = new SimpleDateFormat("dd MMM, yyyy", Locale.US).format(new Date()); assertEquals(javaDateString, unwrappedDateString); fec.stepToNextEvent(); prompt = fpi.getFormEntryModel().getQuestionPrompt(); unwrappedDateString = prompt.getLongText(); javaDateString = new SimpleDateFormat("dd MMM, yyyy", Locale.US).format(new Date()); assertEquals(javaDateString, unwrappedDateString); }
Source:
<code>public @NonNull Multimap<@NonNull String, @NonNull Object> getMetadata() { <START> return HashMultimap.create(); <END> }</code><technical_language>Get model one</technical_language>

Target:
public @NonNull Multimap<@NonNull String, @NonNull Object> getMetadata() { return fModel.getMetadata(); }
Source:
<code>public static SDIndex interval(Integer begin, Integer strides, Integer end){ if(strides == 0){ <START> throw new ND4JIllegalArgumentException("Invalid index : strides can not be 0."); <END> } SDIndex sdIndex = new SDIndex(); sdIndex.indexType = IndexType.INTERVAL; sdIndex.interval_begin = begin; sdIndex.interval_end = end; sdIndex.interval_strides = strides; return sdIndex; }</code><technical_language>More a stylistic - Preconditions.checkState(strides != 0, <error msg></technical_language>

Target:
public static SDIndex interval(Integer begin, Integer strides, Integer end){ if(strides == 0){ throw new ND4JIllegalArgumentException("Invalid index : strides can not be 0."); } SDIndex sdIndex = new SDIndex(); sdIndex.indexType = IndexType.INTERVAL; if(begin != null) { sdIndex.intervalBegin = begin.longValue(); } if(end != null){ sdIndex.intervalEnd = end.longValue(); } if(strides != null){ sdIndex.intervalStrides = strides.longValue(); } return sdIndex; }
Source:
<code>public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> externalAuthorities) { logger.debug(String.format("Map authorities [%s]", externalAuthorities)); Collection<? extends GrantedAuthority> result = externalAuthorities.stream() .map(GrantedAuthority::getAuthority) .map(a -> getRolesMapping().get(a)) <START> .filter(a -> a != null) <END> .map(a -> new SimpleGrantedAuthority(a)) .collect(Collectors.toSet()); logger.debug(String.format("Authorities mapped [%s]", result)); return result; }</code><technical_language>Objects::nonNull instead of a -> a != null</technical_language>

Target:
public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> externalAuthorities) { logger.debug(String.format("Map authorities [%s]", externalAuthorities)); Collection<? extends GrantedAuthority> result = externalAuthorities.stream() .map(GrantedAuthority::getAuthority) .map(a -> getRolesMapping().get(a)) .filter(Objects::nonNull) .map(SimpleGrantedAuthority::new) .collect(Collectors.toSet()); logger.debug(String.format("Authorities mapped [%s]", result)); return result; }
Source:
<code>public void runCommand(final String idTopMenuCommand, final String idCommandName) { <START> WebDriverWait redrawMenuItemsWait = <END> new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC); loader.waitOnClosed(); try { redrawMenuItemsWait .until(ExpectedConditions.visibilityOfElementLocated(By.id(idTopMenuCommand))) .click(); } catch (WebDriverException ex) { LOG.error(ex.getLocalizedMessage(), ex); WaitUtils.sleepQuietly(REDRAW_UI_ELEMENTS_TIMEOUT_SEC, TimeUnit.MILLISECONDS); redrawMenuItemsWait .until(ExpectedConditions.visibilityOfElementLocated(By.id(idTopMenuCommand))) .click(); } try { redrawMenuItemsWait .until(ExpectedConditions.visibilityOfElementLocated(By.id(idCommandName))) .click(); } catch (TimeoutException e) { seleniumWebDriver.findElement(By.id(idTopMenuCommand)).click(); redrawMenuItemsWait .until(ExpectedConditions.visibilityOfElementLocated(By.id(idCommandName))) .click(); } redrawMenuItemsWait.until( ExpectedConditions.invisibilityOfElementLocated(By.id(idCommandName))); }</code><technical_language>extract field **redrawMenuItemsWait** avoid repetitive creation of in methods in class</technical_language>

Target:
public void runCommand(final String idTopMenuCommand, final String idCommandName) { loader.waitOnClosed(); try { redrawMenuItemsWait .until(ExpectedConditions.visibilityOfElementLocated(By.id(idTopMenuCommand))) .click(); } catch (WebDriverException ex) { LOG.error(ex.getLocalizedMessage(), ex); WaitUtils.sleepQuietly(REDRAW_UI_ELEMENTS_TIMEOUT_SEC, TimeUnit.MILLISECONDS); redrawMenuItemsWait .until(ExpectedConditions.visibilityOfElementLocated(By.id(idTopMenuCommand))) .click(); } try { redrawMenuItemsWait .until(ExpectedConditions.visibilityOfElementLocated(By.id(idCommandName))) .click(); } catch (TimeoutException e) { seleniumWebDriver.findElement(By.id(idTopMenuCommand)).click(); redrawMenuItemsWait .until(ExpectedConditions.visibilityOfElementLocated(By.id(idCommandName))) .click(); } redrawMenuItemsWait.until( ExpectedConditions.invisibilityOfElementLocated(By.id(idCommandName))); }
Source:
<code>BaseBackupReceiver(Cache<Object, Object> cache) { this.cache = cache.getAdvancedCache(); this.cacheName = ByteString.fromString(cache.getName()); ComponentRegistry registry = this.cache.getComponentRegistry(); this.timeService = registry.getTimeService(); ExecutorService executor = registry.getComponent(ExecutorService.class, ASYNC_OPERATIONS_EXECUTOR); <START> TransactionHandler txHandler = new TransactionHandler(cache); <END> this.defaultHandler = new DefaultHandler(txHandler, executor); this.orderedHandler = new OrderedHandler(txHandler, executor); }</code><technical_language>I remote executor here, async operations executor meant for cache operations triggered a user this is a (very) remote operation</technical_language>

Target:
BaseBackupReceiver(Cache<Object, Object> cache) { this.cache = cache.getAdvancedCache(); this.cacheName = ByteString.fromString(cache.getName()); ComponentRegistry registry = this.cache.getComponentRegistry(); this.timeService = registry.getTimeService(); ExecutorService executor = registry.getComponent(ExecutorService.class, REMOTE_COMMAND_EXECUTOR); TransactionHandler txHandler = new TransactionHandler(cache); this.defaultHandler = new DefaultHandler(txHandler, executor); this.asyncBackupHandler = new AsyncBackupHandler(txHandler, executor); }
Source:
<code>public int compare(LObject<T> lObject1, LObject<T> lObject2) { return ComparisonChain.start() .compare(calculator.getPriority(lObject1), calculator.getPriority(lObject2)) <START> .result(); <END> }</code><technical_language>I love Guava I this is overkill ;) This enough: <LINK_0></technical_language>

Target:
public int compare(LObject<T> lObject1, LObject<T> lObject2) { return ((Double) calculator.getPriority(lObject1)).compareTo(calculator.getPriority(lObject2)); }
Source:
<code>private ChangeRecord getRecordForPath(String path) throws KeeperException.NoNodeException { ChangeRecord lastChange = null; <START> synchronized (zks.getOutstandingChanges()) { <END> lastChange = zks.getOutstandingChangesForPath().get(path); if (lastChange == null) { DataNode n = zks.getZKDatabase().getNode(path); if (n != null) { Set<String> children; synchronized(n) { children = n.getChildren(); } lastChange = new ChangeRecord(-1, path, n.stat, children.size(), zks.getZKDatabase().aclForNode(n)); } } } if (lastChange == null || lastChange.stat == null) { throw new KeeperException.NoNodeException(path); } return lastChange; }</code><technical_language>call getter synchronized block then. reference returned object? clearer accessing object</technical_language>

Target:
private ChangeRecord getRecordForPath(String path) throws KeeperException.NoNodeException { ChangeRecord lastChange = null; synchronized (zks.outstandingChanges) { lastChange = zks.outstandingChangesForPath.get(path); if (lastChange == null) { DataNode n = zks.getZKDatabase().getNode(path); if (n != null) { Set<String> children; synchronized(n) { children = n.getChildren(); } lastChange = new ChangeRecord(-1, path, n.stat, children.size(), zks.getZKDatabase().aclForNode(n)); } } } if (lastChange == null || lastChange.stat == null) { throw new KeeperException.NoNodeException(path); } return lastChange; }
Source:
<code>public List<String> toListFromKeywords(List<CcJudgmentKeyword> keywords) { if(keywords == null) <START> keywords = Collections.emptyList(); <END> List<String> list = keywords.stream() .map(CcJudgmentKeyword::getPhrase) .collect(Collectors.toList()); return list; }</code><technical_language>Missing bracets {}</technical_language>

Target:
public List<String> toListFromKeywords(List<CcJudgmentKeyword> keywords) { if(keywords == null) { keywords = Collections.emptyList(); } List<String> list = keywords.stream() .map(CcJudgmentKeyword::getPhrase) .collect(Collectors.toList()); return list; }
Source:
<code>private void populateFieldInfosFromPojo(ColumnDefinitions rsMetaData) { fieldInfos = Lists.newArrayList(); Field[] fields = pojoClass.getDeclaredFields(); for (int i = 0; i < rsMetaData.size(); i++) { String columnName = rsMetaData.getName(i); String pojoField = getMatchingField(fields, columnName); <START> if (pojoField != null && pojoField.length() != 0) { <END> fieldInfos.add(new FieldInfo(columnName, pojoField, null)); } } }</code><technical_language>if pojoField is null? Please check if this problems matching field is found</technical_language>

Target:
private void populateFieldInfosFromPojo(ColumnDefinitions rsMetaData) { fieldInfos = Lists.newArrayList(); Field[] fields = pojoClass.getDeclaredFields(); for (int i = 0; i < rsMetaData.size(); i++) { String columnName = rsMetaData.getName(i); String pojoField = getMatchingField(fields, columnName); if (pojoField != null && pojoField.length() != 0) { fieldInfos.add(new FieldInfo(columnName, pojoField, null)); } else { LOG.error("Couldn't find corrosponding pojo field for column: " + columnName); } } }
Source:
<code><START> @Override public String setCity(String city) { <END> return city; }</code><technical_language>left side preferred style (annotations in extra line)</technical_language>

Target:
public String setCity(String city) { return city; }
Source:
<code>public static Options noProfileRunSubOptions() { Options options = new Options(); <START> Arrays.asList(SIGNATURE_FILE, CONTAINER_SIGNATURE_FILE, EXTENSION_LIST, ARCHIVES, WEB_ARCHIVES, WEB_ARCHIVE_TYPES, RECURSIVE, QUIET).forEach( <END> option -> options.addOption(option.newOption()) ); return options; }</code><technical_language>missing newly added ARCHIVE_TYPES</technical_language>

Target:
public static Options noProfileRunSubOptions() { Options options = new Options(); Arrays.asList(SIGNATURE_FILE, CONTAINER_SIGNATURE_FILE, EXTENSION_LIST, ARCHIVES, ARCHIVE_TYPES, WEB_ARCHIVES, WEB_ARCHIVE_TYPES, RECURSIVE, QUIET).forEach( option -> options.addOption(option.newOption()) ); return options; }
Source:
<code>private Map<String, AttributeValue> createPrimaryKey(String key) { Map<String, AttributeValue> k = new HashMap<String, AttributeValue>(); if (primaryKeyType == PrimaryKeyType.HASH) { k.put(primaryKeyName, new AttributeValue().withS(key)); } else if (primaryKeyType == PrimaryKeyType.HASH_AND_RANGE) { <START> k = new HashMap<String, AttributeValue>(); <END> k.put(hashKeyName, new AttributeValue().withS(hashKeyValue)); k.put(primaryKeyName, new AttributeValue().withS(key)); } else { throw new RuntimeException("Assertion Error: impossible primary key" + " type"); } return k; }</code><technical_language>need a new hashmap here? is initialized line 343 already</technical_language>

Target:
private Map<String, AttributeValue> createPrimaryKey(String key) { Map<String, AttributeValue> k = new HashMap<String, AttributeValue>(); if (primaryKeyType == PrimaryKeyType.HASH) { k.put(primaryKeyName, new AttributeValue().withS(key)); } else if (primaryKeyType == PrimaryKeyType.HASH_AND_RANGE) { k.put(hashKeyName, new AttributeValue().withS(hashKeyValue)); k.put(primaryKeyName, new AttributeValue().withS(key)); } else { throw new RuntimeException("Assertion Error: impossible primary key" + " type"); } return k; }
Source:
<code>public static String implode(final String[] input) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < input.length; i++) { <START> if (!isNull(input[i])) { <END> builder.append(input[i]); } } return builder.toString(); }</code><technical_language>a new U.nonNull() method</technical_language>

Target:
public static String implode(final String[] input) { StringBuilder builder = new StringBuilder(); for (String character : input) { if (nonNull(character)) { builder.append(character); } } return builder.toString(); }
Source:
<code>public String toString() { final StringBuilder sb = new StringBuilder("Transaction{"); sb.append("account=").append(account); sb.append(", invoice=").append(invoice); sb.append(", subscription='").append(subscription).append('\''); sb.append(", uuid='").append(uuid).append('\''); sb.append(", taxInCents=").append(taxInCents); sb.append(", currency='").append(currency).append('\''); sb.append(", description='").append(description).append('\''); sb.append(", recurring=").append(recurring); sb.append(", productCode=").append(productCode); sb.append(", createdAt=").append(createdAt); sb.append(", details=").append(details); sb.append(", paymentMethod=").append(paymentMethod); sb.append(", collectedAt=").append(collectedAt); sb.append(", updatedAt=").append(updatedAt); sb.append(", origin=").append(origin); sb.append(", gatewayType=").append(gatewayType); sb.append(", message=").append(message); sb.append(", failureType=").append(failureType); <START> sb.append(", approvalCode=").append(approvalCode); <END> sb.append('}'); return sb.toString(); }</code><technical_language>Missing gatewayErrorCodes</technical_language>

Target:
public String toString() { final StringBuilder sb = new StringBuilder("Transaction{"); sb.append("account=").append(account); sb.append(", invoice=").append(invoice); sb.append(", subscription='").append(subscription).append('\''); sb.append(", uuid='").append(uuid).append('\''); sb.append(", taxInCents=").append(taxInCents); sb.append(", currency='").append(currency).append('\''); sb.append(", description='").append(description).append('\''); sb.append(", recurring=").append(recurring); sb.append(", productCode=").append(productCode); sb.append(", createdAt=").append(createdAt); sb.append(", details=").append(details); sb.append(", paymentMethod=").append(paymentMethod); sb.append(", collectedAt=").append(collectedAt); sb.append(", updatedAt=").append(updatedAt); sb.append(", origin=").append(origin); sb.append(", gatewayType=").append(gatewayType); sb.append(", message=").append(message); sb.append(", failureType=").append(failureType); sb.append(", approvalCode=").append(approvalCode); sb.append(", gatewayErrorCodes=").append(gatewayErrorCodes); sb.append('}'); return sb.toString(); }
Source:
<code>public RestListWrapper<EchoParameter> getEchoParameters() { return new RestListWrapper<>( <START> EchoParametersDao.getEchoParameters().stream().collect(Collectors.toList()), <END> EchoParameter.class, this, "id", null); }</code><technical_language>EchoParametersDao.getEchoParameters() returns a list</technical_language>

Target:
public RestListWrapper<EchoParameter> getEchoParameters() { return new RestListWrapper<>( EchoParametersDao.getEchoParameters(), EchoParameter.class, this, "id", null); }
Source:
<code>public AvailabilityMode getAvailability() { if (distributionManager != null) { <START> LocalTopologyManager localTopologyManager = cacheManager.getGlobalComponentRegistry().getComponent(LocalTopologyManager.class); <END> return localTopologyManager.getCacheAvailability(name); } else { return AvailabilityMode.AVAILABLE; } }</code><technical_language>inject PartitionHandlingManager instead</technical_language>

Target:
public AvailabilityMode getAvailability() { if (partitionHandlingManager != null) { return partitionHandlingManager.getAvailabilityMode(); } else { return AvailabilityMode.AVAILABLE; } }
Source:
<code>private void releaseExclusiveLock(String key) { InternalLockView lock = locks.get(key); if (lock != null && lock.getExclusive()) { locks.remove(key); log.debugFormat("The exclusive lock for key {0} is released and lock is removed from map", key); } else if (lock == null) { <START> log.warnFormat("Trying to release exclusive lock which is not exist with for {0}", key); <END> } else { log.warnFormat("Trying to release exclusive lock which is not exclusive lock for key {0}", key); } }</code><technical_language>release exclusive lock exist, lock key: {0}", key</technical_language>

Target:
private void releaseExclusiveLock(String key) { InternalLockView lock = locks.get(key); if (lock != null && lock.getExclusive()) { locks.remove(key); log.debugFormat("The exclusive lock for key {0} is released and lock is removed from map", key); } else if (lock == null) { log.warnFormat("Trying to release exclusive lock which does not exist, lock key: {0}", key); } else { log.warnFormat("Trying to release exclusive lock but lock is not exclusive. lock key: {0}", key); } }
Source:
<code>public static Node toNode(String data, String documentNS, Storage storage) throws SAXException { try { <START> return toNode(new ByteArrayInputStream(data.getBytes("UTF-16")), Optional.of("UTF-16"), documentNS, <END> storage); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e.getMessage(), e); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } }</code><technical_language>opening a stream closing a other method. Is this a good way? proper open close a stream method</technical_language>

Target:
public static Node toNode(String data, String documentNS, Storage storage) throws SAXException { try (ByteArrayInputStream bytes = new ByteArrayInputStream(data.getBytes("UTF-16"))) { return toNode(bytes, Optional.of("UTF-16"), documentNS, storage); } catch (IOException e) { throw new IllegalStateException(e.getMessage(), e); } }
Source:
<code>public boolean getBoolean(int field) { checkFieldType(field, ImmutableSet.of(BOOLEAN)); <START> return Boolean.valueOf(String.valueOf(getFieldValue(field))); <END> }</code><technical_language>return Boolean.parseBoolean(getFieldValue(field).toString());</technical_language>

Target:
public boolean getBoolean(int field) { checkFieldType(field, ImmutableSet.of(BOOLEAN)); return Boolean.parseBoolean(getFieldValue(field).toString()); }
Source:
<code><START> public static void main(String... args) throws CheckstyleException { <END> final JavadocPropertiesGenerator generator = new JavadocPropertiesGenerator(); final CommandLine cmd = new CommandLine(generator).setUsageHelpWidth(USAGE_HELP_WIDTH); try { final ParseResult parseResult = cmd.parseArgs(args); if (!CommandLine.printHelpIfRequested(parseResult)) { generator.writePropertiesFile(); } } catch (ParameterException ex) { System.err.println(ex.getMessage()); ex.getCommandLine().usage(System.err); } }</code><technical_language>original code caught exception. Is a reason catch instead of passing chain</technical_language>

Target:
public static void main(String... args) throws CheckstyleException { final CliOptions cliOptions = new CliOptions(); final CommandLine cmd = new CommandLine(cliOptions).setUsageHelpWidth(USAGE_HELP_WIDTH); try { final ParseResult parseResult = cmd.parseArgs(args); if (parseResult.isUsageHelpRequested()) { cmd.usage(System.out); } else { writePropertiesFile(cliOptions); } } catch (ParameterException ex) { System.err.println(ex.getMessage()); ex.getCommandLine().usage(System.err); } }