auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void removeConnection(String connectionId) { <START> connectionIdToPoolManager.get(connectionId).removeConnection(connectionId); <END> connectionIdToPoolManager.remove(connectionId); }</code><technical_language>minor: This in line connectionIdToPoolManager.remove(connectionId).removeConnection(connectionId);</technical_language>

Target:
public void removeConnection(String connectionId) { if (!isOpen) { throw new IllegalStateException("Connection Manager is closed"); } HostPortPoolManager hostPortPoolManager = connectionIdToPoolManager.remove(connectionId); if (hostPortPoolManager == null) { throw new IllegalArgumentException("Attempt to remove an invalid connection id"); } totalManagedConnectionsCount--; hostPortPoolManager.removeConnection(connectionId); }
Source:
<code>public static boolean isJobUsingRuntimeLineage(IProcess process) { RuntimeLineageManager runtimeLineageManager = new RuntimeLineageManager(); if (runtimeLineageManager.getDynamicFields().isEmpty()) { <START> runtimeLineageManager.load(); <END> } return runtimeLineageManager.isUseRuntimeLineageAll() || runtimeLineageManager.isRuntimeLineageSetting(process.getId(), process.getVersion()); }</code><technical_language>if isUseRuntimeLineageAll is true , need load all</technical_language>

Target:
public static boolean isJobUsingRuntimeLineage(IProcess process) { boolean isSupport = isStandardJob(process) && !ProcessUtils.isTestContainer(process) && !isGuessSchemaJob(process); if (!isSupport) { return false; } RuntimeLineageManager runtimeLineageManager = new RuntimeLineageManager(); if (runtimeLineageManager.isUseRuntimeLineageAll()) { return true; } if (runtimeLineageManager.getSelectedJobIds().isEmpty()) { runtimeLineageManager.load(); } return runtimeLineageManager.isRuntimeLineageSetting(process.getId()); }
Source:
<code>protected void performDefaults() { fgChangeSet.clear(); fSwitchLaunch.loadDefault(); fSwitchSuspend.loadDefault(); PerspectiveManager pm = DebugUIPlugin.getDefault().getPerspectiveManager(); ILaunchConfigurationType type = null; Set<Set<String>> modes = null; for (TreeItem item : fTree.getItems()) { type = (ILaunchConfigurationType) item.getData(); modes = type.getSupportedModeCombinations(); for (Set<String> modeset : modes) { fgChangeSet.add(new PerspectiveChange(type, null, modeset, pm.getDefaultLaunchPerspective(type, null, modeset))); } for (Object delegate2 : fTreeViewer.getFilteredChildren(type)) { <START> ILaunchDelegate delegate = (ILaunchDelegate) delegate2; <END> modes = new HashSet<>(delegate.getModes()); for (Set<String> modeset : modes) { fgChangeSet.add(new PerspectiveChange(type, delegate, modeset, pm.getDefaultLaunchPerspective(type, delegate, modeset))); } } } if(fTree.getItemCount() > 0) { TreeItem item = fTree.getItem(0); fTreeViewer.setSelection(new StructuredSelection(item.getData())); fTreeViewer.expandToLevel(item.getData(), 1); } super.performDefaults(); }</code><technical_language>obsolete loopvar</technical_language>

Target:
protected void performDefaults() { fgChangeSet.clear(); fSwitchLaunch.loadDefault(); fSwitchSuspend.loadDefault(); PerspectiveManager pm = DebugUIPlugin.getDefault().getPerspectiveManager(); for (TreeItem item : fTree.getItems()) { ILaunchConfigurationType type = (ILaunchConfigurationType) item.getData(); for (Set<String> modeset : type.getSupportedModeCombinations()) { fgChangeSet.add(new PerspectiveChange(type, null, modeset, pm.getDefaultLaunchPerspective(type, null, modeset))); } for (Object child : fTreeViewer.getFilteredChildren(type)) { ILaunchDelegate delegate = (ILaunchDelegate) child; for (Set<String> modeset : new HashSet<>(delegate.getModes())) { fgChangeSet.add(new PerspectiveChange(type, delegate, modeset, pm.getDefaultLaunchPerspective(type, delegate, modeset))); } } } if(fTree.getItemCount() > 0) { TreeItem item = fTree.getItem(0); fTreeViewer.setSelection(new StructuredSelection(item.getData())); fTreeViewer.expandToLevel(item.getData(), 1); } super.performDefaults(); }
Source:
<code>private static int insertQuotesIfAbsent(@NotNull InsertionContext context, int startOffset, int tailOffset) { int insertedQuotesCount = 0; Editor editor = context.getEditor(); Document document = editor.getDocument(); context.commitDocument(); CharSequence fileText = document.getCharsSequence(); if (!alreadyHasQuote(fileText, startOffset - 1)) { document.insertString(startOffset, QUOTA); context.commitDocument(); insertedQuotesCount++; tailOffset++; } if (!alreadyHasQuote(fileText, tailOffset)) { document.insertString(tailOffset, QUOTA); insertedQuotesCount++; } <START> return insertedQuotesCount; <END> }</code><technical_language>Formatting</technical_language>

Target:
private static int insertQuotesIfAbsent(@NotNull InsertionContext context, int startOffset, int tailOffset) { int insertedQuotesCount = 0; Document document = context.getEditor().getDocument(); CharSequence fileText = document.getCharsSequence(); if (!alreadyHasQuote(fileText, startOffset - 1)) { context.commitDocument(); document.insertString(startOffset, QUOTA); insertedQuotesCount++; tailOffset++; } if (!alreadyHasQuote(fileText, tailOffset)) { context.commitDocument(); document.insertString(tailOffset, QUOTA); insertedQuotesCount++; } return insertedQuotesCount; }
Source:
<code>public Single<List<U>> getCached() { <START> return Observable.fromIterable(() -> cache.keySet().iterator()) <END> .map(cache::get) .toList(); }</code><technical_language>Observable.fromIterable(cache.keySet())</technical_language>

Target:
public Single<List<U>> getCached() { return Observable.fromIterable(cache.keySet()) .map(cache::get) .toList(); }
Source:
<code>@Override public Call<List<String>> getServiceNames() { String queryStr = String.format("SHOW TAG VALUES FROM \"%s\" WITH KEY = \"service_name\"", this.storage.measurement()); Query query = new Query(queryStr, this.storage.measurement()); <START> QueryResult result = this.storage.get().query(query); <END> throw new UnsupportedOperationException(); }</code><technical_language>ps proceed, get practice, continue this blocking transform. Ex get service names query result a list. return Call.create(thatList). This helps get of logic needs be, allows start implementing tests. A future move async invocation build progress this independently</technical_language>

Target:
@Override public Call<List<String>> getServiceNames() { String q = String.format("SHOW TAG VALUES FROM \"%s\".\"%s\" WITH KEY IN (\"local_service_name\",\"remote_service_name\")", this.storage.retentionPolicy(), this.storage.measurement()); Query query = new Query(q, this.storage.database()); QueryResult response = this.storage.get().query(query); if (response.hasError()){ throw new RuntimeException(response.getError()); } List<String> services = new ArrayList<>(); List<QueryResult.Result> results = response.getResults(); if (results != null) { for (QueryResult.Result result : results) { if (result != null && result.getSeries() != null) { for (QueryResult.Series series : result.getSeries()) { for (List<Object> values : series.getValues()) { services.add(values.get(1).toString()); } } } } } return Call.create(services); }
Source:
<code>public boolean isPullSuccessIndicated() { if (isErrorIndicated() || getStatus() == null) { return false; } return (getStatus().contains("Download complete") || getStatus().contains("Image is up to date") <START> || getStatus().contains("Downloaded newer image") <END> || getStatus().contains("this image was pulled from a legacy registry")); }</code><technical_language>Please extract messages public static final</technical_language>

Target:
public boolean isPullSuccessIndicated() { if (isErrorIndicated() || getStatus() == null) { return false; } return (getStatus().contains(DOWNLOAD_COMPLETE) || getStatus().contains(IMAGE_UP_TO_DATE) || getStatus().contains(DOWNLOADED_NEWER_IMAGE) || getStatus().contains(LEGACY_REGISTRY)); }
Source:
<code>public void testBasicOperation() throws Exception { URI fullPathKey = rest.fullPathKey(KEY_A); String initialXML = "<hey>ho</hey>"; HttpResponse insert = rest.put(fullPathKey, initialXML, "application/octet-stream"); assertEquals(0, insert.getEntity().getContentLength()); HttpResponse get = rest.get(fullPathKey, initialXML); <START> assertEquals("application/octet-stream;charset=UTF-8", get.getHeaders("Content-Type")[0].getValue()); <END> rest.delete(fullPathKey); rest.get(fullPathKey, HttpStatus.SC_NOT_FOUND); rest.put(fullPathKey, initialXML, "application/octet-stream"); rest.get(fullPathKey, initialXML); rest.delete(rest.fullPathKey(null)); rest.get(fullPathKey, HttpStatus.SC_NOT_FOUND); ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oo = new ObjectOutputStream(bout); oo.writeObject(new TestSerializable("CONTENT")); oo.flush(); byte[] byteData = bout.toByteArray(); rest.put(fullPathKey, byteData, "application/octet-stream"); HttpResponse resp = rest.getWithoutClose(fullPathKey); ObjectInputStream oin = new ObjectInputStream(resp.getEntity().getContent()); TestSerializable ts = (TestSerializable) oin.readObject(); EntityUtils.consume(resp.getEntity()); assertEquals("CONTENT", ts.getContent()); }</code><technical_language>binary payloads a charset. is adding</technical_language>

Target:
public void testBasicOperation() throws Exception { URI fullPathKey = rest.fullPathKey(KEY_A); String initialXML = "<hey>ho</hey>"; HttpResponse insert = rest.put(fullPathKey, initialXML, "application/octet-stream"); assertEquals(0, insert.getEntity().getContentLength()); HttpResponse get = rest.get(fullPathKey, initialXML); assertEquals("application/octet-stream", get.getHeaders("Content-Type")[0].getValue()); rest.delete(fullPathKey); rest.get(fullPathKey, HttpStatus.SC_NOT_FOUND); rest.put(fullPathKey, initialXML, "application/octet-stream"); rest.get(fullPathKey, initialXML); rest.delete(rest.fullPathKey(null)); rest.get(fullPathKey, HttpStatus.SC_NOT_FOUND); ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oo = new ObjectOutputStream(bout); oo.writeObject(new TestSerializable("CONTENT")); oo.flush(); byte[] byteData = bout.toByteArray(); rest.put(fullPathKey, byteData, "application/octet-stream"); HttpResponse resp = rest.getWithoutClose(fullPathKey); ObjectInputStream oin = new ObjectInputStream(resp.getEntity().getContent()); TestSerializable ts = (TestSerializable) oin.readObject(); EntityUtils.consume(resp.getEntity()); assertEquals("CONTENT", ts.getContent()); }
Source:
<code>private GenericUrl( String scheme, String host, int port, String path, String fragment, String query, String userInfo, boolean verbatim) { this.scheme = scheme.toLowerCase(Locale.US); this.host = host; this.port = port; this.pathParts = toPathParts(path, verbatim); this.verbatim = verbatim; if (verbatim) { <START> this.fragment = fragment != null ? fragment : null; <END> if (query != null) { UrlEncodedParser.parse(query, this, false); } this.userInfo = userInfo != null ? userInfo : null; } else { this.fragment = fragment != null ? CharEscapers.decodeUri(fragment) : null; if (query != null) { UrlEncodedParser.parse(query, this); } this.userInfo = userInfo != null ? CharEscapers.decodeUri(userInfo) : null; } }</code><technical_language>this.fragment = fragment, need for ternary ? operator</technical_language>

Target:
private GenericUrl( String scheme, String host, int port, String path, String fragment, String query, String userInfo, boolean verbatim) { this.scheme = scheme.toLowerCase(Locale.US); this.host = host; this.port = port; this.pathParts = toPathParts(path, verbatim); this.verbatim = verbatim; if (verbatim) { this.fragment = fragment; if (query != null) { UrlEncodedParser.parse(query, this, false); } this.userInfo = userInfo; } else { this.fragment = fragment != null ? CharEscapers.decodeUri(fragment) : null; if (query != null) { UrlEncodedParser.parse(query, this); } this.userInfo = userInfo != null ? CharEscapers.decodeUri(userInfo) : null; } }
Source:
<code>private int calculateIndex(int seq) { if (s_l == -1) { s_l = seq; return seq; } int v = ROC; if (s_l < 0x7fff) if (seq - s_l > 0x7fff) v = (int) ((ROC - 1) & 0xffff_ffffL); else if (s_l - 0xffff > seq) v = (int) ((ROC + 1) & 0xffff_ffffL ); if (v == ROC && seq > s_l) s_l = seq; else if (v == ((ROC + 1) & 0xffff_ffffL)) { s_l = seq; ROC = v; } <START> return seq + v * 0xffff; <END> }</code><technical_language>this work correctly</technical_language>

Target:
private int calculateIndex(int seq) { if (s_l == -1) { s_l = seq; return seq; } int v = ROC; if (s_l < 0x8000) if (seq - s_l > 0x8000) v = (int) ((ROC - 1) & 0xffff_ffffL); else if (s_l - 0x1_0000 > seq) v = (int) ((ROC + 1) & 0xffff_ffffL ); if (v == ROC && seq > s_l) s_l = seq; else if (v == ((ROC + 1) & 0xffff_ffffL)) { s_l = seq; ROC = v; } return seq + v * 0x1_0000; }
Source:
<code>public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException { if (bytes == null) { <START> return 0; <END> } try { if (isDebugEnabled()) { debugCode("setBytes(" + pos + ", " + quoteBytes(bytes) + ", " + offset + ", " + len + ");"); } checkEditable(); if (pos != 1) { throw DbException.getInvalidValueException("pos", pos); } completeWrite(conn.createBlob(new ByteArrayInputStream(bytes, offset, len), -1)); return (int) value.getPrecision(); } catch (Exception e) { throw logAndConvert(e); } }</code><technical_language>I setBytes(1, null, 0, 1), setBytes(1, null, 1, 0), etc. throw some exception (NPE other) instead of returning 0 a problem</technical_language>

Target:
public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException { if (bytes == null) { throw new NullPointerException(); } try { if (isDebugEnabled()) { debugCode("setBytes(" + pos + ", " + quoteBytes(bytes) + ", " + offset + ", " + len + ");"); } checkEditable(); if (pos != 1) { throw DbException.getInvalidValueException("pos", pos); } completeWrite(conn.createBlob(new ByteArrayInputStream(bytes, offset, len), -1)); return (int) value.getPrecision(); } catch (Exception e) { throw logAndConvert(e); } }
Source:
<code><START> public void fire(Project.NameKey project, String ref, <END> ObjectId oldObjectId, ObjectId newObjectId) { Event event = new Event(project, ref, oldObjectId.name(), newObjectId.name()); for (GitReferenceUpdatedListener l : listeners) { l.onGitReferenceUpdated(event); } }</code><technical_language>cleaner accept a RefUpdate object here, instead of 3 parameters? of callers of this form values a RefUpdate</technical_language>

Target:
public void fire(Project.NameKey project, String ref, ObjectId oldObjectId, ObjectId newObjectId) { ObjectId old = oldObjectId != null ? oldObjectId : ObjectId.zeroId(); Event event = new Event(project, ref, old.name(), newObjectId.name()); for (GitReferenceUpdatedListener l : listeners) { l.onGitReferenceUpdated(event); } }
Source:
<code>public void bindTo(MeterRegistry registry) { messages = Counter.builder("runtime_log_messages") .baseUnit("message") .description("number of sent messages to runtime log") .register(registry); bytes = Counter.builder("runtime_log_bytes") .baseUnit("byte") .description("number of sent bytes to runtime log") .register(registry); eventService.subscribe( (e) -> { messages.increment(); <START> bytes.increment(e.getText().getBytes().length); <END> }, RuntimeLogEvent.class); }</code><technical_language>This is default locale converting bytes. if is a big problem changes of locale rare control, still.</technical_language>

Target:
public void bindTo(MeterRegistry registry) { messages = Counter.builder("runtime_log_messages") .baseUnit("message") .description("number of sent messages to runtime log") .register(registry); bytes = Counter.builder("runtime_log_bytes") .baseUnit("byte") .description("number of sent bytes to runtime log") .register(registry); eventService.subscribe( (e) -> { messages.increment(); bytes.increment(e.getText().getBytes(StandardCharsets.UTF_8).length); }, RuntimeLogEvent.class); }
Source:
<code>public void update(ImageStorageDomainMap entity) { <START> getCallsHandler().executeModification("Updateimage_storage_domain_map", <END> getCustomMapSqlParameterSource().addValue("image_id", entity.getImageId()).addValue("storage_domain_id", entity.getStorageDomainId()) .addValue("quota_id", entity.getQuotaId()) .addValue("disk_profile_id", entity.getDiskProfileId())); }</code><technical_language>is this relevant patch</technical_language>

Target:
public void update(ImageStorageDomainMap entity) { throw new UnsupportedOperationException(); }
Source:
<code>public CompletionStage<Boolean> reload() { if (!primaryConfigLoader.supportsReloading() && !fallbackConfigLoader.supportsReloading()) { return CompletableFutures.failedFuture( new UnsupportedOperationException( "Reloading is not supported (this is a composite config, " + "and neither the primary nor the fallback are reloadable)")); } else if (!primaryConfigLoader.supportsReloading()) { return fallbackConfigLoader.reload(); } else if (!fallbackConfigLoader.supportsReloading()) { return primaryConfigLoader.reload(); } else { <START> return fallbackConfigLoader <END> .reload() .thenCompose( fallbackChanged -> primaryConfigLoader .reload() .thenApply(primaryChanged -> primaryChanged || fallbackChanged)); } }</code><technical_language>is a specific reason for this order of reloading? ( I fallback first, primary) - double-check: thenCompose execute if fallback reload() fail, right? - log if error while reloading? (for example this: <LINK_0></technical_language>

Target:
public CompletionStage<Boolean> reload() { if (!primaryConfigLoader.supportsReloading() && !fallbackConfigLoader.supportsReloading()) { return CompletableFutures.failedFuture( new UnsupportedOperationException( "Reloading is not supported (this is a composite config, " + "and neither the primary nor the fallback are reloadable)")); } else if (!primaryConfigLoader.supportsReloading()) { return fallbackConfigLoader.reload(); } else if (!fallbackConfigLoader.supportsReloading()) { return primaryConfigLoader.reload(); } else { CompletionStage<Boolean> primaryFuture = primaryConfigLoader.reload(); CompletionStage<Boolean> fallbackFuture = fallbackConfigLoader.reload(); CompletableFuture<Boolean> compositeFuture = new CompletableFuture<>(); primaryFuture.whenComplete( (primaryChanged, primaryError) -> fallbackFuture.whenComplete( (fallbackChanged, fallbackError) -> { if (primaryError == null && fallbackError == null) { compositeFuture.complete(primaryChanged || fallbackChanged); } else if (fallbackError == null) { compositeFuture.completeExceptionally(primaryError); } else if (primaryError == null) { compositeFuture.completeExceptionally(fallbackError); } else { primaryError.addSuppressed(fallbackError); compositeFuture.completeExceptionally(primaryError); } })); return compositeFuture; } }
Source:
<code>public String toString() { return Objects.toStringHelper(this) .add("LevelName", this.worldInfo.getWorldName()) <START> .add("DimensionId:", this.provider.getDimensionId()) <END> .add("DimensionType", this.worldInfo.getTerrainType().getWorldTypeName()) .toString(); }</code><technical_language>dimensionId, ToStringHelper automatically formats uppercase keys odd</technical_language>

Target:
public String toString() { return Objects.toStringHelper(this) .add("LevelName", this.worldInfo.getWorldName()) .add("DimensionId", this.provider.getDimensionType()) .add("DimensionType", this.worldInfo.getTerrainType().getWorldTypeName()) .toString(); }
Source:
<code>protected void initialize() { super.initialize(); List<Server> servers = api.serverApi().getAllServers(); <START> assertNotNull(servers, "At least one server is required to run drives test."); <END> Server server = Iterables.getFirst(servers, null); assertNotNull(server); this.serverId = server.id(); List<Image> images = api.imageApi().getAllImages(); assertNotNull(images, "At least one image is required to run drives test."); Image image = Iterables.getFirst(images, null); assertNotNull(image); this.imageId = image.id(); }</code><technical_language>Remove this assertion, server api returns null. fallback empty list. In jclouds try avoid returning null lists, this is a pattern apply rest of code</technical_language>

Target:
protected void initialize() { super.initialize(); List<Server> servers = api.serverApi().getAllServers(); assertFalse(servers.isEmpty(), "At least one server is required to run drives test."); Server server = Iterables.getFirst(servers, null); assertNotNull(server); this.serverId = server.id(); List<Image> images = api.imageApi().getAllImages(); assertFalse(images.isEmpty(), "At least one image is required to run drives test."); Image image = Iterables.getFirst(images, null); assertNotNull(image); this.imageId = image.id(); }
Source:
<code>public static Value from(ChangedLines changedLines, Config cfg) { int n = changedLines.deletions + changedLines.insertions; int <START> largeChangeTreshold = <END> cfg.getInt("change", "largeChange", 500); if (n < largeChangeTreshold / 4) { return XS; } else if (n < largeChangeTreshold / 2) { return S; } else if (n < largeChangeTreshold) { return M; } else if (n < largeChangeTreshold * 2) { return L; } else { return XL; } }</code><technical_language>Threshold</technical_language>

Target:
public static Value from(ChangedLines changedLines, Config cfg) { int n = changedLines.deletions + changedLines.insertions; int largeChangeThreshold = cfg.getInt("change", "largeChange", 500); if (n < largeChangeThreshold / 4) { return XS; } else if (n < largeChangeThreshold / 2) { return S; } else if (n < largeChangeThreshold) { return M; } else if (n < largeChangeThreshold * 2) { return L; } else { return XL; } }
Source:
<code>public void setUp() { <START> cqlClient = mock(CqlClient.class); <END> }</code><technical_language>forget shutdown executors</technical_language>

Target:
public void setUp() { cqlFuturesCombiner = new DefaultCqlFuturesCombiner(MoreExecutors.newDirectExecutorService()); asyncCellLoader = AsyncCellLoader.create(cqlClient, cqlFuturesCombiner, KEYSPACE); }
Source:
<code>public ArrayList<Pojo> getResults(String query) { query = StringNormalizer.normalize(query); ArrayList<Pojo> results = new ArrayList<>(); query = query.replaceAll("-", " "); int relevance; int matchPositionStart; int matchPositionEnd; String contactNameNormalized; String phoneNormalized; final String queryWithSpace = " " + query; for (ContactPojo contact : pojos) { relevance = 0; contactNameNormalized = contact.nameNormalized; <START> phoneNormalized = contact.phone.replaceAll("[-.(): ]","");; <END> matchPositionStart = 0; matchPositionEnd = 0; if (contactNameNormalized.startsWith(query)) { relevance = 50; matchPositionEnd = matchPositionStart + query.length(); } else if ((matchPositionStart = contactNameNormalized.indexOf(queryWithSpace)) > -1) { relevance = 40; matchPositionEnd = matchPositionStart + queryWithSpace.length(); } else if (query.length()>2) { matchPositionStart = 0; matchPositionEnd = 0; if (phoneNormalized.startsWith(query)) { relevance = 10; } else if (phoneNormalized.indexOf(query) > -1) { relevance = 5; } } if (relevance > 0) { relevance += contact.timesContacted; if (contact.starred) relevance += 30; if (contact.homeNumber) relevance -= 1; contact.setDisplayNameHighlightRegion(matchPositionStart, matchPositionEnd); contact.relevance = relevance; results.add(contact); if (results.size() > 50) { break; } } } return results; }</code><technical_language>for performance reason, compute this normalizedPhone LoadContacts instead, regexp slow devices lots of contacts ;)</technical_language>

Target:
public ArrayList<Pojo> getResults(String query) { query = StringNormalizer.normalize(query); ArrayList<Pojo> results = new ArrayList<>(); query = query.replaceAll("-", " "); int relevance; int matchPositionStart; int matchPositionEnd; String contactNameNormalized; final String queryWithSpace = " " + query; for (ContactPojo contact : pojos) { relevance = 0; contactNameNormalized = contact.nameNormalized; matchPositionStart = 0; matchPositionEnd = 0; if (contactNameNormalized.startsWith(query)) { relevance = 50; matchPositionEnd = matchPositionStart + query.length(); } else if ((matchPositionStart = contactNameNormalized.indexOf(queryWithSpace)) > -1) { relevance = 40; matchPositionEnd = matchPositionStart + queryWithSpace.length(); } else if (query.length()>2) { matchPositionStart = 0; matchPositionEnd = 0; if (contact.phoneSimplified.startsWith(query)) { relevance = 10; } else if (contact.phoneSimplified.indexOf(query) > -1) { relevance = 5; } } if (relevance > 0) { relevance += contact.timesContacted; if (contact.starred) relevance += 30; if (contact.homeNumber) relevance -= 1; contact.setDisplayNameHighlightRegion(matchPositionStart, matchPositionEnd); contact.relevance = relevance; results.add(contact); if (results.size() > 50) { break; } } } return results; }
Source:
<code>public String saveOrUpdate(@Valid @ModelAttribute StateDTO stateDTO, BindingResult result) throws ObjectNotFoundException { if (result.hasErrors()) { throw new IllegalArgumentException(); } <START> validateIdsBeforeExecuteSaveOrUpdate(stateDTO.getCandidateId(), stateDTO.getChannel().getId(), <END> stateDTO.getPosition().getId()); stateDTO.setStateType("newstate"); stateDTO.setStateIndex(0); ApplicationDTO applicationDTO = ApplicationDTO.builder() .creationDate(new Date()) .candidateId(stateDTO.getCandidateId()) .positionId(stateDTO.getPosition().getId()) .channelId(stateDTO.getChannel().getId()) .build(); applicationsService.saveApplicaton(applicationDTO, stateDTO); return "redirect:/secure/candidate/" + stateDTO.getCandidateId(); }</code><technical_language>service layer check existence of a id</technical_language>

Target:
public String saveOrUpdate(@Valid @ModelAttribute StateDTO stateDTO, BindingResult result) { if (!result.hasErrors()) { stateDTO.setStateType("newstate"); stateDTO.setStateIndex(0); ApplicationDTO applicationDTO = ApplicationDTO.builder() .creationDate(new Date()) .candidateId(stateDTO.getCandidateId()) .positionId(stateDTO.getPosition().getId()) .channelId(stateDTO.getChannel().getId()) .build(); applicationsService.saveApplicaton(applicationDTO, stateDTO); } return "redirect:/secure/candidate/" + stateDTO.getCandidateId(); }
Source:
<code>private void loadFunctionNamespaceManager(File file) throws Exception { String functionNamespaceManagerId = getNameWithoutExtension(file.getName()); <START> log.info("-- Loading function namespace managers from %s --", file); <END> Map<String, String> properties = new HashMap<>(loadProperties(file)); String functionNamespaceManagerName = properties.remove("function-namespace-manager.name"); checkState(functionNamespaceManagerName != null, "Function namespace configuration %s does not contain function-namespace-manager.name", file.getAbsoluteFile()); String functionNamespaces = properties.remove("serving-namespaces"); checkState(functionNamespaces != null, "Function namespace configuration %s does not contain serving-namespaces", file.getAbsoluteFile()); functionManager.loadFunctionNamespaceManager(functionNamespaceManagerName, functionNamespaceManagerId, SPLITTER.splitToList(functionNamespaces), properties); log.info("-- Added function namespaces [%s] using function namespace manager [%s] --", functionNamespaces, functionNamespaceManagerId); }</code><technical_language>1 function namespace manager right? remove "s" "managers"</technical_language>

Target:
private void loadFunctionNamespaceManager(File file) throws Exception { String functionNamespaceManagerId = getNameWithoutExtension(file.getName()); log.info("-- Loading function namespace manager from %s --", file); Map<String, String> properties = new HashMap<>(loadProperties(file)); String functionNamespaceManagerName = properties.remove("function-namespace-manager.name"); checkState(functionNamespaceManagerName != null, "Function namespace configuration %s does not contain function-namespace-manager.name", file.getAbsoluteFile()); String functionNamespaces = properties.remove("serving-namespaces"); checkState(functionNamespaces != null, "Function namespace configuration %s does not contain serving-namespaces", file.getAbsoluteFile()); functionManager.loadFunctionNamespaceManager(functionNamespaceManagerName, functionNamespaceManagerId, SPLITTER.splitToList(functionNamespaces), properties); log.info("-- Added function namespaces [%s] using function namespace manager [%s] --", functionNamespaces, functionNamespaceManagerId); }
Source:
<code>private static void buildRequest(GitHubRequest request, HttpURLConnection connection) throws IOException { for (Map.Entry<String, String> e : request.headers().entrySet()) { String v = e.getValue(); if (v != null) connection.setRequestProperty(e.getKey(), v); } connection.setRequestProperty("Accept-Encoding", "gzip"); if (request.inBody()) { connection.setDoOutput(true); Object body = request.body(); if (body instanceof InputStream) { try (InputStream stream = (InputStream) body) { connection.setRequestProperty("Content-type", defaultString(request.contentType(), "application/x-www-form-urlencoded")); byte[] bytes = new byte[32768]; int read; while ((read = stream.read(bytes)) != -1) { connection.getOutputStream().write(bytes, 0, read); } } } else { connection.setRequestProperty("Content-type", defaultString(request.contentType(), "application/json")); <START> if (body == null) { <END> Map<String, Object> json = new HashMap<>(); for (GitHubRequest.Entry e : request.args()) { json.put(e.key, e.value); } body = json; } getMappingObjectWriter().writeValue(connection.getOutputStream(), body); } } }</code><technical_language>Do unit tests include null null scenarios</technical_language>

Target:
private static void buildRequest(GitHubRequest request, HttpURLConnection connection) throws IOException { for (Map.Entry<String, String> e : request.headers().entrySet()) { String v = e.getValue(); if (v != null) connection.setRequestProperty(e.getKey(), v); } connection.setRequestProperty("Accept-Encoding", "gzip"); if (request.inBody()) { connection.setDoOutput(true); try (InputStream body = request.body()) { if (body != null) { connection.setRequestProperty("Content-type", defaultString(request.contentType(), "application/x-www-form-urlencoded")); byte[] bytes = new byte[32768]; int read; while ((read = body.read(bytes)) != -1) { connection.getOutputStream().write(bytes, 0, read); } } else { connection.setRequestProperty("Content-type", defaultString(request.contentType(), "application/json")); Map<String, Object> json = new HashMap<>(); for (GitHubRequest.Entry e : request.args()) { json.put(e.key, e.value); } getMappingObjectWriter().writeValue(connection.getOutputStream(), json); } } } }
Source:
<code>public URL getFileLink(Path path) throws IOException { String value = String.format("%s/view/head%s", url, path.getValue()); if (LOGGER.isLoggable(Level.FINE)) { <START> LOGGER.fine("FileLink URL: " + value); <END> } return new URL(value); }</code><technical_language>I if is helpful FINE level. DEBUG</technical_language>

Target:
public URL getFileLink(Path path) throws IOException { String value = String.format("%s/view/head%s", url, path.getValue()); if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest("FileLink URL: " + value); } return new URL(value); }
Source:
<code>private static String doc(TypeInfo type) { <START> return null; END> }</code><technical_language>this return null</technical_language>

Target:
private static String doc(TypeInfo type) { if (type instanceof StructTypeInfo) { return null; } return "Converted from '" + String.valueOf(type) + "'"; }
Source:
<code>public void visitEnd() { for (final Jump j : jumps) { final Instruction target = LabelInfo.getInstruction(j.target); final int sourceOpcode = j.source.getNode().getOpcode(); if ((sourceOpcode == Opcodes.LOOKUPSWITCH || sourceOpcode == Opcodes.TABLESWITCH) <START> && ignored.contains(target.getNode())) { <END> continue; } target.setPredecessor(j.source, j.branch); } for (final CoveredProbe p : coveredProbes) { p.instruction.setCovered(p.branch); } for (final Instruction i : instructions) { final AbstractInsnNode m = i.getNode(); final AbstractInsnNode r = findRepresentative(m); if (r != m) { ignored.add(m); nodeToInstruction.get(r).merge(i); } } coverage.ensureCapacity(firstLine, lastLine); for (final Instruction i : instructions) { if (ignored.contains(i.getNode())) { continue; } final int total = i.getBranches(); final int covered = i.getCoveredBranches(); final ICounter instrCounter = covered == 0 ? CounterImpl.COUNTER_1_0 : CounterImpl.COUNTER_0_1; final ICounter branchCounter = total > 1 ? CounterImpl.getInstance(total - covered, covered) : CounterImpl.COUNTER_0_0; coverage.increment(instrCounter, branchCounter, i.getLine()); } coverage.incrementMethodCounter(); }</code><technical_language>unit tests in MethodAnalyzerTest covers this</technical_language>

Target:
public void visitEnd() { for (final Jump j : jumps) { LabelInfo.getInstruction(j.target).setPredecessor(j.source, j.branch); } for (final CoveredProbe p : coveredProbes) { p.instruction.setCovered(p.branch); } for (final Instruction i : instructions) { final AbstractInsnNode m = i.getNode(); final AbstractInsnNode r = findRepresentative(m); if (r != m) { ignored.add(m); nodeToInstruction.get(r).merge(i); } } coverage.ensureCapacity(firstLine, lastLine); for (final Instruction i : instructions) { if (ignored.contains(i.getNode())) { continue; } final int total; final int covered; final Set<AbstractInsnNode> r = replacements.get(i.getNode()); if (r != null) { int cb = 0; for (AbstractInsnNode b : r) { if (nodeToInstruction.get(b).getCoveredBranches() > 0) { cb++; } } total = r.size(); covered = cb; } else { total = i.getBranches(); covered = i.getCoveredBranches(); } final ICounter instrCounter = covered == 0 ? CounterImpl.COUNTER_1_0 : CounterImpl.COUNTER_0_1; final ICounter branchCounter = total > 1 ? CounterImpl.getInstance(total - covered, covered) : CounterImpl.COUNTER_0_0; coverage.increment(instrCounter, branchCounter, i.getLine()); } coverage.incrementMethodCounter(); }
Source:
<code>@Override public void active(boolean active) { <START> cluster().state(active ? ClusterState.ACTIVE : ClusterState.INACTIVE); <END> }</code><technical_language>withhold this change. Ignite.active() IgniteCluster.active() deprecated. OK for map former. If a warning IgniteCluster.active(), way</technical_language>

Target:
@Override public void active(boolean active) { cluster().active(active); }
Source:
<code>public Object getIssueTracker(@CheckForNull String scmUrl) { if (scmUrl != null) { try { String slug = UrlToGitHubSlugConverter.convert(scmUrl); boolean issuesEnabled = GitHubSource.getInstance().issuesEnabled(slug); if (issuesEnabled) { return githubIssueTracker("<LINK_0>" + slug + "/issues"); } } catch (Exception e) { System.out.println("Failed to check if issues are enabled: " + e.getMessage()); } } else { <START> System.out.println("SCM url is empty, defaulting to Jenkins JIRA for issue tracking"); <END> } return JIRA_ISSUE_TRACKER; }</code><technical_language>suggestion System.out.println("SCM url is empty, defaulting Jenkins Jira for issue tracking");</technical_language>

Target:
public Object getIssueTracker(@CheckForNull String scmUrl) { if (scmUrl != null) { try { String slug = UrlToGitHubSlugConverter.convert(scmUrl); boolean issuesEnabled = GitHubSource.getInstance().issuesEnabled(slug); if (issuesEnabled) { return githubIssueTracker("<LINK_0>" + slug + "/issues"); } } catch (Exception e) { System.out.println("Failed to check if issues are enabled: " + e.getMessage()); } } else { System.out.println("SCM url is empty, defaulting to Jenkins Jira for issue tracking"); } return JIRA_ISSUE_TRACKER; }
Source:
<code>public void testRebaseInteractiveSingleFixup() throws Exception { writeTrashFile(FILE1, FILE1); git.add().addFilepattern(FILE1).call(); git.commit().setMessage("Add file1\nnew line").call(); assertTrue(new File(db.getWorkTree(), FILE1).exists()); writeTrashFile("file2", "file2"); git.add().addFilepattern("file2").call(); git.commit().setMessage("Add file2\nnew line").call(); assertTrue(new File(db.getWorkTree(), "file2").exists()); writeTrashFile(FILE1, "blah"); git.add().addFilepattern(FILE1).call(); git.commit().setMessage("updated file1 on master\nnew line").call(); writeTrashFile("file2", "more change"); git.add().addFilepattern("file2").call(); git.commit().setMessage("update file2 on side\nnew line").call(); git.rebase().setUpstream("HEAD~3") .runInteractively(new InteractiveHandler() { public void prepareSteps(List<RebaseTodoLine> steps) { steps.get(1).setAction(Action.FIXUP); } public String modifyCommitMessage(String commit) { fail("No callback to modify commit message expected for single fixup"); return commit; } }).call(); RevWalk walk = new RevWalk(db); ObjectId headId = db.resolve(Constants.HEAD); RevCommit headCommit = walk.parseCommit(headId); assertEquals(headCommit.getFullMessage(), <START> "update file2 on side\nnew line"); <END> ObjectId head1Id = db.resolve(Constants.HEAD + "^1"); RevCommit head1Commit = walk.parseCommit(head1Id); assertEquals("updated file1 on master\nnew line", head1Commit.getFullMessage()); }</code><technical_language>wrong order of parameters</technical_language>

Target:
public void testRebaseInteractiveSingleFixup() throws Exception { writeTrashFile(FILE1, FILE1); git.add().addFilepattern(FILE1).call(); git.commit().setMessage("Add file1\nnew line").call(); assertTrue(new File(db.getWorkTree(), FILE1).exists()); writeTrashFile("file2", "file2"); git.add().addFilepattern("file2").call(); git.commit().setMessage("Add file2\nnew line").call(); assertTrue(new File(db.getWorkTree(), "file2").exists()); writeTrashFile(FILE1, "blah"); git.add().addFilepattern(FILE1).call(); git.commit().setMessage("updated file1 on master\nnew line").call(); writeTrashFile("file2", "more change"); git.add().addFilepattern("file2").call(); git.commit().setMessage("update file2 on master\nnew line").call(); git.rebase().setUpstream("HEAD~3") .runInteractively(new InteractiveHandler() { public void prepareSteps(List<RebaseTodoLine> steps) { steps.get(1).setAction(Action.FIXUP); } public String modifyCommitMessage(String commit) { fail("No callback to modify commit message expected for single fixup"); return commit; } }).call(); RevWalk walk = new RevWalk(db); ObjectId headId = db.resolve(Constants.HEAD); RevCommit headCommit = walk.parseCommit(headId); assertEquals("update file2 on master\nnew line", headCommit.getFullMessage()); ObjectId head1Id = db.resolve(Constants.HEAD + "^1"); RevCommit head1Commit = walk.parseCommit(head1Id); assertEquals("Add file2\nnew line", head1Commit.getFullMessage()); }
Source:
<code>public List<CloudSubnet> chooseSubnetForPrivateEndpoint(Collection<CloudSubnet> subnetMetas, DBStack dbStack, boolean existingNetwork) { NetworkConnector networkConnector = cloudPlatformConnectors.get(new CloudPlatformVariant(dbStack.getCloudPlatform(), dbStack.getPlatformVariant())) .networkConnector(); <START> return networkConnector.chooseSubnetsForPrivateEndpoint(subnetMetas, existingNetwork).getResult(); <END> }</code><technical_language>pls. add a log line</technical_language>

Target:
public List<CloudSubnet> chooseSubnetForPrivateEndpoint(Collection<CloudSubnet> subnetMetas, DBStack dbStack, boolean existingNetwork) { NetworkConnector networkConnector = cloudPlatformConnectors.get(new CloudPlatformVariant(dbStack.getCloudPlatform(), dbStack.getPlatformVariant())) .networkConnector(); List<CloudSubnet> suitableCloudSubnets = networkConnector.chooseSubnetsForPrivateEndpoint(subnetMetas, existingNetwork).getResult(); LOGGER.debug("Subnets suitable for private endpoint: {}", suitableCloudSubnets); return suitableCloudSubnets; }
Source:
<code>public void update(DocumentReference documentReference, Map<String, String> parameters) { try { XWikiContext context = xcontextProvider.get(); XWiki wiki = context.getWiki(); XWikiDocument document = wiki.getDocument(documentReference, context); boolean save = false; String title = parameters.get("title"); if (title != null && !title.equals(document.getTitle())) { document.setTitle(title); save = true; } if (!parentChildConfiguration.isParentChildMechanismEnabled()) { DocumentReference hierarchicalParent = getHierarchicalParent(documentReference); if (!hierarchicalParent.equals(document.getParentReference())) { <START> document.setParentReference(hierarchicalParent.getLocalDocumentReference()); <END> save = true; } } if (save) { wiki.saveDocument(document, "Update document after refactoring.", true, context); this.logger.info("Document has been updated.", documentReference); } } catch (Exception e) { this.logger.error("Failed to update the document after refactoring.", documentReference, e); } }</code><technical_language>simple, parent in a wiki. ideal fix remember relative parent depending if moved this page not</technical_language>

Target:
public void update(DocumentReference documentReference, Map<String, String> parameters) { try { XWikiContext context = xcontextProvider.get(); XWiki wiki = context.getWiki(); XWikiDocument document = wiki.getDocument(documentReference, context); boolean save = false; String title = parameters.get("title"); if (title != null && !title.equals(document.getTitle())) { document.setTitle(title); save = true; } if (!parentChildConfiguration.isParentChildMechanismEnabled()) { DocumentReference hierarchicalParent = getHierarchicalParent(documentReference); String hierarchicalParentSerialized = this.compactEntityReferenceSerializer .serialize(hierarchicalParent, documentReference); EntityReference relativeHierarchicalReference = this.relativeStringEntityReferenceResolver .resolve(hierarchicalParentSerialized, EntityType.DOCUMENT); EntityReference newDocumentParentRef = document.getRelativeParentReference(); if (!relativeHierarchicalReference.equals(newDocumentParentRef)) { document.setParentReference(relativeHierarchicalReference); save = true; } } if (save) { wiki.saveDocument(document, "Update document after refactoring.", true, context); this.logger.info("Document has been updated.", documentReference); } } catch (Exception e) { this.logger.error("Failed to update the document after refactoring.", documentReference, e); } }
Source:
<code>public void testSortedPositionLinks() { JoinFilterFunction filterFunction = (leftAddress, rightPosition, rightPage) -> <START> BIGINT.getLong(TEST_PAGE.getBlock(0), leftAddress) > 4; <END> PositionLinks.FactoryBuilder factoryBuilder = buildSortedPositionLinks(); PositionLinks positionLinks = factoryBuilder.build().create(ImmutableList.of(filterFunction)); assertEquals(positionLinks.start(0, 0, TEST_PAGE), 5); assertEquals(positionLinks.next(5, 0, TEST_PAGE), 6); assertEquals(positionLinks.next(6, 0, TEST_PAGE), -1); assertEquals(positionLinks.start(10, 0, TEST_PAGE), 10); assertEquals(positionLinks.next(10, 0, TEST_PAGE), 11); assertEquals(positionLinks.next(11, 0, TEST_PAGE), 12); assertEquals(positionLinks.next(12, 0, TEST_PAGE), -1); }</code><technical_language>cmt msg typo "embended"</technical_language>

Target:
public void testSortedPositionLinks() { JoinFilterFunction filterFunction = (leftAddress, rightPosition, rightPage) -> BIGINT.getLong(TEST_PAGE.getBlock(0), leftAddress) > 4; PositionLinks.FactoryBuilder factoryBuilder = buildSortedPositionLinks(); PositionLinks positionLinks = factoryBuilder.build().create(ImmutableList.of(filterFunction)); assertEquals(positionLinks.start(0, 0, TEST_PAGE), 5); assertEquals(positionLinks.next(5, 0, TEST_PAGE), 6); assertEquals(positionLinks.next(6, 0, TEST_PAGE), -1); assertEquals(positionLinks.start(7, 0, TEST_PAGE), 7); assertEquals(positionLinks.next(7, 0, TEST_PAGE), -1); assertEquals(positionLinks.start(8, 0, TEST_PAGE), 8); assertEquals(positionLinks.next(8, 0, TEST_PAGE), -1); assertEquals(positionLinks.start(9, 0, TEST_PAGE), 9); assertEquals(positionLinks.next(9, 0, TEST_PAGE), -1); assertEquals(positionLinks.start(10, 0, TEST_PAGE), 10); assertEquals(positionLinks.next(10, 0, TEST_PAGE), 11); assertEquals(positionLinks.next(11, 0, TEST_PAGE), 12); assertEquals(positionLinks.next(12, 0, TEST_PAGE), -1); assertEquals(positionLinks.start(13, 0, TEST_PAGE), 13); assertEquals(positionLinks.next(13, 0, TEST_PAGE), -1); }
Source:
<code>private void lineLengthViolation(int lineNumber, int lineLength, int lengthLimit, Rules rule, String msg) { String lengthVersusLimit = " (" + lineLength + "/" + lengthLimit + ")"; Location location; if (rule == Rules.MAX_LINE_LENGTH) { location = new Location(lineNumber, lengthLimit + 1); <START> } else { <END> location = new Location(lineNumber, lengthLimit); } this.printer.error(rule, Messages.LINE + msg + lengthVersusLimit, location); }</code><technical_language>need this anymore</technical_language>

Target:
private void lineLengthViolation(int lineNumber, int lineLength, int lengthLimit, Rules rule, String msg) { String lengthVersusLimit = " (" + lineLength + "/" + lengthLimit + ")"; Location location = new Location(lineNumber, lengthLimit + 1); this.printer.error(rule, Messages.LINE + msg + lengthVersusLimit, location); }
Source:
<code>public <K, V> RemoteCache<K, V> getCache(boolean forceReturnValue) { <START> return remoteCacheManager.getCache(); <END> }</code><technical_language>RemoteCache interface a getRemoteCacheManager(). However, this method currently returns a RemoteCacheManager (ugh...). opened <LINK_0> rectify this. this is in place, need getCache() methods return a ManagedRemoteCache decorator getRemoteCacheContainer() method returns this instance</technical_language>

Target:
public <K, V> RemoteCache<K, V> getCache(boolean forceReturnValue) { return this.remoteCacheManager.getCache(); }
Source:
<code>public void testExceptionPropagation() throws Exception { try (Ignite srv = startGrid("server")) { try (Ignite client = startGrid("client", getConfiguration("client").setClientMode(true))) { try { client.services().deployClusterSingleton("my-service", new ServiceImpl()); fail("Deployment exception has been expected."); } catch (ServiceDeploymentException ex) { assertTrue(ex.getSuppressed()[0].getMessage().contains("ServiceImpl init exception")); return; <START> } <END> fail("<LINK_0>"); } } }</code><technical_language>fail bellow is called</technical_language>

Target:
public void testExceptionPropagation() throws Exception { try (IgniteEx srv = startGrid("server")) { try (Ignite client = startGrid("client", getConfiguration("client").setClientMode(true))) { final String srvcName = "my-service"; try { client.services().deployClusterSingleton(srvcName, new ServiceImpl()); fail("Deployment exception has been expected."); } catch (ServiceDeploymentException ex) { String errMsg = ex.getSuppressed()[0].getMessage(); assertTrue(errMsg.contains(srv.cluster().localNode().id().toString())); assertTrue(errMsg.contains(srvcName)); Throwable cause = ex.getSuppressed()[0].getCause(); assertTrue(cause.getMessage().contains("ServiceImpl init exception")); } } } }