auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Response getPage(final HttpServletRequest req, final User user, final String filter, final int page, final int perPage, final String orderBy, final OrderDirection direction, final Map<String, Object> extraParams) { final int pageValue = page == 0 ? FIRST_PAGE_INDEX : page; final int perPageValue = perPage == 0 ? perPageDefault : perPage; final int minIndex = getMinIndex(pageValue, perPageValue); final String sanitizefilter = SQLUtil.sanitizeParameter(filter); Collection items = paginator.getItems(user, sanitizefilter, perPageValue, minIndex, orderBy, direction, extraParams); <START> items = items == null ? Collections.emptyList() : items; <END> final long totalRecords = paginator.getTotalRecords(filter); final String linkHeaderValue = getHeaderValue(req.getRequestURL().toString(), sanitizefilter, pageValue, perPageValue, totalRecords, orderBy, direction, extraParams); return Response. ok(new ResponseEntityView(items)) .header(LINK_HEADER_NAME, linkHeaderValue) .header(PAGINATION_PER_PAGE_HEADER_NAME, perPageValue) .header(PAGINATION_CURRENT_PAGE_HEADER_NAME, pageValue) .header(PAGINATION_MAX_LINK_PAGES_HEADER_NAME, nLinks) .header(PAGINATION_TOTAL_ENTRIES_HEADER_NAME, totalRecords) .build(); }</code><technical_language>replace this UtilMethods.isSet(Collection<?> collection) {</technical_language>

Target:
public Response getPage(final HttpServletRequest req, final User user, final String filter, final int page, final int perPage, final String orderBy, final OrderDirection direction, final Map<String, Object> extraParams) { final int pageValue = page == 0 ? FIRST_PAGE_INDEX : page; final int perPageValue = perPage == 0 ? perPageDefault : perPage; final int minIndex = getMinIndex(pageValue, perPageValue); final String sanitizefilter = SQLUtil.sanitizeParameter(filter); Collection items = paginator.getItems(user, sanitizefilter, perPageValue, minIndex, orderBy, direction, extraParams); items = !UtilMethods.isSet(items) ? Collections.emptyList() : items; final long totalRecords = paginator.getTotalRecords(filter); final String linkHeaderValue = getHeaderValue(req.getRequestURL().toString(), sanitizefilter, pageValue, perPageValue, totalRecords, orderBy, direction, extraParams); return Response. ok(new ResponseEntityView(items)) .header(LINK_HEADER_NAME, linkHeaderValue) .header(PAGINATION_PER_PAGE_HEADER_NAME, perPageValue) .header(PAGINATION_CURRENT_PAGE_HEADER_NAME, pageValue) .header(PAGINATION_MAX_LINK_PAGES_HEADER_NAME, nLinks) .header(PAGINATION_TOTAL_ENTRIES_HEADER_NAME, totalRecords) .build(); }
Source:
<code>static void add(StringBuilder sb, String name, long val) { sb.append(name); <START> sb.append(HttpConstants.EQUALS_CHAR); <END> sb.append(val); sb.append(HttpConstants.SEMICOLON_CHAR); sb.append(HttpConstants.SP_CHAR); }</code><technical_language>out a limb, is this more clear a literal? pretty clear a literal: sb.append('='); is clear is a string char is. time I a COMMA constant I a fit code harder read for gain. I continue reaction. feels way</technical_language>

Target:
static void add(StringBuilder sb, String name, long val) { sb.append(name); sb.append('='); sb.append(val); sb.append(';'); sb.append(HttpConstants.SP_CHAR); }
Source:
<code>private JsonObject createAlertForSubject(String journalKey, String subjectName) { String queryString = "{\"startPage\":0,\"filterSubjects\":[],\"unformattedQuery\":\"\",\"query\":\"*:*\"," + "\"eLocationId\":\"\",\"pageSize\":0,\"resultView\":\"\",\"volume\":\"\",\"sortValue\":\"\"," + "\"sortKey\":\"\",\"filterKeyword\":\"\",\"filterArticleTypes\":[]," <START> + "\"filterSubjectsDisjunction\":[],\"filterAuthors\":[],\"filterJournals\":[],\"id\":\"\"}"; <END> JsonObject query = (new Gson()).fromJson(queryString, JsonObject.class); JsonArray filterJournals = query.getAsJsonArray("filterJournals"); filterJournals.add(new JsonPrimitive(journalKey)); JsonArray filterSubjects = query.getAsJsonArray("filterSubjectsDisjunction"); filterSubjects.add(new JsonPrimitive(subjectName)); query.remove("filterJournals"); query.remove("filterSubjects"); query.add("filterJournals", filterJournals); query.add("filterSubjects", filterSubjects); JsonObject alert = new JsonObject(); alert.addProperty("source", ALERT_SOURCE); alert.addProperty("frequency", ALERT_FREQUENCY); alert.addProperty("name", ALERT_NAME); alert.addProperty("query", (new Gson()).toJson(query)); return alert; }</code><technical_language>a class matching this structure, populate instance, Gson encode JSON? And, if destination of JSON is uploaded NED, NED client library provide model class, right</technical_language>

Target:
private Alert createAlertForSubject(String journalKey, String subjectName) { AlertQuery query = new AlertQuery(); query.setFilterJournals(ImmutableList.of(journalKey)); query.setFilterSubjectsDisjunction(ImmutableList.of(subjectName)); Alert alert = new Alert(); alert.setSource(ALERT_SOURCE); alert.setFrequency(ALERT_FREQUENCY); alert.setName(ALERT_NAME); alert.setQuery(gson.toJson(query)); return alert; }
Source:
<code><START> public Document getCustomData() { <END> String encodedData = nativeCustomData(osUser.getNativePtr()); return JniBsonProtocol.decode(encodedData, app.getConfiguration().getDefaultCodecRegistry().get(Document.class)); }</code><technical_language>OsUser for API's sync_user.hpp in ObjectStore. refresh_custom_data is well, there. primary reason for split is Os<X> implements NativeObject interface want in public API, allows greater design flexibility in terms of expose OS API. downside methods "pass-through" though</technical_language>

Target:
public Document getCustomData() { return osUser.getCustomData(); }
Source:
<code>public void failGlobal(Throwable t) { <START> ClusterEntryPointExceptionUtils.tryEnrichClusterEntryPointError(t); <END> if (!isLegacyScheduling()) { internalTaskFailuresListener.notifyGlobalFailure(t); return; } assertRunningInJobMasterMainThread(); while (true) { JobStatus current = state; if (current == JobStatus.FAILING || current == JobStatus.SUSPENDED || current.isGloballyTerminalState()) { return; } else if (transitionState(current, JobStatus.FAILING, t)) { initFailureCause(t); final long globalVersionForRestart = incrementGlobalModVersion(); final CompletableFuture<Void> ongoingSchedulingFuture = schedulingFuture; if (ongoingSchedulingFuture != null) { ongoingSchedulingFuture.cancel(false); } final ConjunctFuture<Void> allTerminal = cancelVerticesAsync(); FutureUtils.assertNoException(allTerminal.handle( (Void ignored, Throwable throwable) -> { if (throwable != null) { transitionState( JobStatus.FAILING, JobStatus.FAILED, new FlinkException("Could not cancel all execution job vertices properly.", throwable)); } else { allVerticesInTerminalState(globalVersionForRestart); } return null; })); return; } } }</code><technical_language>I enrich t t TaskExecutor if a Task failed. In this case, ClusterEntryPoint specific messages sense</technical_language>

Target:
public void failGlobal(Throwable t) { if (!isLegacyScheduling()) { internalTaskFailuresListener.notifyGlobalFailure(t); return; } assertRunningInJobMasterMainThread(); while (true) { JobStatus current = state; if (current == JobStatus.FAILING || current == JobStatus.SUSPENDED || current.isGloballyTerminalState()) { return; } else if (transitionState(current, JobStatus.FAILING, t)) { initFailureCause(t); final long globalVersionForRestart = incrementGlobalModVersion(); final CompletableFuture<Void> ongoingSchedulingFuture = schedulingFuture; if (ongoingSchedulingFuture != null) { ongoingSchedulingFuture.cancel(false); } final ConjunctFuture<Void> allTerminal = cancelVerticesAsync(); FutureUtils.assertNoException(allTerminal.handle( (Void ignored, Throwable throwable) -> { if (throwable != null) { transitionState( JobStatus.FAILING, JobStatus.FAILED, new FlinkException("Could not cancel all execution job vertices properly.", throwable)); } else { allVerticesInTerminalState(globalVersionForRestart); } return null; })); return; } } }
Source:
<code>public boolean addRoute(@NonNull RouteInfo route) { String routeIface = route.getInterface(); if (routeIface != null && !routeIface.equals(mIfaceName)) { throw new IllegalArgumentException( "Route added with non-matching interface: " + routeIface + " vs. " + mIfaceName); } route = routeWithInterface(route); int i = findRouteIndexByDestination(route); if (i <START> < 0) { <END> mRoutes.add(route); return true; } else if (mRoutes.get(i).equals(route)) { return false; } else { mRoutes.set(i, route); return true; } }</code><technical_language>== -1</technical_language>

Target:
public boolean addRoute(@NonNull RouteInfo route) { String routeIface = route.getInterface(); if (routeIface != null && !routeIface.equals(mIfaceName)) { throw new IllegalArgumentException( "Route added with non-matching interface: " + routeIface + " vs. " + mIfaceName); } route = routeWithInterface(route); int i = findRouteIndexByDestination(route); if (i == -1) { mRoutes.add(route); return true; } else if (mRoutes.get(i).equals(route)) { return false; } else { mRoutes.set(i, route); return true; } }
Source:
<code>public String getNoVncUrl() { String noVncUrl = properties.get(NOVNC_URL); if (noVncUrl == null) { <START> String noVncUrlFromCurrentLocation = getWindowsLocationUrl(); <END> noVncUrlFromCurrentLocation += "/rest/novnc"; return noVncUrlFromCurrentLocation; } return noVncUrl; }</code><technical_language>I more work needs done this config, portal port (8080) is correct => 5900</technical_language>

Target:
public String getNoVncUrl() { String noVncUrl = properties.get(NOVNC_URL); if (noVncUrl == null) { String protocol = com.google.gwt.user.client.Window.Location.getProtocol(); String host = com.google.gwt.user.client.Window.Location.getHost(); String noVncUrlFromCurrentLocation = protocol + "://" + host + ":5900/rest/novnc"; noVncUrlFromCurrentLocation.replace(":","\\:"); return noVncUrlFromCurrentLocation; } return noVncUrl; }
Source:
<code>protected void executeCommand() { List<String> macsToRemove = getVmNetworkInterfaceDao().getAllMacsByStoragePool(getStoragePool().getId()); removeNetworks(); List<storage_domains> storageDomains = DbFacade.getInstance().getStorageDomainDao().getAllForStoragePool( getStoragePool().getId()); Collections.sort(storageDomains, new Comparator<storage_domains>() { @Override public int compare(storage_domains o1, storage_domains o2) { return o1.getstorage_domain_type().compareTo(o2.getstorage_domain_type()); } }); if (storageDomains.size() > 0) { if (!getParameters().getForceDelete() && getAllRunningVdssInPool().size() > 0) { if(!regularRemoveStorageDomains(storageDomains)) { setSucceeded(false); return; } } else if (getParameters().getForceDelete()) { forceRemoveStorageDomains(storageDomains); } else { return; } } getStoragePoolDAO().remove(getStoragePool().getId()); setSucceeded(true); <START> <END> if (getSucceeded()) { MacPoolManager.getInstance().freeMacs(macsToRemove); } }</code><technical_language>getSucceeded return true for prior assignment. check macsToRemove contains is empty avoid unnecessary visit in a critical section</technical_language>

Target:
protected void executeCommand() { List<String> macsToRemove = getVmNetworkInterfaceDao().getAllMacsByDataCenter(getStoragePool().getId()); removeNetworks(); List<storage_domains> storageDomains = DbFacade.getInstance().getStorageDomainDao().getAllForStoragePool( getStoragePool().getId()); Collections.sort(storageDomains, new Comparator<storage_domains>() { @Override public int compare(storage_domains o1, storage_domains o2) { return o1.getstorage_domain_type().compareTo(o2.getstorage_domain_type()); } }); if (storageDomains.size() > 0) { if (!getParameters().getForceDelete() && getAllRunningVdssInPool().size() > 0) { if(!regularRemoveStorageDomains(storageDomains)) { setSucceeded(false); return; } } else if (getParameters().getForceDelete()) { forceRemoveStorageDomains(storageDomains); } else { return; } } getStoragePoolDAO().remove(getStoragePool().getId()); setSucceeded(true); if (macsToRemove != null && !macsToRemove.isEmpty()) { MacPoolManager.getInstance().freeMacs(macsToRemove); } }
Source:
<code>public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, EntityPlayer player) { <START> if(!ToolHelper.isBroken(stack) && this instanceof IAoeTool && ((IAoeTool) this).isAoeHarvestTool()) { <END> for(BlockPos extraPos : ((IAoeTool) this).getAOEBlocks(stack, player.worldObj, player, pos)) { breakBlock(stack, player, extraPos, pos); } } return super.onBlockStartBreak(stack, pos, player); }</code><technical_language>Redundant instanceof casts</technical_language>

Target:
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, EntityPlayer player) { if(!ToolHelper.isBroken(stack) && this.isAoeHarvestTool()) { for(BlockPos extraPos : ((IAoeTool) this).getAOEBlocks(stack, player.worldObj, player, pos)) { breakBlock(stack, player, extraPos, pos); } } return super.onBlockStartBreak(stack, pos, player); }
Source:
<code>public static Set<String> unzipPathNames(BeanByteSource source) { Set<String> entryNames = new LinkedHashSet<>(); try (ZipInputStream in = new ZipInputStream(source.openStream())) { ZipEntry entry = in.getNextEntry(); while (entry != null) { if (!entry.isDirectory()) { entryNames.add(entry.getName()); } in.closeEntry(); entry = in.getNextEntry(); } } catch (IOException ex) { throw new UncheckedIOException(ex); } <START> return entryNames; <END> }</code><technical_language>immutable</technical_language>

Target:
public static Set<String> unzipPathNames(BeanByteSource source) { ImmutableSet.Builder<String> entryNames = ImmutableSet.builder(); try (ZipInputStream in = new ZipInputStream(source.openStream())) { ZipEntry entry = in.getNextEntry(); while (entry != null) { if (!entry.isDirectory()) { entryNames.add(entry.getName()); } in.closeEntry(); entry = in.getNextEntry(); } } catch (IOException ex) { throw new UncheckedIOException(ex); } return entryNames.build(); }
Source:
<code><START> public List<LauncherActivityInfo> getActivityList(String packageName, UserHandle user) { <END> final Predicate<LauncherActivityInfo> predicatePackage = info -> info.getComponentName() != null && packageName != null && packageName.equals(info.getComponentName().getPackageName()); return activityList.get(user).stream().filter(predicatePackage).collect(Collectors.toList()); }</code><technical_language>nit: @Implementation protected avoid introducing extra shadow APIs</technical_language>

Target:
protected List<LauncherActivityInfo> getActivityList(String packageName, UserHandle user) { final Predicate<LauncherActivityInfo> predicatePackage = info -> info.getComponentName() != null && packageName != null && packageName.equals(info.getComponentName().getPackageName()); return activityList.get(user).stream().filter(predicatePackage).collect(Collectors.toList()); }
Source:
<code>public void testUserAgentHeaderIsAddedToRequest() throws Exception { MockWebServer server = new MockWebServer(); server.start(); server.enqueue(new MockResponse()); try { CloudantClient client = CloudantClientHelper.newMockWebServerClientBuilder(server) .build(); <START> client.executeRequest(createPost(client.getBaseUri(), null, "application/json")) <END> .responseAsString(); String userAgentHeader = server.takeRequest(10, TimeUnit.SECONDS) .getHeader("User-Agent"); assertNotNull("The User-Agent header should be present on the request", userAgentHeader); assertTrue("The value of the User-Agent header " + userAgentHeader + " on the request" + " should match the format " + userAgentFormat, userAgentHeader.matches(userAgentRegex)); } finally { server.shutdown(); } }</code><technical_language>sorts of invocations trigger findbugs RV_RETURN_VALUE_IGNORED_INFERRED warnings</technical_language>

Target:
public void testUserAgentHeaderIsAddedToRequest() throws Exception { MockWebServer server = new MockWebServer(); server.start(); server.enqueue(new MockResponse()); try { CloudantClient client = CloudantClientHelper.newMockWebServerClientBuilder(server) .build(); String response = client.executeRequest(createPost(client.getBaseUri(), null, "application/json")).responseAsString(); assertTrue("There should be no response body on the mock response", response.isEmpty()); String userAgentHeader = server.takeRequest(10, TimeUnit.SECONDS) .getHeader("User-Agent"); assertNotNull("The User-Agent header should be present on the request", userAgentHeader); assertTrue("The value of the User-Agent header " + userAgentHeader + " on the request" + " should match the format " + userAgentFormat, userAgentHeader.matches(userAgentRegex)); } finally { server.shutdown(); } }
Source:
<code>public String getAnonConfirmation() { <START> return requestConfirmation.getText(); <END> }</code><technical_language>in case add wait.forElementVisible(requestConfirmation) text, avoid network hiccups. metod renamed getAnonConfirmationText()</technical_language>

Target:
public String getAnonConfirmation() { wait.forElementVisible(requestConfirmation); return requestConfirmation.getText(); }
Source:
<code>public synchronized void assignEventProducers(String connectorType, List<DatastreamTask> addedTasks, List<DatastreamTask> removedTasks, boolean customCheckpointing) { Validate.notNull(connectorType); Validate.notEmpty(connectorType); for (DatastreamTask task : removedTasks) { _taskEventProducerMap.get(task).unassignTask(task); _taskEventProducerMap.remove(task); } <START> removedTasks.forEach(t -> _taskEventProducerMap.remove(t)); <END> if (!_producerPool.containsKey(customCheckpointing)) { _producerPool.put(customCheckpointing, createProducers(_poolSize / 2, customCheckpointing)); } List<EventProducer> producers = _producerPool.get(customCheckpointing); for (int addedTaskIndex = 0; addedTaskIndex < addedTasks.size(); addedTaskIndex++) { DatastreamTask task = addedTasks.get(addedTaskIndex); EventProducer eventProducer; if (addedTaskIndex < removedTasks.size()) { eventProducer = ((DatastreamEventProducerImpl) removedTasks.get(addedTaskIndex).getEventProducer()).getEventProducer(); } else { eventProducer = producers.get(_random.nextInt(producers.size())); } assignEventProducerToTask(eventProducer, task); } }</code><technical_language>tasks removed in line 83, right</technical_language>

Target:
public synchronized void assignEventProducers(String connectorType, List<DatastreamTask> addedTasks, List<DatastreamTask> removedTasks, boolean customCheckpointing) { Validate.notNull(connectorType); Validate.notEmpty(connectorType); for (DatastreamTask task : removedTasks) { _taskEventProducerMap.get(task).unassignTask(task); _taskEventProducerMap.remove(task); } if (!_producerPool.containsKey(customCheckpointing)) { _producerPool.put(customCheckpointing, createProducers(_poolSize / 2, customCheckpointing)); } List<EventProducer> producers = _producerPool.get(customCheckpointing); for (int addedTaskIndex = 0; addedTaskIndex < addedTasks.size(); addedTaskIndex++) { DatastreamTask task = addedTasks.get(addedTaskIndex); EventProducer eventProducer; if (addedTaskIndex < removedTasks.size()) { eventProducer = ((DatastreamEventProducerImpl) removedTasks.get(addedTaskIndex).getEventProducer()).getEventProducer(); } else { eventProducer = producers.get(_random.nextInt(producers.size())); } assignEventProducerToTask(eventProducer, task); } }
Source:
<code>private <W extends Widget> void navigate(Request<W> request) { if (locked) { queuedRequests.add(request); return; } redirectDepth++; if (redirectDepth >= MAXIMUM_REDIRECTS) { throw new RuntimeException( "Maximum redirect limit of " + MAXIMUM_REDIRECTS + " reached. " + "Do you have a redirect loop?"); } locked = true; hideCurrentPage(); showPage(request.pageNode, request.state); <START> locked = false; <END> if (queuedRequests.isEmpty()) { redirectDepth = 0; History.newItem(request.state.toString(), false); } else { while (queuedRequests.size() != 0) { navigate(queuedRequests.poll()); } } }</code><technical_language>If a page lifecycle method throws exception, navigation system get stuck in locked state? need a try/finally another test for this</technical_language>

Target:
private <W extends Widget> void navigate(Request<W> request) { if (locked) { queuedRequests.add(request); return; } redirectDepth++; if (redirectDepth >= MAXIMUM_REDIRECTS) { throw new RuntimeException( "Maximum redirect limit of " + MAXIMUM_REDIRECTS + " reached. " + "Do you have a redirect loop?"); } locked = true; try { hideCurrentPage(); showPage(request.pageNode, request.state); } finally { locked = false; } if (queuedRequests.isEmpty()) { redirectDepth = 0; History.newItem(request.state.toString(), false); } else { while (queuedRequests.size() != 0) { navigate(queuedRequests.poll()); } } }
Source:
<code>public BulkReceiveLibraryBackend(LibraryDto dto, Integer quantity, Project project, SampleClass aliquotClass, String defaultSciName, <START> LibraryTemplateService libraryTemplateService) throws IOException { <END> super("libraryReceipt", LibraryDto.class, "Libraries", dto, quantity); if (isDetailedSampleEnabled() && aliquotClass == null) throw new InvalidParameterException("Aliquot class cannot be null"); this.project = project; this.aliquotClass = aliquotClass; this.defaultSciName = defaultSciName; this.libraryTemplateService = libraryTemplateService; newBox = dto.getBox(); }</code><technical_language>![MINOR](<LINK_2> 'Severity: MINOR') Remove declaration of thrown exception 'java.io.IOException', thrown constructor's body. [![rule](<LINK_1>](<LINK_0></technical_language>

Target:
public BulkReceiveLibraryBackend(LibraryDto dto, Integer quantity, Project project, SampleClass aliquotClass, String defaultSciName, LibraryTemplateService libraryTemplateService) { super("libraryReceipt", LibraryDto.class, "Libraries", dto, quantity); if (isDetailedSampleEnabled() && aliquotClass == null) throw new InvalidParameterException("Aliquot class cannot be null"); this.project = project; this.aliquotClass = aliquotClass; this.defaultSciName = defaultSciName; this.libraryTemplateService = libraryTemplateService; newBox = dto.getBox(); }
Source:
<code>public void setUp() { <START> classInstance = new urn_perun_entityless_attribute_def_def_homeDirUmask(); <END> facility = new Facility(); session = mock(PerunSessionImpl.class, RETURNS_DEEP_STUBS); }</code><technical_language>Please fix class name too</technical_language>

Target:
public void setUp() { classInstance = new urn_perun_facility_attribute_def_def_homeDirUmask(); facility = new Facility(); session = mock(PerunSessionImpl.class, RETURNS_DEEP_STUBS); }
Source:
<code>public void testEscapeString() { final String[] testPairs = { "", "", "plain string", "plain string", "string with \"quotes\"", "string with \"quotes\"", "C:\\Program Files\\MyProgram", "C:\\\\Program Files\\\\MyProgram", "string\nwith\nnewlines", "string\\nwith\\nnewlines", <START> "string\nwith\ntabs", "string\\nwith\\ntabs" }; <END> for (int i = 0; i < testPairs.length; i += 2) { assertEquals(ColumnFormatter.escapeString(testPairs[i]), testPairs[i + 1]); } }</code><technical_language>"string\nwith\ntabs" tabs</technical_language>

Target:
public void testEscapeString() { final String[] testPairs = { "", "", "plain string", "plain string", "string with \"quotes\"", "string with \"quotes\"", "C:\\Program Files\\MyProgram", "C:\\\\Program Files\\\\MyProgram", "string\nwith\nnewlines", "string\\nwith\\nnewlines", "string\twith\ttabs", "string\\twith\\ttabs" }; for (int i = 0; i < testPairs.length; i += 2) { assertEquals(ColumnFormatter.escapeString(testPairs[i]), testPairs[i + 1]); } }
Source:
<code><START> private void clearIndexCache(String uri) throws IOException { <END> ExecutionBlockId ebId = ExecutionBlockId.fromString(uri); String queryId = ebId.getQueryId().toString(); String ebSeqId = Integer.toString(ebId.getId()); List<CacheKey> removed = new ArrayList<>(); synchronized (indexReaderCache) { for (Entry<CacheKey, BSTIndexReader> e : indexReaderCache.asMap().entrySet()) { CacheKey key = e.getKey(); if (key.queryId.equals(queryId) && key.ebSeqId.equals(ebSeqId)) { e.getValue().forceClose(); removed.add(e.getKey()); } } indexReaderCache.invalidateAll(removed); } removed.clear(); synchronized (waitForRemove) { for (Entry<CacheKey, BSTIndexReader> e : waitForRemove.entrySet()) { CacheKey key = e.getKey(); if (key.queryId.equals(queryId) && key.ebSeqId.equals(ebSeqId)) { e.getValue().forceClose(); removed.add(e.getKey()); } } for (CacheKey eachKey : removed) { waitForRemove.remove(eachKey); } } }</code><technical_language>add some description</technical_language>

Target:
private void clearIndexCache(String uri) throws IOException, InvalidURLException { String[] tokens = uri.split("="); if (tokens.length != 2 || !tokens[0].equals("ebid")) { throw new IllegalArgumentException("invalid params: " + uri); } ExecutionBlockId ebId = TajoIdUtils.createExecutionBlockId(tokens[1]); String queryId = ebId.getQueryId().toString(); String ebSeqId = Integer.toString(ebId.getId()); List<CacheKey> removed = new ArrayList<>(); synchronized (indexReaderCache) { for (Entry<CacheKey, BSTIndexReader> e : indexReaderCache.asMap().entrySet()) { CacheKey key = e.getKey(); if (key.queryId.equals(queryId) && key.ebSeqId.equals(ebSeqId)) { e.getValue().forceClose(); removed.add(e.getKey()); } } indexReaderCache.invalidateAll(removed); } removed.clear(); synchronized (waitForRemove) { for (Entry<CacheKey, BSTIndexReader> e : waitForRemove.entrySet()) { CacheKey key = e.getKey(); if (key.queryId.equals(queryId) && key.ebSeqId.equals(ebSeqId)) { e.getValue().forceClose(); removed.add(e.getKey()); } } for (CacheKey eachKey : removed) { waitForRemove.remove(eachKey); } } }
Source:
<code>private boolean withinMinMaxRecordTime(final InputRow row) { final boolean beforeMinimumMessageTime = ioConfig.getMinimumMessageTime().isPresent() && ioConfig.getMinimumMessageTime().get().isAfter(row.getTimestamp()); final boolean afterMaximumMessageTime = ioConfig.getMaximumMessageTime().isPresent() && ioConfig.getMaximumMessageTime().get().isBefore(row.getTimestamp()); if (!Intervals.ETERNITY.contains(row.getTimestamp())) { <START> log.error("Encountered row with timestamp that cannot be represented as a long: [%s]", row); <END> return false; } if (log.isDebugEnabled()) { if (beforeMinimumMessageTime) { log.debug( "CurrentTimeStamp[%s] is before MinimumMessageTime[%s]", row.getTimestamp(), ioConfig.getMinimumMessageTime().get() ); } else if (afterMaximumMessageTime) { log.debug( "CurrentTimeStamp[%s] is after MaximumMessageTime[%s]", row.getTimestamp(), ioConfig.getMaximumMessageTime().get() ); } } return !beforeMinimumMessageTime && !afterMaximumMessageTime; }</code><technical_language>This emits logs</technical_language>

Target:
private boolean withinMinMaxRecordTime(final InputRow row) { final boolean beforeMinimumMessageTime = ioConfig.getMinimumMessageTime().isPresent() && ioConfig.getMinimumMessageTime().get().isAfter(row.getTimestamp()); final boolean afterMaximumMessageTime = ioConfig.getMaximumMessageTime().isPresent() && ioConfig.getMaximumMessageTime().get().isBefore(row.getTimestamp()); if (!Intervals.ETERNITY.contains(row.getTimestamp())) { final String errorMsg = StringUtils.format( "Encountered row with timestamp that cannot be represented as a long: [%s]", row ); log.debug(errorMsg); if (tuningConfig.isReportParseExceptions()) { throw new ParseException(errorMsg); } else { return false; } } if (log.isDebugEnabled()) { if (beforeMinimumMessageTime) { log.debug( "CurrentTimeStamp[%s] is before MinimumMessageTime[%s]", row.getTimestamp(), ioConfig.getMinimumMessageTime().get() ); } else if (afterMaximumMessageTime) { log.debug( "CurrentTimeStamp[%s] is after MaximumMessageTime[%s]", row.getTimestamp(), ioConfig.getMaximumMessageTime().get() ); } } return !beforeMinimumMessageTime && !afterMaximumMessageTime; }
Source:
<code><START> public ResponseEntity deleteSynonymCatalog(@PathVariable("tenant") final String tenant, <END> @PathVariable("name") final String name) { final TenantContext context = _contextFactory.getContext(tenant); final SynonymCatalog synonymCatalog = getReferenceDataCatalog(tenant).getSynonymCatalog(name); if (synonymCatalog instanceof TextFileSynonymCatalog) { try { Files.delete(getResourceFile(context, name).toPath()); } catch (final IOException e) { logger.warn("Synonym catalog file could not be deleted.", e); } } _referenceDataDao.removeSynonymCatalog(context, name); return ResponseEntity.noContent().build(); }</code><technical_language>ResponseEntity is a raw type. References generic type ResponseEntity<T> parameterized</technical_language>

Target:
public ResponseEntity<Void> deleteSynonymCatalog(@PathVariable("tenant") final String tenant, @PathVariable("name") final String name) { final TenantContext context = _contextFactory.getContext(tenant); final SynonymCatalog synonymCatalog = getReferenceDataCatalog(tenant).getSynonymCatalog(name); if (synonymCatalog instanceof TextFileSynonymCatalog) { try { Files.delete(getResourceFile(context, name).toPath()); } catch (final IOException e) { logger.warn("Synonym catalog file could not be deleted.", e); } } _referenceDataDao.removeSynonymCatalog(context, name); return ResponseEntity.noContent().build(); }
Source:
<code>public static <K, V> void assertExpirationTimeExistsEventually(final K key, final BackupAccessor<K, V> accessor) { checkInstanceOf(CacheBackupAccessor.class, accessor, "Need to supply a CacheBackupAccessor"); assertTrueEventually(new AssertTask() { @Override public void run() { <START> assertTrueEventually(new AssertTask() { <END> @Override public void run() throws Exception { CacheBackupAccessor<K, V> cacheBackupAccessor = (CacheBackupAccessor<K, V>) accessor; long expirationTime = cacheBackupAccessor.getExpirationTime(key); assertTrue(expirationTime != Long.MAX_VALUE && expirationTime > 0); } }); } }); }</code><technical_language>this assertTrueEventually is another assertTrueEventually. remove inside</technical_language>

Target:
public static <K, V> void assertExpirationTimeExistsEventually(final K key, final BackupAccessor<K, V> accessor) { checkInstanceOf(CacheBackupAccessor.class, accessor, "Need to supply a CacheBackupAccessor"); assertTrueEventually(new AssertTask() { @Override public void run() { CacheBackupAccessor<K, V> cacheBackupAccessor = (CacheBackupAccessor<K, V>) accessor; long expirationTime = cacheBackupAccessor.getExpirationTime(key); assertTrue(expirationTime != Long.MAX_VALUE && expirationTime > 0); } }); }
Source:
<code>public void onAttackRequest(AttackRequest event, EntityRef character, CharacterComponent characterComponent) { if (event.getItem().exists()) { if (!character.equals(event.getItem().getOwner())) { return; } } OnItemUseEvent onItemUseEvent = new OnItemUseEvent(); character.send(onItemUseEvent); if (!onItemUseEvent.isConsumed()) { <START> Vector3i positionVector = targetSystem.getTargetBlockPosition(); <END> if (positionVector == null) { return; } EntityRef targetEntity = blockRegistry.getBlockEntityAt(positionVector); targetEntity.send(new AttackEvent(character, event.getItem())); } }</code><technical_language>recommend simply: Vector3i position =</technical_language>

Target:
public void onAttackRequest(AttackRequest event, EntityRef character, CharacterComponent characterComponent) { if (event.getItem().exists()) { if (!character.equals(event.getItem().getOwner())) { return; } } OnItemUseEvent onItemUseEvent = new OnItemUseEvent(); character.send(onItemUseEvent); if (!onItemUseEvent.isConsumed()) { Vector3i position = targetSystem.getTargetBlockPosition(); if (position == null) { return; } EntityRef targetEntity = blockRegistry.getBlockEntityAt(position); targetEntity.send(new AttackEvent(character, event.getItem())); } }
Source:
<code>private boolean hasAllIndexedColumns(IndexMaintainer indexMaintainer, MultiMutation multiMutation) { Map<byte[], List<Cell>> familyMap = multiMutation.getFamilyCellMap(); for (ColumnReference columnReference : indexMaintainer.getIndexedColumns()) { byte[] family = columnReference.getFamily(); List<Cell> cellList = familyMap.get(family); if (cellList == null) { return false; } boolean has = false; for (Cell cell : cellList) { <START> if (Bytes.compareTo(CellUtil.cloneFamily(cell), family) == 0 && <END> Bytes.compareTo(CellUtil.cloneQualifier(cell), columnReference.getQualifier() ) == 0) { has = true; break; } } if (!has) { return false; } } return true; }</code><technical_language>replaced CellUtil.matchingColumn(Cell, family, qualifier)</technical_language>

Target:
private boolean hasAllIndexedColumns(IndexMaintainer indexMaintainer, MultiMutation multiMutation) { Map<byte[], List<Cell>> familyMap = multiMutation.getFamilyCellMap(); for (ColumnReference columnReference : indexMaintainer.getIndexedColumns()) { byte[] family = columnReference.getFamily(); List<Cell> cellList = familyMap.get(family); if (cellList == null) { return false; } boolean has = false; for (Cell cell : cellList) { if (CellUtil.matchingColumn(cell, family, columnReference.getQualifier())) { has = true; break; } } if (!has) { return false; } } return true; }
Source:
<code>public MenuItem lookForViewMenu(final List<IContributionItem> contItems, final Matcher<String>... matchers) { IWorkbenchPart part = getActivePart(false); final IMenuManager m = ((IViewSite) part.getSite()).getActionBars().getMenuManager(); if (!(m instanceof MenuManager)) { throw new CoreLayerException("No Menu found in active part: " + part.getTitle()); } MenuItem contItem = Display.syncExec(new ResultRunnable<MenuItem>() { @Override public MenuItem run() { MenuItem currentItem = null; Menu currentMenu = ((MenuManager) m).getMenu(); for (Matcher<String> matcher : matchers) { for (MenuItem item : currentMenu.getItems()) { String normalized = item.getText().replace("&", ""); if (matcher.matches(normalized)) { if (item.getMenu() != null) { sendHide(item.getMenu(), true); sendShowUI(item.getMenu()); currentMenu = item.getMenu(); break; } else { <START> currentItem = item; <END> } } } } return currentItem; } }); return contItem; }</code><technical_language>adding a break ? need continue in loop a match</technical_language>

Target:
public MenuItem lookForViewMenu(final List<IContributionItem> contItems, final Matcher<String>... matchers) { IWorkbenchPart part = getActivePart(false); final IMenuManager m = ((IViewSite) part.getSite()).getActionBars().getMenuManager(); if (!(m instanceof MenuManager)) { throw new CoreLayerException("No Menu found in active part: " + part.getTitle()); } MenuItem contItem = Display.syncExec(new ResultRunnable<MenuItem>() { @Override public MenuItem run() { MenuItem currentItem = null; Menu currentMenu = ((MenuManager) m).getMenu(); for (Matcher<String> matcher : matchers) { for (MenuItem item : currentMenu.getItems()) { String normalized = item.getText().replace("&", ""); if (matcher.matches(normalized)) { if (item.getMenu() != null) { sendHide(item.getMenu(), true); sendShowUI(item.getMenu()); currentMenu = item.getMenu(); break; } else { currentItem = item; break; } } } } return currentItem; } }); return contItem; }
Source:
<code><START> public void fail_to_update_plugin_rule_if_name_is_set() { <END> RuleDefinitionDto ruleDto = RuleTesting.newRule(RuleKey.of("squid", "S01")); db.rules().insert(ruleDto); dbSession.commit(); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Not a custom rule"); createForPluginRule(ruleDto.getKey()).setName("New name"); }</code><technical_language>Please inline 2 previous line</technical_language>

Target:
public void fail_to_update_plugin_rule_if_name_is_set() { RuleDefinitionDto ruleDefinition = db.rules().insert(newRule(RuleKey.of("squid", "S01"))); dbSession.commit(); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Not a custom rule"); createForPluginRule(ruleDefinition.getKey()).setName("New name"); }
Source:
<code>public int hashCode() { <START> int result = getId(); <END> id += getFirstName().hashCode(); id += getLastName().hashCode(); return result; }</code><technical_language>Question: specific reason alter hashcode()</technical_language>

Target:
public int hashCode() { int result = getId(); return result; }
Source:
<code>public MVCCEntry wrapEntryForWriting(InvocationContext ctx, Object key, Wrap wrap, boolean skipRead, boolean ignoreOwnership) { if (wrap == Wrap.STORE) { <START> throw new IllegalStateException("wrapDataContainerEntry must create a MVCCEntry"); <END> } if (useRepeatableRead) { wrap = Wrap.WRAP_ALL; } CacheEntry contextEntry = getFromContext(ctx, key); MVCCEntry mvccEntry; if (contextEntry instanceof MVCCEntry) { mvccEntry = assertRepeatableReadEntry(contextEntry); } else if (contextEntry != null) { mvccEntry = createWrappedEntry(key, contextEntry, ctx, skipRead); ctx.putLookedUpEntry(key, mvccEntry); if (trace) log.tracef("Updated context entry %s", contextEntry); } else { InternalCacheEntry ice = getFromContainer(key, ignoreOwnership); if (ice == null && wrap == Wrap.WRAP_NON_NULL) { mvccEntry = null; } else { mvccEntry = createWrappedEntry(key, ice, ctx, skipRead); if (ice == null) { mvccEntry.setCreated(true); } ctx.putLookedUpEntry(key, mvccEntry); if (trace) log.tracef("Updated context entry %s", contextEntry); } } if (mvccEntry != null) { mvccEntry.copyForUpdate(); } return mvccEntry; }</code><technical_language>wrong method name</technical_language>

Target:
public MVCCEntry wrapEntryForWriting(InvocationContext ctx, Object key, Wrap wrap, boolean skipRead, boolean ignoreOwnership) { if (wrap == Wrap.STORE) { throw new IllegalStateException("wrapEntryForWriting must create a MVCCEntry"); } if (useRepeatableRead) { wrap = Wrap.WRAP_ALL; } CacheEntry contextEntry = getFromContext(ctx, key); MVCCEntry mvccEntry; if (contextEntry instanceof MVCCEntry) { mvccEntry = assertRepeatableReadEntry(contextEntry); } else if (contextEntry != null) { mvccEntry = createWrappedEntry(key, contextEntry, ctx, skipRead); ctx.putLookedUpEntry(key, mvccEntry); if (trace) log.tracef("Updated context entry %s", contextEntry); } else { InternalCacheEntry ice = getFromContainer(key, ignoreOwnership); if (ice == null && wrap == Wrap.WRAP_NON_NULL) { mvccEntry = null; } else { mvccEntry = createWrappedEntry(key, ice, ctx, skipRead); if (ice == null) { mvccEntry.setCreated(true); } ctx.putLookedUpEntry(key, mvccEntry); if (trace) log.tracef("Updated context entry %s", mvccEntry); } } if (mvccEntry != null) { mvccEntry.copyForUpdate(); } return mvccEntry; }
Source:
<code>public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> permissionList = new ArrayList<>(); permissionList.add(new <START> PermissionSubject(getParameters().getDev().getVmId(), <END> getParameters().isVm() ? VdcObjectType.VM : VdcObjectType.VmTemplate, getActionType().getActionGroup())); return permissionList; }</code><technical_language>I create a method getVmBaseId() for this. is often</technical_language>

Target:
public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> permissionList = new ArrayList<>(); permissionList.add(new PermissionSubject(getVmBaseId(), getParameters().isVm() ? VdcObjectType.VM : VdcObjectType.VmTemplate, getActionType().getActionGroup())); return permissionList; }
Source:
<code>public void resetAssetPermissions (String assetId, Long languageId) throws DotDataException, PortalException, SystemException, DotSecurityException { HibernateUtil.startTransaction(); try { UserWebAPI userWebAPI = WebAPILocator.getUserWebAPI(); WebContext ctx = WebContextFactory.get(); HttpServletRequest request = ctx.getHttpServletRequest(); User user = userWebAPI.getLoggedInUser(request); boolean respectFrontendRoles = !userWebAPI.isLoggedToBackend(request); PermissionAPI permissionAPI = APILocator.getPermissionAPI(); Permissionable asset = retrievePermissionable(assetId, languageId, user, respectFrontendRoles); permissionAPI.removePermissions(asset); if(asset instanceof Host){ systemEventsAPI.push(SystemEventType.UPDATE_SITE_PERMISSIONS, new Payload(asset, Visibility.GLOBAL, (String) null)); <START> } <END> } catch (DotDataException e) { HibernateUtil.rollbackTransaction(); throw e; } HibernateUtil.commitTransaction(); }</code><technical_language>I is a idea move this code a API if is</technical_language>

Target:
public void resetAssetPermissions (String assetId, Long languageId) throws DotDataException, PortalException, SystemException, DotSecurityException { HibernateUtil.startTransaction(); try { UserWebAPI userWebAPI = WebAPILocator.getUserWebAPI(); WebContext ctx = WebContextFactory.get(); HttpServletRequest request = ctx.getHttpServletRequest(); User user = userWebAPI.getLoggedInUser(request); boolean respectFrontendRoles = !userWebAPI.isLoggedToBackend(request); PermissionAPI permissionAPI = APILocator.getPermissionAPI(); Permissionable asset = retrievePermissionable(assetId, languageId, user, respectFrontendRoles); permissionAPI.removePermissions(asset); } catch (DotDataException e) { HibernateUtil.rollbackTransaction(); throw e; } HibernateUtil.commitTransaction(); }
Source:
<code>public void insertOnDuplicateKeyUpdate_multiple() { SQLInsertClause clause = queryFactory.insertOnDuplicateKeyUpdate(QSurvey.survey, QSurvey.survey.id.eq(2), QSurvey.survey.name.eq("B")); <START> assertEquals("insert into SURVEY\nvalues () on duplicate key update SURVEY.ID = ?, SURVEY.NAME = ?", clause.toString()); <END> }</code><technical_language>is write values expression sql? duplicate key update content_count = values(content_count)</technical_language>

Target:
public void insertOnDuplicateKeyUpdate_multiple() { SQLInsertClause clause = queryFactory.insertOnDuplicateKeyUpdate(QSurvey.survey, SQLExpressions.set(QSurvey.survey.id, 2), SQLExpressions.set(QSurvey.survey.name, "B")); assertEquals("insert into SURVEY\n" + "values () on duplicate key update SURVEY.ID = ?, SURVEY.NAME = ?", clause.toString()); }
Source:
<code>public String submit() throws Exception { ApplicationId applicationId = getYarnClientForSubmit().submitApplication(); if (applicationId != null) { return "Submit succesful, new id is " + applicationId.toString(); } else { <START> return "Failure submitting new application."; <END> } }</code><technical_language>Failures throw exceptions simple return. revisit, for consistency this is atm</technical_language>

Target:
public String submit() throws Exception { ApplicationId applicationId = getYarnClientForSubmit().submitApplication(); if (applicationId != null) { return "Submit succesful, new application id is " + applicationId.toString(); } throw new IllegalArgumentException("Failed to submit new application instance."); }
Source:
<code>private void getStatusCode(HttpWebResponse _response) throws IOException { int statusCode = HttpURLConnection.HTTP_OK; try { statusCode = _connection.getResponseCode(); } catch (IOException ex) { if (Build.VERSION.SDK_INT < 18) { <START> if (ex.getMessage() == "Received authentication challenge is null") { <END> statusCode = HttpURLConnection.HTTP_UNAUTHORIZED; } } else { statusCode = _connection.getResponseCode(); } if (statusCode != HttpURLConnection.HTTP_UNAUTHORIZED) { throw ex; } } _response.setStatusCode(statusCode); Logger.v(TAG, "Statuscode:" + statusCode); }</code><technical_language>This is a specific workaround. create a string constant, named appropriately? E.g. PreSDK18UnauthorizedMessage</technical_language>

Target:
private void getStatusCode(HttpWebResponse _response) throws IOException { int statusCode = HttpURLConnection.HTTP_OK; try { statusCode = _connection.getResponseCode(); } catch (IOException ex) { if (Build.VERSION.SDK_INT < 18) { if (ex.getMessage() == UNAUTHORIZED_ERROR_MESSAGE_PRE18) { statusCode = HttpURLConnection.HTTP_UNAUTHORIZED; } } else { statusCode = _connection.getResponseCode(); } if (statusCode != HttpURLConnection.HTTP_UNAUTHORIZED) { throw ex; } } _response.setStatusCode(statusCode); Logger.v(TAG, "Status code:" + statusCode); }
Source:
<code>public void removeChangeListener(ListenerToken token) { synchronized (lock) { if (token == null || (!(token instanceof ReplicatorChangeListenerToken) && !(token instanceof DocumentReplicatedListenerToken))) throw new IllegalArgumentException(); <START> if(docEndedListenerTokens.remove(token)==true) { <END> setProgressLevel(ReplicatorProgressLevel.OVERALL); } } }</code><technical_language>I this check size instead of result of remove below. Java docEndedListenerTokens.remove(token); if (docEndedListenerTokens.size() == 0) { setProgressLevel(ReplicatorProgressLevel.OVERALL); }</technical_language>

Target:
public void removeChangeListener(ListenerToken token) { synchronized (lock) { if (token == null || (!(token instanceof ReplicatorChangeListenerToken) && !(token instanceof DocumentReplicationListenerToken))) throw new IllegalArgumentException(); changeListenerTokens.remove(token); docEndedListenerTokens.remove(token); if (docEndedListenerTokens.size() == 0) { setProgressLevel(ReplicatorProgressLevel.OVERALL); } } }
Source:
<code>public void releaseClearLockLocalDoesNotReleaseLocksOnPrimaryBucketsWhenMemberIsNotCurrent() { BucketAdvisor bucketAdvisor = mock(BucketAdvisor.class); when(bucketAdvisor.hasPrimary()).thenReturn(true); PartitionedRegionDataStore partitionedRegionDataStore = mock(PartitionedRegionDataStore.class); Set<BucketRegion> buckets = setupBucketRegions(partitionedRegionDataStore, bucketAdvisor); when(partitionedRegion.getDataStore()).thenReturn(partitionedRegionDataStore); InternalDistributedMember member = mock(InternalDistributedMember.class); <START> partitionedRegionClear.obtainClearLockLocal(member); <END> assertThat(partitionedRegionClear.lockForListenerAndClientNotification.getLockRequester()) .isNull(); for (BucketRegion bucketRegion : buckets) { verify(bucketRegion, times(0)).releaseLockLocallyForClear(null); } }</code><technical_language>I this releaseClearLockLocal() instead</technical_language>

Target:
public void releaseClearLockLocalDoesNotReleaseLocksOnPrimaryBucketsWhenMemberIsNotCurrent() { BucketAdvisor bucketAdvisor = mock(BucketAdvisor.class); when(bucketAdvisor.hasPrimary()).thenReturn(true); PartitionedRegionDataStore partitionedRegionDataStore = mock(PartitionedRegionDataStore.class); Set<BucketRegion> buckets = setupBucketRegions(partitionedRegionDataStore, bucketAdvisor); when(partitionedRegion.getDataStore()).thenReturn(partitionedRegionDataStore); InternalDistributedMember member = mock(InternalDistributedMember.class); partitionedRegionClear.releaseClearLockLocal(); assertThat(partitionedRegionClear.lockForListenerAndClientNotification.getLockRequester()) .isNull(); for (BucketRegion bucketRegion : buckets) { verify(bucketRegion, times(0)).releaseLockLocallyForClear(null); } }