auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void createOpenShiftRoute(String serviceName, String serverRef, String workspaceName) { String routeName = CHE_OPENSHIFT_RESOURCES_PREFIX + workspaceName + "." + serverRef; if (cheServerExternalAddress == null) { <START> throw new NullPointerException("Property che.docker.ip.external must be set when using openshift."); <END> } String serviceHost = serverRef + "." + workspaceName + "." + this.cheServerExternalAddress; Route route = openShiftClient .routes() .inNamespace(this.openShiftCheProjectName) .createNew() .withNewMetadata() .withName(routeName) .addToLabels(OPENSHIFT_DEPLOYMENT_LABEL,serviceName) .endMetadata() .withNewSpec() .withHost(serviceHost) .withNewTo() .withKind("Service") .withName(serviceName) .endTo() .withNewPort() .withNewTargetPort() .withStrVal(serverRef) .endTargetPort() .endPort() .endSpec() .done(); LOG.info("OpenShift route created", route.getMetadata().getName()); }</code><technical_language>I IllegalArgumentException</technical_language>

Target:
private void createOpenShiftRoute(String serviceName, String serverRef, String workspaceName) { String routeName = CHE_OPENSHIFT_RESOURCES_PREFIX + workspaceName + "." + serverRef; if (cheServerExternalAddress == null) { throw new IllegalArgumentException("Property che.docker.ip.external must be set when using openshift."); } String serviceHost = serverRef + "." + workspaceName + "." + this.cheServerExternalAddress; Route route = openShiftClient .routes() .inNamespace(this.openShiftCheProjectName) .createNew() .withNewMetadata() .withName(routeName) .addToLabels(OPENSHIFT_DEPLOYMENT_LABEL,serviceName) .endMetadata() .withNewSpec() .withHost(serviceHost) .withNewTo() .withKind("Service") .withName(serviceName) .endTo() .withNewPort() .withNewTargetPort() .withStrVal(serverRef) .endTargetPort() .endPort() .endSpec() .done(); LOG.info("OpenShift route created", route.getMetadata().getName()); }
Source:
<code>public void onMessage(String messageType, JSONObject messagePayload) { if (!fragment.isAdded()) { return; } if (messageType.equals("editSectionClicked")) { if (messagePayload.has("mainPencilClicked") && DescriptionEditClient.isEditAllowed(currentPage)) { View tempView = new View(fragment.requireContext()); tempView.setX(DimenUtil.dpToPx(messagePayload.optInt("x"))); tempView.setY(DimenUtil.dpToPx(messagePayload.optInt("y")) - fragment.getWebView().getScrollY()); ((ViewGroup) fragment.getView()).addView(tempView); <START> PopupMenu menu = new PopupMenu(fragment.requireContext(), tempView, GravityCompat.END, 0, R.style.PagePopupMenu); menu.getMenuInflater().inflate(R.menu.menu_page_header_edit, menu.getMenu()); menu.setOnMenuItemClickListener(new EditMenuClickListener()); menu.setOnDismissListener(menu1 -> ((ViewGroup) fragment.getView()).removeView(tempView)); menu.show(); <END> } else if (messagePayload.has("editDescriptionClicked") && DescriptionEditClient.isEditAllowed(currentPage)) { verifyDescriptionEditable(); } else { startEditingSection(messagePayload.optInt("sectionID"), null); } } }</code><technical_language>reading articles in Hebrew, PopupMenu shows right-hand side instead of exact position cursor was</technical_language>

Target:
public void onMessage(String messageType, JSONObject messagePayload) { if (!fragment.isAdded()) { return; } if (messageType.equals("editSectionClicked")) { if (messagePayload.has("mainPencilClicked") && DescriptionEditClient.isEditAllowed(currentPage)) { View tempView = new View(fragment.requireContext()); tempView.setX(DimenUtil.dpToPx(messagePayload.optInt("x"))); tempView.setY(DimenUtil.dpToPx(messagePayload.optInt("y")) - fragment.getWebView().getScrollY()); ((ViewGroup) fragment.getView()).addView(tempView); PopupMenu menu = new PopupMenu(fragment.requireContext(), tempView, 0, 0, R.style.PagePopupMenu); menu.getMenuInflater().inflate(R.menu.menu_page_header_edit, menu.getMenu()); menu.setOnMenuItemClickListener(new EditMenuClickListener()); menu.setOnDismissListener(menu1 -> ((ViewGroup) fragment.getView()).removeView(tempView)); menu.show(); } else if (messagePayload.has("editDescriptionClicked") && DescriptionEditClient.isEditAllowed(currentPage)) { verifyDescriptionEditable(); } else { startEditingSection(messagePayload.optInt("sectionID"), null); } } }
Source:
<code>public void exportCurrentDataSetLookup(ExportFormat format, int maxRows, ExportCallback callback) { int allRows = lastLookedUpDataSet.getRowCountNonTrimmed(); <START> if (allRows > 0 && allRows > maxRows) { <END> callback.tooManyRows(allRows); return; } if (lastLookedUpDataSet.getRowCount() == 0) { callback.noData(); return; } try { DataSetExportReadyCallback exportReadyCallback = new DataSetExportReadyCallback() { @Override public void exportReady(Path exportFilePath) { final String u = clientServices.getDownloadFileUrl(exportFilePath); callback.exportFileUrl(u); } @Override public void onError(ClientRuntimeError error) { callback.error(error); } }; DataSetLookup exportLookup = getCurrentDataSetLookup().cloneInstance(); exportLookup.setRowOffset(0); exportLookup.setNumberOfRows(maxRows); if (ExportFormat.XLS.equals(format)) { clientServices.exportDataSetExcel(exportLookup, exportReadyCallback); } else { clientServices.exportDataSetCSV(exportLookup, exportReadyCallback); } } catch (Exception e) { callback.error(new ClientRuntimeError(e)); } }</code><technical_language>allRows > maxRows implies allRows > 0, part 0 redundant.</technical_language>

Target:
public void exportCurrentDataSetLookup(ExportFormat format, int maxRows, ExportCallback callback) { if (lastLookedUpDataSet == null || lastLookedUpDataSet.getRowCount() == 0) { callback.noData(); return; } int allRows = lastLookedUpDataSet.getRowCountNonTrimmed(); if (maxRows > 0 && allRows > maxRows) { callback.tooManyRows(allRows); return; } try { DataSetExportReadyCallback exportReadyCallback = new DataSetExportReadyCallback() { @Override public void exportReady(Path exportFilePath) { final String u = clientServices.getDownloadFileUrl(exportFilePath); callback.exportFileUrl(u); } @Override public void onError(ClientRuntimeError error) { callback.error(error); } }; DataSetLookup exportLookup = getCurrentDataSetLookup().cloneInstance(); exportLookup.setRowOffset(0); exportLookup.setNumberOfRows(maxRows); if (ExportFormat.XLS.equals(format)) { clientServices.exportDataSetExcel(exportLookup, exportReadyCallback); } else { clientServices.exportDataSetCSV(exportLookup, exportReadyCallback); } } catch (Exception e) { callback.error(new ClientRuntimeError(e)); } }
Source:
<code>protected InputTransformer lookupTransformerReference(String namespaceUri) throws InvalidSyntaxException { LOGGER.trace("Looking up Input Transformer by schema : {}", namespaceUri); Bundle bundle = FrameworkUtil.getBundle(this.getClass()); if (bundle != null) { BundleContext bundleContext = bundle.getBundleContext(); Collection<ServiceReference<InputTransformer>> transformerReference = bundleContext.getServiceReferences( InputTransformer.class, "(schema=" + namespaceUri + ")"); if (transformerReference.isEmpty()) { LOGGER.trace("Failed to find Input Transformer by schema : {}", namespaceUri); } else { LOGGER.trace( "Found Input Transformer by schema {}", transformerReference.iterator().next().getBundle().getSymbolicName(), <START> namespaceUri); <END> return bundleContext.getService(transformerReference.iterator().next()); } } return null; }</code><technical_language>nit: refactor transformerReference.iterator().next() variable</technical_language>

Target:
protected InputTransformer lookupTransformerReference(String namespaceUri) throws InvalidSyntaxException { LOGGER.trace("Looking up Input Transformer by schema : {}", namespaceUri); Bundle bundle = FrameworkUtil.getBundle(this.getClass()); if (bundle != null) { BundleContext bundleContext = bundle.getBundleContext(); Collection<ServiceReference<InputTransformer>> transformerReference = bundleContext.getServiceReferences( InputTransformer.class, "(schema=" + namespaceUri + ")"); if (!transformerReference.isEmpty()) { ServiceReference<InputTransformer> transformer = transformerReference.iterator().next(); LOGGER.trace( "Found Input Transformer by schema {}", transformer.getBundle().getSymbolicName(), namespaceUri); return bundleContext.getService(transformer); } LOGGER.trace("Failed to find Input Transformer by schema : {}", namespaceUri); } return null; }
Source:
<code>public void postInit(KeycloakSessionFactory factory) { factory.register(event -> { if (event instanceof UserRemovedEvent) { KeycloakSession keycloakSession = ((UserRemovedEvent) event).getKeycloakSession(); AuthorizationProvider provider = keycloakSession.getProvider(AuthorizationProvider.class); StoreFactory storeFactory = provider.getStoreFactory(); PolicyStore policyStore = storeFactory.getPolicyStore(); UserModel removedUser = ((UserRemovedEvent) event).getUser(); RealmModel realm = ((UserRemovedEvent) event).getRealm(); ResourceServerStore resourceServerStore = storeFactory.getResourceServerStore(); resourceServerStore .findByClients(realm.getClients().stream().map(clientModel -> clientModel.getId()).toArray(String[]::new)) .forEach(resourceServer -> { if (resourceServer != null) { policyStore.findByType(getId(), resourceServer.getId()).forEach(policy -> { <START> List<String> users = new ArrayList<>(); <END> for (String userId : getUsers(policy)) { if (!userId.equals(removedUser.getId())) { users.add(userId); } } try { if (users.isEmpty()) { policyStore.delete(policy.getId()); } else { policy.getConfig().put("users", JsonSerialization.writeValueAsString(users)); } } catch (IOException e) { throw new RuntimeException( "Error while synchronizing users with policy [" + policy.getName() + "].", e); } }); } }); } }); }</code><technical_language>Replace lines 173 - 180 java users = getUsers(policy).stream() .filter(userId -> ! userId.equals(removedUser.getId())) .collect(Collectors::toList);</technical_language>

Target:
public void postInit(KeycloakSessionFactory factory) { factory.register(event -> { if (event instanceof UserRemovedEvent) { KeycloakSession keycloakSession = ((UserRemovedEvent) event).getKeycloakSession(); AuthorizationProvider provider = keycloakSession.getProvider(AuthorizationProvider.class); StoreFactory storeFactory = provider.getStoreFactory(); PolicyStore policyStore = storeFactory.getPolicyStore(); UserModel removedUser = ((UserRemovedEvent) event).getUser(); RealmModel realm = ((UserRemovedEvent) event).getRealm(); ResourceServerStore resourceServerStore = storeFactory.getResourceServerStore(); realm.getClients().forEach(clientModel -> { ResourceServer resourceServer = resourceServerStore.findByClient(clientModel.getId()); if (resourceServer != null) { policyStore.findByType(getId(), resourceServer.getId()).forEach(policy -> { List<String> users = new ArrayList<>(); for (String userId : getUsers(policy)) { if (!userId.equals(removedUser.getId())) { users.add(userId); } } try { if (users.isEmpty()) { policyStore.delete(policy.getId()); } else { policy.putConfig("users", JsonSerialization.writeValueAsString(users)); } } catch (IOException e) { throw new RuntimeException("Error while synchronizing users with policy [" + policy.getName() + "].", e); } }); } }); } }); }
Source:
<code>private ConfigBagExtendingParent(ConfigBag parentBag) { <START> this.parentBag = parentBag; <END> }</code><technical_language>a bit surprised this do copy(parentBag). leave caller, do ConfigBagExtendingParent's constructor? I lean extended it. strong feelings</technical_language>

Target:
private ConfigBagExtendingParent(ConfigBag parentBag) { this.parentBag = parentBag; copy(parentBag); }
Source:
<code>private static boolean isValidIndexVersionOperationList(List<IndexVersionOperation> indexVersionOperations) { boolean isValid = false; IndexVersionOperation lastNoopOperationIndexVersion = null; IndexVersionOperation indexWithDeleteHiddenOp = null; <START> for (int i = 0; i < indexVersionOperations.size(); i++) { <END> if (indexVersionOperations.get(i).getOperation() == Operation.NOOP) { lastNoopOperationIndexVersion = indexVersionOperations.get(i); } if (indexVersionOperations.get(i).getOperation() == Operation.DELETE_HIDDEN_AND_DISABLE) { indexWithDeleteHiddenOp = indexVersionOperations.get(i); } } if (lastNoopOperationIndexVersion.getIndexName().getCustomerVersion() == 0) { isValid = true; } else if (lastNoopOperationIndexVersion.getIndexName().getCustomerVersion() != 0) { if (indexWithDeleteHiddenOp != null) { isValid = true; } } if (!isValid) { log.info("IndexVersionOperation List is not valid for index {}", lastNoopOperationIndexVersion.getIndexName().getNodeName()); } return isValid; }</code><technical_language>I enhanced for avoid number of calls indexVersionOperations.get(i)</technical_language>

Target:
private static boolean isValidIndexVersionOperationList(List<IndexVersionOperation> indexVersionOperations) { boolean isValid = false; IndexVersionOperation lastNoopOperationIndexVersion = null; IndexVersionOperation indexWithDeleteHiddenOp = null; for (IndexVersionOperation indexVersionOperation : indexVersionOperations) { if (indexVersionOperation.getOperation() == Operation.NOOP) { lastNoopOperationIndexVersion = indexVersionOperation; } if (indexVersionOperation.getOperation() == Operation.DELETE_HIDDEN_AND_DISABLE) { indexWithDeleteHiddenOp = indexVersionOperation; } } if (lastNoopOperationIndexVersion.getIndexName().getCustomerVersion() == 0) { isValid = true; } else if (lastNoopOperationIndexVersion.getIndexName().getCustomerVersion() != 0) { if (indexWithDeleteHiddenOp != null && lastNoopOperationIndexVersion.getIndexName().getProductVersion() == indexWithDeleteHiddenOp.getIndexName().getProductVersion()) { isValid = true; } } if (!isValid) { LOG.info("IndexVersionOperation List is not valid for index {}", lastNoopOperationIndexVersion.getIndexName().getNodeName()); } return isValid; }
Source:
<code>public SpongeSkinPart(int ordinal, String id) { this.ordinal = ordinal; this.mask = 1 << this.ordinal; this.id = id; <START> this.translation = new SpongeTranslation("options.modelPart." + this.id); <END> }</code><technical_language>Wheres is this string coming from</technical_language>

Target:
public SpongeSkinPart(int ordinal, String id) { super("minecraft:" + id, new SpongeTranslation("options.modelPart." + id)); this.ordinal = ordinal; this.mask = 1 << this.ordinal; }
Source:
<code>private Set<Symbol> getAlternativeDefinitions(Symbol symbol, List<Usage> bindingUsages) { Set<Symbol> alternativeDefinitions = new HashSet<>(); for (Usage bindingUsage : bindingUsages) { switch (bindingUsage.kind()) { case FUNC_DECLARATION: FunctionDef functionDef = (FunctionDef) bindingUsage.tree().parent(); FunctionSymbolImpl functionSymbol = new FunctionSymbolImpl(functionDef, symbol.fullyQualifiedName(), pythonFile); <START> ParameterList parameters = functionDef.parameters(); <END> if (parameters != null) { functionSymbol.addParameters(parameters); } ((FunctionDefImpl) functionDef).setFunctionSymbol(functionSymbol); alternativeDefinitions.add(functionSymbol); break; case CLASS_DECLARATION: ClassSymbolImpl classSymbol = new ClassSymbolImpl(symbol.name(), symbol.fullyQualifiedName()); ClassDef classDef = (ClassDef) bindingUsage.tree().parent(); resolveTypeHierarchy(classDef, classSymbol); Scope classScope = scopesByRootTree.get(classDef); classSymbol.addMembers(getClassMembers(classScope.symbolsByName, classScope.instanceAttributesByName)); alternativeDefinitions.add(classSymbol); break; default: SymbolImpl alternativeSymbol = new SymbolImpl(symbol.name(), symbol.fullyQualifiedName()); alternativeDefinitions.add(alternativeSymbol); } } return alternativeDefinitions; }</code><technical_language>do FunctionSymbolImpl constructor anymore</technical_language>

Target:
private Set<Symbol> getAlternativeDefinitions(Symbol symbol, List<Usage> bindingUsages) { Set<Symbol> alternativeDefinitions = new HashSet<>(); for (Usage bindingUsage : bindingUsages) { switch (bindingUsage.kind()) { case FUNC_DECLARATION: FunctionDef functionDef = (FunctionDef) bindingUsage.tree().parent(); FunctionSymbolImpl functionSymbol = new FunctionSymbolImpl(functionDef, symbol.fullyQualifiedName(), pythonFile); ((FunctionDefImpl) functionDef).setFunctionSymbol(functionSymbol); alternativeDefinitions.add(functionSymbol); break; case CLASS_DECLARATION: ClassSymbolImpl classSymbol = new ClassSymbolImpl(symbol.name(), symbol.fullyQualifiedName()); ClassDef classDef = (ClassDef) bindingUsage.tree().parent(); resolveTypeHierarchy(classDef, classSymbol, pythonFile, scopesByRootTree.get(fileInput).symbolsByName); Scope classScope = scopesByRootTree.get(classDef); classSymbol.addMembers(getClassMembers(classScope.symbolsByName, classScope.instanceAttributesByName)); alternativeDefinitions.add(classSymbol); break; default: SymbolImpl alternativeSymbol = new SymbolImpl(symbol.name(), symbol.fullyQualifiedName()); alternativeDefinitions.add(alternativeSymbol); } } return alternativeDefinitions; }
Source:
<code>public boolean isAvailable(String featureName) { <START> return Boolean.getBoolean(featureName) || Boolean.parseBoolean(features.getProperty(featureName, "true")); <END> }</code><technical_language>this allows env prop enable a feature (in spite of is in meta-inf files) allow for disabling a feature. Is this asymmetry intended? I find confusing. imagine confusing if env props (if present) act override for true false values</technical_language>

Target:
public boolean isAvailable(String featureName) { String name = FEATURE_PREFIX + featureName; String sysprop = SecurityActions.getProperty(name); if (sysprop != null) { return Boolean.parseBoolean(sysprop); } else { return Boolean.parseBoolean(features.getProperty(name, "true")); } }
Source:
<code>public void testIsFragment() throws Exception { String bundleName = getName(); File config = RuntimeTestsPlugin.getContext().getDataFile(bundleName); <START> config.mkdirs(); <END> Map<String, String> headers = new HashMap<>(); headers.put(Constants.BUNDLE_SYMBOLICNAME, bundleName); headers.put(Constants.BUNDLE_VERSION, "1.0.0"); File testBundleJarFile = createBundle(config, bundleName, headers, emptyMap()); Bundle hostBundle = getContext().installBundle(testBundleJarFile.getName(), new FileInputStream(testBundleJarFile)); assertNotNull(hostBundle); assertFalse(Platform.isFragment(hostBundle)); String fragmentName = bundleName + "_fragment"; headers.put(Constants.BUNDLE_SYMBOLICNAME, fragmentName); headers.put(Constants.BUNDLE_VERSION, "1.0.0"); headers.put(Constants.FRAGMENT_HOST, bundleName); testBundleJarFile = createBundle(config, fragmentName, headers, emptyMap()); Bundle fragmentBundle = getContext().installBundle(testBundleJarFile.getName(), new FileInputStream(testBundleJarFile)); assertNotNull(fragmentBundle); assertTrue(Platform.isFragment(fragmentBundle)); }</code><technical_language>Files.createDirectories(Path) throws exception if fails</technical_language>

Target:
public void testIsFragment() throws Exception { String bundleName = getName(); File config = RuntimeTestsPlugin.getContext().getDataFile(bundleName); Files.createDirectories(config.toPath()); Map<String, String> headers = new HashMap<>(); headers.put(Constants.BUNDLE_SYMBOLICNAME, bundleName); headers.put(Constants.BUNDLE_VERSION, "1.0.0"); File testBundleJarFile = createBundle(config, bundleName, headers, emptyMap()); Bundle hostBundle = getContext().installBundle(testBundleJarFile.getName(), new FileInputStream(testBundleJarFile)); assertNotNull(hostBundle); assertFalse(Platform.isFragment(hostBundle)); String fragmentName = bundleName + "_fragment"; headers.put(Constants.BUNDLE_SYMBOLICNAME, fragmentName); headers.put(Constants.BUNDLE_VERSION, "1.0.0"); headers.put(Constants.FRAGMENT_HOST, bundleName); testBundleJarFile = createBundle(config, fragmentName, headers, emptyMap()); Bundle fragmentBundle = getContext().installBundle(testBundleJarFile.getName(), new FileInputStream(testBundleJarFile)); assertNotNull(fragmentBundle); assertTrue(Platform.isFragment(fragmentBundle)); }
Source:
<code>private void createBranch(final String textForBranch, boolean doCheckout, RevCommit commit, IProgressMonitor monitor) throws CoreException { monitor.setTaskName(UIText.FetchGerritChangePage_CreatingBranchTaskName); CreateLocalBranchOperation bop = new CreateLocalBranchOperation( repository, textForBranch, commit); bop.execute(monitor); if (doCheckout) { CheckoutResult result; try { <START> result = checkout(textForBranch, monitor); <END> } catch (OperationCanceledException | InterruptedException e1) { return; } if (result.getStatus() == Status.CONFLICTS) { PlatformUI.getWorkbench().getDisplay().asyncExec(() -> { Shell shell = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(); CleanupUncomittedChangesDialog cleanupUncomittedChangesDialog = new CleanupUncomittedChangesDialog( shell, UIText.BranchResultDialog_CheckoutConflictsTitle, UIText.AbstractRebaseCommandHandler_cleanupDialog_text, repository, result.getConflictList()); cleanupUncomittedChangesDialog.open(); if (cleanupUncomittedChangesDialog.shouldContinue()) { try { checkout(textForBranch, monitor); } catch (InterruptedException e) { Activator.logError(e.getMessage(), e); } } }); } } monitor.worked(1); }</code><technical_language>Monitor handling is OK. Re-using monitor times--should convert SubMonitor pass children</technical_language>

Target:
private void createBranch(final String textForBranch, boolean doCheckout, RevCommit commit, IProgressMonitor monitor) throws CoreException { SubMonitor progress = SubMonitor.convert(monitor, UIText.FetchGerritChangePage_CreatingBranchTaskName, 10); CreateLocalBranchOperation bop = new CreateLocalBranchOperation( repository, textForBranch, commit); bop.execute(progress.newChild(8)); if (doCheckout) { CheckoutResult result; try { result = checkout(textForBranch, progress.newChild(1)); } catch (OperationCanceledException | InterruptedException e1) { return; } if (result.getStatus() == Status.CONFLICTS) { PlatformUI.getWorkbench().getDisplay().asyncExec(() -> { Shell shell = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(); CleanupUncomittedChangesDialog cleanupUncomittedChangesDialog = new CleanupUncomittedChangesDialog( shell, UIText.BranchResultDialog_CheckoutConflictsTitle, UIText.AbstractRebaseCommandHandler_cleanupDialog_text, repository, result.getConflictList()); cleanupUncomittedChangesDialog.open(); if (cleanupUncomittedChangesDialog.shouldContinue()) { try { checkout(textForBranch, progress.newChild(1)); } catch (InterruptedException e) { Activator.logError(e.getMessage(), e); } } }); } else { progress.setWorkRemaining(0); } } monitor.worked(1); }
Source:
<code>public void speakNames() { <START> if (settings.getAutomaticTts()) { <END> textToSpeechManager.speak(chosenNamesText, settings.getSpeechLanguage()); } }</code><technical_language>Ahhh, speaking check is here. Calling speakNames() speak names is confusing wastes a method call. I pass boolean presentation manager</technical_language>

Target:
public void speakNames() { textToSpeechManager.speak(chosenNamesText, settings.getSpeechLanguage()); }
Source:
<code>public void initialize() { layersById.clear(); Resource baseDir = resourceLoader.get(baseDirectory); LOGGER.info("GeoServer TileLayer store base directory is: " + baseDir.path()); final List<Resource> tileLayerFiles = Resources.list(baseDir, new Filter<Resource>() { @Override public boolean accept(Resource res) { return res.name().endsWith(".xml"); } }); LOGGER.info("Loading tile layers from " + baseDir.path()); tileLayerFiles.parallelStream().forEach(res -> { GeoServerTileLayerInfoImpl info; try { info = depersist(res); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error depersisting tile layer information from file " + res.name(), e); <START> return; <END> } layersById.put(info.getId(), info.getName()); if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("Loaded tile layer '" + info.getName() + "'"); } }); this.initialized = true; }</code><technical_language>this a programming mistake</technical_language>

Target:
public void initialize() { layersById.clear(); Resource baseDir = resourceLoader.get(baseDirectory); LOGGER.info("GeoServer TileLayer store base directory is: " + baseDir.path()); final List<Resource> tileLayerFiles = Resources.list(baseDir, new Filter<Resource>() { @Override public boolean accept(Resource res) { return res.name().endsWith(".xml"); } }); LOGGER.info("Loading tile layers from " + baseDir.path()); for (Resource res : tileLayerFiles) { GeoServerTileLayerInfoImpl info; try { info = depersist(res); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error depersisting tile layer information from file " + res.name(), e); continue; } layersById.put(info.getId(), info.getName()); if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("Loaded tile layer '" + info.getName() + "'"); } } this.initialized = true; }
Source:
<code><START> public boolean isEmpty() { <END> return normalizedName.isEmpty(); }</code><technical_language>here, add deprecation flag</technical_language>

Target:
public boolean isEmpty() { return normalisedName.isEmpty(); }
Source:
<code>@Test public void delegates() throws IOException { Retrofit retrofit = new Retrofit.Builder() .baseUrl(server.url("/")) .addConverterFactory(new Converter.Factory() { @Nullable @Override public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) { <START> if (getRawType(type) == Optional.class) { <END> return null; } return new Converter<ResponseBody, Object>() { @Override public Object convert(ResponseBody value) { return null; } }; } }) .addConverterFactory(GuavaOptionalConverterFactory.create()) .build(); server.enqueue(new MockResponse()); Service service = retrofit.create(Service.class); Optional<Object> optional = service.optional().execute().body(); assertThat(optional).isNotNull(); assertThat(optional.isPresent()).isFalse(); }</code><technical_language>this is surprising. . . . selecting types want, rejecting types don't</technical_language>

Target:
@Test public void delegates() throws IOException { Retrofit retrofit = new Retrofit.Builder() .baseUrl(server.url("/")) .addConverterFactory(new Converter.Factory() { @Nullable @Override public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) { if (getRawType(type) != Object.class) { return null; } return new Converter<ResponseBody, Object>() { @Override public Object convert(ResponseBody value) { return null; } }; } }) .addConverterFactory(GuavaOptionalConverterFactory.create()) .build(); server.enqueue(new MockResponse()); Service service = retrofit.create(Service.class); Optional<Object> optional = service.optional().execute().body(); assertThat(optional).isNotNull(); assertThat(optional.isPresent()).isFalse(); }
Source:
<code>void testMergeWithSingleSegmentRejected() throws InterruptedException { int numberOfSegments = 1; initProcessor(TrackingEventProcessorConfiguration.forParallelProcessing(numberOfSegments)); testSubject.start(); waitForActiveThreads(1); CompletableFuture<Boolean> actual = testSubject.mergeSegment(0); assertFalse(actual.join(), "Expected merge to be rejected"); waitForProcessingNotInStatus(0, EventTrackerStatus::isMerging); <START> <END> }</code><technical_language>Super nit: unnecessary empty line</technical_language>

Target:
void testMergeWithSingleSegmentRejected() throws InterruptedException { int numberOfSegments = 1; initProcessor(TrackingEventProcessorConfiguration.forParallelProcessing(numberOfSegments)); int segmentId = 0; testSubject.start(); waitForActiveThreads(1); CompletableFuture<Boolean> actual = testSubject.mergeSegment(segmentId); assertFalse(actual.join(), "Expected merge to be rejected"); assertFalse(testSubject.processingStatus().get(segmentId).isMerging()); }
Source:
<code>public void testGetAllForTemplateWithPermissionsForUnprivilegedUser() { List<VmNetworkInterface> result = dao.getAllForTemplate(TEMPLATE_ID, UNPRIVILEGED_USER_ID, true); assertNotNull(result); <START> assertTrue(result.size() == 0); <END> }</code><technical_language>check isEmpty()</technical_language>

Target:
public void testGetAllForTemplateWithPermissionsForUnprivilegedUser() { List<VmNetworkInterface> result = dao.getAllForTemplate(TEMPLATE_ID, UNPRIVILEGED_USER_ID, true); assertNotNull(result); assertTrue(result.isEmpty()); }
Source:
<code><START> public long getTableVolume(TableDesc table, Optional<EvalNode> filter) throws UnsupportedException { <END> long totalVolume; try { totalVolume = getRawSplits("", table, filter.orElse(null)).stream() .map(f -> f.getLength()) .filter(size -> size > 0) .reduce(0L, (sum, size) -> sum + size); } catch (TajoException e) { throw new TajoRuntimeException(e); } catch (Throwable ioe) { throw new TajoInternalError(ioe); } return totalVolume; }</code><technical_language>Please remove UnsupportedException</technical_language>

Target:
public long getTableVolume(TableDesc table, Optional<EvalNode> filter) { long totalVolume; try { totalVolume = getRawSplits("", table, filter.orElse(null)).stream() .map(f -> f.getLength()) .filter(size -> size > 0) .reduce(0L, Long::sum); } catch (TajoException e) { throw new TajoRuntimeException(e); } catch (Throwable ioe) { throw new TajoInternalError(ioe); } return totalVolume; }
Source:
<code>public Change perform(IProgressMonitor pm) throws CoreException { pm.beginTask("", 1); try { IQ7NamedElement e = (IQ7NamedElement) getElement(); IQ7NamedElement copy = null; boolean isWorkingCopy = e.isWorkingCopy(); try { copy = isWorkingCopy ? e : e.getWorkingCopy(new NullProgressMonitor()); List<String> references = getContextsReferences(copy); int index = references.indexOf(getContextId()); if (index != -1) { references.remove(index); if (copy instanceof ITestCase) { ((ITestCase) copy).setContexts(references .toArray(new String[references.size()])); } else if (copy instanceof IQ7ProjectMetadata) { NamedElement namedElement = copy.getNamedElement(); if (namedElement instanceof ProjectMetadata) { ProjectMetadata meta = (ProjectMetadata) namedElement; meta.getContexts().clear(); meta.getContexts().addAll(references); } } else { NamedElement namedElement = copy.getNamedElement(); if (namedElement instanceof GroupContext) { GroupContext ctx = (GroupContext) namedElement; ctx.getContextReferences().clear(); ctx.getContextReferences().addAll(references); } } WriteAccessChecker writeAccessChecker = new WriteAccessChecker(); <START> if (writeAccessChecker.makeResourceWritable(copy)) { <END> copy.commitWorkingCopy(true, new NullProgressMonitor()); } return new UndoDeleteContextReferenceChange(getElement(), (IFile) (getElement().getResource()), getContext(), getContextId(), index); } } finally { if (!isWorkingCopy) copy.discardWorkingCopy(); } return null; } finally { pm.done(); } }</code><technical_language>Refactoring ask question in process. questions answered preparation screen</technical_language>

Target:
public Change perform(IProgressMonitor pm) throws CoreException { pm.beginTask("", 1); try { IQ7NamedElement e = (IQ7NamedElement) getElement(); IQ7NamedElement copy = null; boolean isWorkingCopy = e.isWorkingCopy(); try { copy = isWorkingCopy ? e : e.getWorkingCopy(new NullProgressMonitor()); List<String> references = getContextsReferences(copy); int index = references.indexOf(getContextId()); if (index != -1) { references.remove(index); if (copy instanceof ITestCase) { ((ITestCase) copy).setContexts(references .toArray(new String[references.size()])); } else if (copy instanceof IQ7ProjectMetadata) { NamedElement namedElement = copy.getNamedElement(); if (namedElement instanceof ProjectMetadata) { ProjectMetadata meta = (ProjectMetadata) namedElement; meta.getContexts().clear(); meta.getContexts().addAll(references); } } else { NamedElement namedElement = copy.getNamedElement(); if (namedElement instanceof GroupContext) { GroupContext ctx = (GroupContext) namedElement; ctx.getContextReferences().clear(); ctx.getContextReferences().addAll(references); } } copy.commitWorkingCopy(true, new NullProgressMonitor()); return new UndoDeleteContextReferenceChange(getElement(), (IFile) (getElement().getResource()), getContext(), getContextId(), index); } } finally { if (!isWorkingCopy) copy.discardWorkingCopy(); } return null; } finally { pm.done(); } }
Source:
<code>protected void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @Nullable String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; <START> mHandler.runWithScissors(() -> mTimeDetectorStrategy.dump(pw, args), 0); } <END></code><technical_language>meeting discussion, lock blocking call</technical_language>

Target:
protected void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @Nullable String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; synchronized (mStrategyLock) { mTimeDetectorStrategy.dump(pw, args); } }
Source:
<code>private Map<Method, Handler> buildHandlersFor(Class<?> sqlObjectType, SqlObject config) { return handlersCache.computeIfAbsent(sqlObjectType, type -> { final MemberResolver mr = new MemberResolver(typeResolver); final ResolvedType sql_object_type = typeResolver.resolve(sqlObjectType); final ResolvedTypeWithMembers d = mr.resolve(sql_object_type, null, null); final Map<Method, Handler> handlers = new HashMap<>(); for (final ResolvedMethod method : d.getMemberMethods()) { final Method raw_method = method.getRawMember(); <START> if (raw_method.isAnnotationPresent(SqlQuery.class)) { <END> handlers.put(raw_method, new QueryHandler(sqlObjectType, method, ResultReturnThing.forType(method))); } else if (raw_method.isAnnotationPresent(SqlUpdate.class)) { handlers.put(raw_method, new UpdateHandler(sqlObjectType, method)); } else if (raw_method.isAnnotationPresent(SqlBatch.class)) { handlers.put(raw_method, new BatchHandler(sqlObjectType, method)); } else if (raw_method.isAnnotationPresent(SqlCall.class)) { handlers.put(raw_method, new CallHandler(sqlObjectType, method)); } else if (raw_method.isAnnotationPresent(CreateSqlObject.class)) { handlers.put(raw_method, new CreateSqlObjectHandler(raw_method.getReturnType(), config)); } else if (raw_method.isAnnotationPresent(Transaction.class)) { handlers.put(raw_method, new PassThroughTransactionHandler(raw_method, raw_method.getAnnotation(Transaction.class))); } else if (mixinHandlers.containsKey(raw_method)) { handlers.put(raw_method, mixinHandlers.get(raw_method)); } else { handlers.put(raw_method, new PassThroughHandler(raw_method)); } } handlers.putAll(EqualsHandler.handler()); handlers.putAll(ToStringHandler.handler(sqlObjectType.getName())); handlers.putAll(HashCodeHandler.handler()); return handlers; }); }</code><technical_language>meta-annotation drive this dispatch</technical_language>

Target:
private Map<Method, Handler> buildHandlersFor(Class<?> sqlObjectType, SqlObject config) { return handlersCache.computeIfAbsent(sqlObjectType, type -> { final MemberResolver mr = new MemberResolver(typeResolver); final ResolvedType sql_object_type = typeResolver.resolve(sqlObjectType); final ResolvedTypeWithMembers d = mr.resolve(sql_object_type, null, null); final Map<Method, Handler> handlers = new HashMap<>(); for (final ResolvedMethod method : d.getMemberMethods()) { final Method rawMethod = method.getRawMember(); Optional<? extends Class<? extends HandlerFactory>> factoryClass = Stream.of(rawMethod.getAnnotations()) .map(a -> a.annotationType().getAnnotation(SqlMethodAnnotation.class)) .filter(Objects::nonNull) .map(a -> a.value()) .findFirst(); if (factoryClass.isPresent()) { HandlerFactory factory = buildFactory(factoryClass.get()); Handler handler = factory.buildHandler(sqlObjectType, method, config); handlers.put(rawMethod, handler); } else if (mixinHandlers.containsKey(rawMethod)) { handlers.put(rawMethod, mixinHandlers.get(rawMethod)); } else { handlers.put(rawMethod, new PassThroughHandler(rawMethod)); } } handlers.putAll(EqualsHandler.handler()); handlers.putAll(ToStringHandler.handler(sqlObjectType.getName())); handlers.putAll(HashCodeHandler.handler()); return handlers; }); }
Source:
<code><START> public ControlledProcessStateService getService() { <END> return service; }</code><technical_language>I of this package I this remain package protected</technical_language>

Target:
ControlledProcessStateService getService() { return service; }
Source:
<code>public Optional<Alert> get(final UUID identifier, final Organization organization) { assertIsOpen(); LOGGER.debug() <START> .setMessage("Getting alert") <END> .addData("identifier", identifier) .log(); return Optional.empty(); }</code><technical_language>I this is item. Add organization relevant log statements</technical_language>

Target:
public Optional<Alert> get(final UUID identifier, final Organization organization) { assertIsOpen(); LOGGER.debug() .setMessage("Getting alert") .addData("identifier", identifier) .addData("organization", organization) .log(); return Optional.empty(); }
Source:
<code>public Set<File> getAll() { Set<File> files = new HashSet<>(); if (base.exists()) { for (File low : base.listFiles()) { for (File high: low.listFiles()) { for (File file : high.listFiles()) { <START> files.add(file); <END> } } } } return files; }</code><technical_language>check for null adding</technical_language>

Target:
public Set<File> getAll() { Set<File> files = new HashSet<>(); if (base.exists()) { for (File low : Files.list(base)) { for (File high: Files.list(low)) { for (File file : Files.list(high)) { files.add(file); } } } } return files; }
Source:
<code>protected Object getFieldValue(ITmfEvent event, String field) { Object value = null; if (ITmfEvent.EVENT_FIELD_CONTENT.equals(field)) { value = event.getContent().toString(); } else if (ITmfEvent.EVENT_FIELD_TYPE.equals(field)) { value = event.getType().getName(); } else if (ITmfEvent.EVENT_FIELD_TIMESTAMP.equals(field)) { value = event.getTimestamp().toString(); } else if (ITmfEvent.EVENT_FIELD_SOURCE.equals(field)) { value = event.getSource(); } else if (ITmfEvent.EVENT_FIELD_REFERENCE.equals(field)) { value = event.getReference(); } else { if (field == null) { return null; } ITmfEventField eventField; if <START> (field.equals(EMPTY_STRING) || <END> field.charAt(0) != SLASH) { eventField = event.getContent().getField(field); } else { String[] array = getPathArray(field); eventField = event.getContent().getSubField(array); } if (eventField != null) { value = eventField.getValue(); } } return value; }</code><technical_language>isEmpty()</technical_language>

Target:
protected Object getFieldValue(ITmfEvent event, String field) { Object value = null; if (ITmfEvent.EVENT_FIELD_CONTENT.equals(field)) { value = event.getContent().toString(); } else if (ITmfEvent.EVENT_FIELD_TYPE.equals(field)) { value = event.getType().getName(); } else if (ITmfEvent.EVENT_FIELD_TIMESTAMP.equals(field)) { value = event.getTimestamp().toString(); } else if (ITmfEvent.EVENT_FIELD_SOURCE.equals(field)) { value = event.getSource(); } else if (ITmfEvent.EVENT_FIELD_REFERENCE.equals(field)) { value = event.getReference(); } else { if (field == null) { return null; } ITmfEventField eventField; if (field.isEmpty() || field.charAt(0) != SLASH) { eventField = event.getContent().getField(field); } else { String[] array = getPathArray(field); eventField = event.getContent().getSubField(array); } if (eventField != null) { value = eventField.getValue(); } } return value; }
Source:
<code>public void validate() throws Exception { JenkinsConfig c = jenkins.getConfigPage(); c.configure(); c.numExecutors.set(16); FormValidation formValidation = c.numExecutors.getFormValidation(); assertThat(formValidation, silent()); c.numExecutors.set(-16); formValidation = c.numExecutors.getFormValidation(); <START> assertThat(formValidation, reports(Kind.ERROR, "Not a non-negative number")); <END> }</code><technical_language>change? provide support for LTS latest? @olivergondza is LTS job more</technical_language>

Target:
public void validate() throws Exception { JenkinsConfig c = jenkins.getConfigPage(); c.configure(); c.numExecutors.set(16); FormValidation formValidation = c.numExecutors.getFormValidation(); assertThat(formValidation, silent()); c.numExecutors.set(-16); formValidation = c.numExecutors.getFormValidation(); String errorMessage = jenkins.getVersion().isNewerThan(new VersionNumber("2.104"))? "Not a non-negative number" : "Not an integer"; assertThat(formValidation, reports(Kind.ERROR, errorMessage)); }
Source:
<code>public static String checkPrefixBeforeAppend(final String checkValue, final String checkPrefix) { final String tempValue = checkValue.toLowerCase(); final String tempPrefix = checkPrefix.toLowerCase(); <START> if(tempValue.indexOf(tempPrefix) == -1){ <END> return MessageFormat.format("{0}{1}", checkPrefix, checkValue); } else { return checkValue; } }</code><technical_language>startsWith instead of indexOf. indexOf return position if communityId is defined 67i8urn:oid</technical_language>

Target:
public static String checkPrefixBeforeAppend(final String checkValue, final String checkPrefix) { final String tempValue = checkValue.trim().toLowerCase(); final String tempPrefix = checkPrefix.toLowerCase(); if(!tempValue.startsWith(tempPrefix)){ return MessageFormat.format("{0}{1}", checkPrefix, checkValue); } else { return checkValue; } }
Source:
<code>public T build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException { try (InputStream input = provider.open(checkNotNull(path))) { final JsonNode node = mapper.readTree(yamlFactory.createParser(input)); if (node == null){ throw ConfigurationParsingException <START> .builder("Configuration file must not be empty") <END> .build(path); } return build(node, path); } catch (YAMLException e) { ConfigurationParsingException.Builder builder = ConfigurationParsingException .builder("Malformed YAML") .setCause(e) .setDetail(e.getMessage()); if (e instanceof MarkedYAMLException) { builder.setLocation(((MarkedYAMLException) e).getProblemMark()); } throw builder.build(path); } }</code><technical_language>ConfigurationSourceProvider necessarily a file-based backend for configuration, some remote network location a database, message misleading. change message "Configuration $path empty" more generic in actual location configuration lives more specific in error message itself</technical_language>

Target:
public T build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException { try (InputStream input = provider.open(checkNotNull(path))) { final JsonNode node = mapper.readTree(yamlFactory.createParser(input)); if (node == null){ throw ConfigurationParsingException .builder("Configuration at " + path + " must not be empty") .build(path); } return build(node, path); } catch (YAMLException e) { ConfigurationParsingException.Builder builder = ConfigurationParsingException .builder("Malformed YAML") .setCause(e) .setDetail(e.getMessage()); if (e instanceof MarkedYAMLException) { builder.setLocation(((MarkedYAMLException) e).getProblemMark()); } throw builder.build(path); } }
Source:
<code>public UserResource toResource(UserDto user) { UserResource userResource = instantiateResource(user); <START> if (representation != UserResourceRepresentation.MINIMAL || user.getPrivateData().isFetchable()) <END> { addSelfLink(userResource); } if (representation.includeGeneralContent.apply(user)) { addGeneralLinks(userResource); } if (representation.includeOwnUserNumNotConfirmedContent.apply(user)) { addOwnUserNumNotConfirmedLinks(user, userResource); } if (representation.includeOwnUserNumConfirmedContent.apply(user)) { addOwnUserNumConfirmedLinks(userResource); } return userResource; }</code><technical_language>leave link out if representation is minimal? other I understand, part ||</technical_language>

Target:
public UserResource toResource(UserDto user) { UserResource userResource = instantiateResource(user); if (user.getPrivateData().isFetchable()) { addSelfLink(userResource); } if (representation.includeGeneralContent.apply(user)) { addGeneralLinks(userResource); } if (representation.includeOwnUserNumNotConfirmedContent.apply(user)) { addOwnUserNumNotConfirmedLinks(user, userResource); } if (representation.includeOwnUserNumConfirmedContent.apply(user)) { addOwnUserNumConfirmedLinks(userResource); } return userResource; }
Source:
<code>public static double distance(int px, int py, int x1, int y1, int x2, int y2) { double length2 = distance2(x1, y1, x2, y2); if (length2 == 0) { return Math.sqrt(distance2(px, py, x1, y1)); } <START> double t = ((px - x1) * (x2 - x1) + (py - y1) * (y2 - y1)) / length2; <END> if (t <= 0.0) { return Math.sqrt(distance2(px, py, x1, y1)); } if (t >= 1.0) { return Math.sqrt(distance2(px, py, x2, y2)); } int x = (int) (x1 + t * (x2 - x1)); int y = (int) (y1 + t * (y2 - y1)); return Math.sqrt(distance2(px, py, x, y)); }</code><technical_language>name other t? t</technical_language>

Target:
public static double distance(int px, int py, int x1, int y1, int x2, int y2) { double length2 = distance2(x1, y1, x2, y2); if (length2 == 0) { return Math.sqrt(distance2(px, py, x1, y1)); } double r = ((px - x1) * (x2 - x1) + (py - y1) * (y2 - y1)) / length2; if (r <= 0.0) { return Math.sqrt(distance2(px, py, x1, y1)); } if (r >= 1.0) { return Math.sqrt(distance2(px, py, x2, y2)); } int x = (int) (x1 + r * (x2 - x1)); int y = (int) (y1 + r * (y2 - y1)); return Math.sqrt(distance2(px, py, x, y)); }
Source:
<code>protected void onHandleIntent(Intent intent) { try { ArrayList<String> eventsExtras = intent.getExtras().getStringArrayList(EXTRA_EVENTS); if (eventsExtras != null && eventsExtras.size() > 0) { handleSendEvents(eventsExtras); } else { <START> SwrveLogger.e(LOG_TAG, "SwrveWakefulService: Unknown intent received (extras: " + intent.getExtras().get(EXTRA_EVENTS) + ")."); <END> } } catch (Exception ex) { SwrveLogger.e(LOG_TAG, "SwrveWakefulService exception (intent: " + intent + ") :", ex); } finally { SwrveWakefulReceiver.completeWakefulIntent(intent); } }</code><technical_language>+1: intent.getExtras() is nullable, check <LINK_0></technical_language>

Target:
protected void onHandleIntent(Intent intent) { try { ArrayList<String> eventsExtras = intent.getExtras().getStringArrayList(EXTRA_EVENTS); if (eventsExtras != null && eventsExtras.size() > 0) { handleSendEvents(eventsExtras); } else { SwrveLogger.e(LOG_TAG, "SwrveWakefulService: Unknown intent received (extras: " + intent.getExtras() + ")."); } } catch (Exception ex) { SwrveLogger.e(LOG_TAG, "SwrveWakefulService exception (intent: " + intent + ") :", ex); } finally { SwrveWakefulReceiver.completeWakefulIntent(intent); } }
Source:
<code>public void push(FlowStackElement flowStackElement) { if (innerStack.size() >= MAX_DEPTH) { StringBuilder messageBuilder = new StringBuilder(); <START> messageBuilder.append("Too many child contexts nested. ") <END> .append(lineSeparator()) .append(toString()); throw new EventContextDeepNestingException(messageBuilder.toString()); } innerStack.push(flowStackElement); }</code><technical_language>"Too nested child context."</technical_language>

Target:
public void push(FlowStackElement flowStackElement) { if (innerStack.size() >= MAX_DEPTH) { StringBuilder messageBuilder = new StringBuilder(); messageBuilder.append("Too many nested child contexts.") .append(lineSeparator()) .append(toString()); throw new EventContextDeepNestingException(messageBuilder.toString()); } innerStack.push(flowStackElement); }