auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private FunctionElement(JAXBElement element) { super(element); if (!element.getDeclaredType().equals(FunctionType.class)) { throw new FilterProcessingException( INVALID_INVOCATION + element.getDeclaredType().getName()); } FunctionType functionType = (FunctionType) element.getValue(); this.value = new HashMap<>(); this.value.put("type", "FILTER_FUNCTION"); this.value.put("filterFunctionName", functionType.getName()); this.value.put( "params", <START> functionType <END> .getExpression() .stream() .map(JAXBElement::getValue) .map(LiteralType.class::cast) .map( literalType -> literalType .getContent() .stream() .findFirst() .map( serializable -> { QName qName = literalType.getType(); return QNameMapper.convert(serializable, qName); }) .orElse("")) .collect(Collectors.toList())); }</code><technical_language>Extract creation expression put() call reduce nesting</technical_language>

Target:
private FunctionElement(JAXBElement element) { super(element); if (!element.getDeclaredType().equals(FunctionType.class)) { throw new FilterProcessingException( INVALID_INVOCATION + element.getDeclaredType().getName()); } FunctionType functionType = (FunctionType) element.getValue(); this.value = new HashMap<>(); this.value.put("type", "FILTER_FUNCTION"); this.value.put(XmlModelBuilder.FUNCTION_PROPERTY_NAME, functionType.getName()); this.value.put( XmlModelBuilder.FUNCTION_PROPERTY_PARAMS, createFunctionPropertyParameters(functionType)); }
Source:
<code>public void notify(final IScriptEngine engine, final Script script, final int status) { switch (status) { case SCRIPT_START: case SCRIPT_INJECTION_START: if (fDispatcher != null) { <START> fDispatcher.put(script); <END> } fLastScript = script; break; case ENGINE_END: fFrameToSource.clear(); fLastScript = null; break; default: break; } super.notify(engine, script, status); }</code><technical_language>remove script_end</technical_language>

Target:
public void notify(final IScriptEngine engine, final Script script, final int status) { final IScriptRegistry scriptRegistry = getDispatcher(); switch (status) { case SCRIPT_START: case SCRIPT_INJECTION_START: if (scriptRegistry != null) { scriptRegistry.put(script); } fLastScript = script; break; case SCRIPT_END: break; case ENGINE_END: fFrameToSource.clear(); fLastScript = null; break; default: break; } super.notify(engine, script, status); }
Source:
<code>public int compareTo(Filter other) { <START> if (!this.methodName.equals(other.methodName)) { <END> return this.methodName.compareTo(other.methodName); } else if (!this.className.equals(other.className)) { return this.className.compareTo(other.className); } return 0; }</code><technical_language>Rewrite as: int c = methodName.compareTo(other.methodName); if (c != 0) return c; return className.compareTo(other.className);</technical_language>

Target:
public int compareTo(Filter other) { int c = methodName.compareTo(other.methodName); if (c != 0) { return c; } return className.compareTo(other.className); }
Source:
<code>public Set<Integer> getMembers() { <START> return members; <END> }</code><technical_language>convention is create a new instance if members is null method returns null</technical_language>

Target:
public Collection<CohortMembership> getMembers() { if (members == null) { members = new TreeSet<CohortMembership>(); } return members; }
Source:
<code>public void shouldDoNumericProjectionWithStringBasedQuery() { Party partyHasKeyword = new Party(KEY_PARTY_KEYWORD, "party", "desc is a N1QL keyword", new Date(), 4000000, new Point(500, 500)); partyRepository.save(partyHasKeyword); Optional<Party> p = null; int count = 0; do { try { Thread.sleep(1000); } catch(Exception e){} try { p = partyRepository.findById(partyHasKeyword.getKey()); } catch (DataRetrievalFailureException e) } while ( !p.isPresent() && count++ < 60); <START> long max = partyRepository.findMaxAttendees(); <END> assertEquals(4000000, max); }</code><technical_language>easier scan consistency findMaxAttendees request is implied</technical_language>

Target:
public void shouldDoNumericProjectionWithStringBasedQuery() { Party partyHasKeyword = new Party(KEY_PARTY_KEYWORD, "party", "desc is a N1QL keyword", new Date(), 4000000, new Point(500, 500)); partyRepository.save(partyHasKeyword); long max = partyRepository.findMaxAttendees(); assertEquals(4000000, max); }
Source:
<code>public List<FeedbackResponseAttributes> getViewableFeedbackResponsesForQuestionInSection( FeedbackQuestionAttributes question, String userEmail, UserRole role, String section, SectionDisplayMode sectionDisplayMode) { List<FeedbackResponseAttributes> viewableResponses = new ArrayList<>(); switch (role) { case STUDENT: addNewResponses( viewableResponses, getFeedbackResponsesFromGiverForQuestionInSection( question.getId(), userEmail, section)); if (question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) { addNewResponses( viewableResponses, getFeedbackResponsesForReceiverForQuestionInSection( question.getId(), userEmail, section)); <START> } <END> addNewResponses(viewableResponses, getViewableFeedbackResponsesForStudentForQuestion(question, userEmail)); break; case INSTRUCTOR: if (question.isResponseVisibleTo(FeedbackParticipantType.INSTRUCTORS)) { addNewResponses(viewableResponses, getFeedbackResponsesForQuestionInSection(question.getId(), section, sectionDisplayMode)); } break; default: Assumption.fail("The role of the requesting use has to be Student or Instructor"); break; } return viewableResponses; }</code><technical_language>if I get logic here. is this block (from // Add responses user submitted this line) moved case STUDENT</technical_language>

Target:
public List<FeedbackResponseAttributes> getViewableFeedbackResponsesForQuestionInSection( FeedbackQuestionAttributes question, String userEmail, UserRole role, String section, SectionDisplayMode sectionDisplayMode) { List<FeedbackResponseAttributes> viewableResponses = new ArrayList<>(); switch (role) { case STUDENT: addNewResponses( viewableResponses, getFeedbackResponsesFromGiverForQuestionInSection( question.getId(), userEmail, section)); if (question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) { addNewResponses( viewableResponses, getFeedbackResponsesForReceiverForQuestionInSection( question.getId(), userEmail, section)); } addNewResponses(viewableResponses, getViewableFeedbackResponsesForStudentForQuestion(question, userEmail)); break; case INSTRUCTOR: if (question.isResponseVisibleTo(FeedbackParticipantType.INSTRUCTORS)) { addNewResponses(viewableResponses, getFeedbackResponsesForQuestionInSection(question.getId(), section, sectionDisplayMode)); } if (!question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) { viewableResponses = excludeResponsesWithReceiverEmail(viewableResponses, userEmail); } break; default: Assumption.fail("The role of the requesting use has to be Student or Instructor"); break; } return viewableResponses; }
Source:
<code>public LockRangeDialog(Shell parentShell, TmfXYChartViewer chartViewer) { super(parentShell); <START> this.fChartViewer <END> = chartViewer; }</code><technical_language>remove this</technical_language>

Target:
public LockRangeDialog(Shell parentShell, TmfXYChartViewer chartViewer) { super(parentShell); fChartViewer = chartViewer; }
Source:
<code>public void testNonMethodChainWordcount() throws Exception { TupleCollector<Map<Object, Integer>> collector = new TupleCollector<>(); collector.id = "testNonMethodChainWordcount"; MyStream<String> mystream = new MyStream<>(StreamFactory .fromFolder("./src/test/resources/data")) .flatMap(new Function.FlatMapFunction<String, String>() { @Override public Iterable<String> f(String input) { return Arrays.asList(input.split(" ")); } }); mystream.filterAndMap(new Function.MapFunction<String, String>() { @Override public String f(String input) { return input.replace("word", "newword"); } }, new Function.FilterFunction<String>() { @Override public Boolean f(String input) { return input.startsWith("word"); } <START> }).countByKey().addOperator(collector, collector.inputPort, collector.outputPort).print().runEmbedded(5000); <END> List<Map<Object, Integer>> data = (List<Map<Object, Integer>>)TupleCollector.results.get("testNonMethodChainWordcount"); Assert.assertTrue(data.size() > 1); Assert.assertEquals(expected, data.get(data.size() - 1)); }</code><technical_language>timing dependency is problematic. API run DAG terminate results computed? This of this PR, fixed</technical_language>

Target:
public void testNonMethodChainWordcount() throws Exception { testId = "testNonMethodChainWordcount"; TupleCollector<Map<Object, Integer>> collector = new TupleCollector<>(); collector.id = testId; MyStream<String> mystream = new MyStream<>(StreamFactory .fromFolder("./src/test/resources/data")) .flatMap(new Function.FlatMapFunction<String, String>() { @Override public Iterable<String> f(String input) { return Arrays.asList(input.split(" ")); } }); mystream.myFilterAndMap(new Function.MapFunction<String, String>() { @Override public String f(String input) { return input.replace("word", "newword"); } }, new Function.FilterFunction<String>() { @Override public Boolean f(String input) { return input.startsWith("word"); } }).countByKey().addOperator(collector, collector.inputPort, collector.outputPort).print().runEmbedded(false, 30000, exitCondition); List<Map<Object, Integer>> data = (List<Map<Object, Integer>>)TupleCollector.results.get(testId); Assert.assertTrue(data.size() > 1); Assert.assertEquals(expected, data.get(data.size() - 1)); }
Source:
<code>public void searchShouldReturnAResponseWithOneTransaction_whenFilteringByCardHolderNameFromLedger() { Account account = new Account("123456", TokenPaymentType.CARD); var searchParams = new PaymentSearchParams.Builder() .withCardHolderName("J Doe") .withPageNumber("1") .withDisplaySize("500") .build(); Response response = paymentSearchService.searchLedgerPayments(account, searchParams); JsonAssert.with(response.getEntity().toString()) .assertThat("count", is(1)) .assertThat("total", is(1)) .assertThat("page", is(1)) .assertThat("results", is(collectionWithSize(equalTo(1)))) .assertThat("results[0]", hasKey("amount")) .assertThat("results[0]", hasKey("state")) .assertThat("results[0]", hasKey("reference")) .assertThat("results[0]", hasKey("email")) .assertThat("results[0].card_details.cardholder_name", is("J Doe")) .assertThat("results[0].card_details", hasKey("first_digits_card_number")) .assertThat("results[0].card_details", hasKey("last_digits_card_number")) .assertThat("results[0].state", hasKey("status")) .assertThat("results[0].state", hasKey("finished")) .assertThat("results[0]", hasKey("_links")) .assertThat("_links", hasKey("self")) .assertThat("_links", hasKey("first_page")) .assertThat("_links", hasKey("last_page")) <START> .assertThat("results[0]._links.capture", is(nullValue())) <END> .assertNotDefined("_links.next_page") .assertNotDefined("_links.prev_page"); }</code><technical_language>[minor] This in response Ledger. generate this link. connector. I of this line in this test</technical_language>

Target:
public void searchShouldReturnAResponseWithOneTransaction_whenFilteringByCardHolderNameFromLedger() { Account account = new Account("123456", TokenPaymentType.CARD); var searchParams = new PaymentSearchParams.Builder() .withCardHolderName("J Doe") .withPageNumber("1") .withDisplaySize("500") .build(); Response response = paymentSearchService.searchLedgerPayments(account, searchParams); JsonAssert.with(response.getEntity().toString()) .assertThat("count", is(1)) .assertThat("total", is(1)) .assertThat("page", is(1)) .assertThat("results", is(collectionWithSize(equalTo(1)))) .assertThat("results[0]", hasKey("amount")) .assertThat("results[0]", hasKey("state")) .assertThat("results[0]", hasKey("reference")) .assertThat("results[0]", hasKey("email")) .assertThat("results[0].card_details.cardholder_name", is("J Doe")) .assertThat("results[0].card_details", hasKey("first_digits_card_number")) .assertThat("results[0].card_details", hasKey("last_digits_card_number")) .assertThat("results[0].state", hasKey("status")) .assertThat("results[0].state", hasKey("finished")); }
Source:
<code><START> public boolean execute(BindContext context) { <END> for (BindOperation operation : operations) { log.debug("Starting execute of {}", operation.getClass().getSimpleName()); if (operation.execute(context)) { log.debug("Finished execute of {}", operation.getClass().getSimpleName()); } else { log.error("Skipped chain execute in operation {}", operation.getClass().getSimpleName()); return false; } } return true; }</code><technical_language>method protected (private if isolated in tests)</technical_language>

Target:
private boolean execute(BindContext context) { for (BindOperation operation : operations) { log.debug("Starting execute of {}", operation.getClass().getSimpleName()); if (operation.execute(context)) { log.debug("Finished execute of {}", operation.getClass().getSimpleName()); } else { log.error("Skipped chain execute in operation {}", operation.getClass().getSimpleName()); return false; } } return true; }
Source:
<code>public static List<Element> lockSyncFolder(Project project) { if (!ProjectUtilities.isFromEsiServer(project.getPrimaryProject())) { return Collections.emptyList(); } <START> String folderId = Converters.getIProjectToIdConverter().apply(project.getPrimaryProject()) + "_sync"; <END> Element folder = Converters.getIdToElementConverter().apply(folderId, project); if (folder == null) { return Collections.emptyList(); } ILockProjectService lockService = EsiUtils.getLockService(project); if (lockService == null) { return Collections.emptyList(); } Collection<Element> ownedElements = folder.getOwnedElement(); List<Element> lockedElements = new ArrayList<>(ownedElements.size()); for (Element element : folder.getOwnedElement()) { if (element instanceof com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class && !lockService.isLocked(element) && lockService.canBeLocked(element)) { lockedElements.add(element); } } if (!lockService.lockElements(lockedElements, false, null)) { return Collections.emptyList(); } return lockedElements; }</code><technical_language>Change this MDKConstants.SYNC_SYSML_ID_SUFFIX</technical_language>

Target:
public static List<Element> lockSyncFolder(Project project) { if (!ProjectUtilities.isFromEsiServer(project.getPrimaryProject())) { return Collections.emptyList(); } String folderId = Converters.getIProjectToIdConverter().apply(project.getPrimaryProject()) + MDKConstants.SYNC_SYSML_ID_SUFFIX; Element folder = Converters.getIdToElementConverter().apply(folderId, project); if (folder == null) { return Collections.emptyList(); } ILockProjectService lockService = EsiUtils.getLockService(project); if (lockService == null) { return Collections.emptyList(); } Collection<Element> ownedElements = folder.getOwnedElement(); List<Element> lockedElements = new ArrayList<>(ownedElements.size()); for (Element element : folder.getOwnedElement()) { if (element instanceof com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class && !lockService.isLocked(element) && lockService.canBeLocked(element)) { lockedElements.add(element); } } if (!lockService.lockElements(lockedElements, false, null)) { return Collections.emptyList(); } return lockedElements; }
Source:
<code>private void checkInitialization() { if (!addedEval || initialized) { return; } <START> while (!initialized) { <END> try { initLatch.await(); } catch (final InterruptedException e) { LOG.log(Level.WARNING, "Interrupted while waiting for routing table initialization from driver", e); } } }</code><technical_language>do need initialized variable</technical_language>

Target:
private void checkInitialization() { if (!addedEval) { return; } while (true) { try { initLatch.await(); break; } catch (final InterruptedException e) { LOG.log(Level.WARNING, "Interrupted while waiting for routing table initialization from driver", e); } } }
Source:
<code>public Integer offsetComparator(String offset1, String offset2) { <START> int o1 = Optional.ofNullable(offset1) <END> .filter(Strings::isNullOrEmpty) .map(Integer::parseInt) .orElse(-1); int o2 = Optional.ofNullable(offset2) .filter(Strings::isNullOrEmpty) .map(Integer::parseInt) .orElse(-1); if (o1 == -1 || o2 == -1) { return null; } return Integer.compare(o1, o2); }</code><technical_language>this logic is hard understand. I refer a simple like: if(offset1 == null || offset2 == null) { return null; } else { return Integer.valueOf(offset1).compare(Interger.valueOf(offset2)); }</technical_language>

Target:
public Integer offsetComparator(String offset1, String offset2) { if (offset1 == null || offset2 == null) { return null; } return Integer.compare(Integer.parseInt(offset1), Integer.parseInt(offset2)); }
Source:
<code>public CosemDateTime getDaylightSavingsBegin() { <START> return new CosemDateTime(this.daylightSavingsBegin); <END> }</code><technical_language>CosemDateTime appears immutable, is need return a new object protect internal state</technical_language>

Target:
public CosemDateTime getDaylightSavingsBegin() { return this.daylightSavingsBegin; }
Source:
<code>private boolean shouldExecuteInBatchMode(final RuntimeExecutionMode configuredMode) { final boolean existsUnboundedSource = existsContinuousSource(); <START> if (configuredMode == RuntimeExecutionMode.BATCH && existsUnboundedSource) { <END> throw new IllegalArgumentException( "Detected an UNBOUNDED source with the '" + RuntimeOptions.RUNTIME_MODE.key() + "' set to 'BATCH'. " + "This combination is not allowed, please set the '" + RuntimeOptions.RUNTIME_MODE.key() + "' to STREAMING or AUTOMATIC"); } if (checkNotNull(configuredMode) != RuntimeExecutionMode.AUTOMATIC) { return configuredMode == RuntimeExecutionMode.BATCH; } return !existsUnboundedSource; }</code><technical_language>nit: checkArgument? I undecided myself, IllegalArgumentException IllegalStateException in cases</technical_language>

Target:
private boolean shouldExecuteInBatchMode(final RuntimeExecutionMode configuredMode) { final boolean existsUnboundedSource = existsUnboundedSource(); checkState(configuredMode != RuntimeExecutionMode.BATCH || !existsUnboundedSource, "Detected an UNBOUNDED source with the '" + ExecutionOptions.RUNTIME_MODE.key() + "' set to 'BATCH'. " + "This combination is not allowed, please set the '" + ExecutionOptions.RUNTIME_MODE.key() + "' to STREAMING or AUTOMATIC"); if (checkNotNull(configuredMode) != RuntimeExecutionMode.AUTOMATIC) { return configuredMode == RuntimeExecutionMode.BATCH; } return !existsUnboundedSource; }
Source:
<code>private void nonTransactionalRemoveGroup(String groupName, long explicitFlags) { InvocationContext context = invocationContextFactory.createInvocationContext(false, UNBOUNDED); Map<K, V> keys = internalGetGroup(groupName, explicitFlags, context); long removeFlags = addIgnoreReturnValuesFlag(explicitFlags); for (K key : keys.keySet()) { assertKeyNotNull(key); InvocationContext ctx = singleKeyContextWithImplicitTransaction(); RemoveCommand command = createRemoveCommand(key, removeFlags); <START> checkLockOwner(ctx, command); <END> executeCommandAndCommitIfNeeded(ctx, command); } }</code><technical_language>I a bit confused executeCommandAndCommitIfNeeded(ctx, command) set lock owner executeCommandAndCommitIfNeeded(contextBuilder, command) - please move checkLockOwner former</technical_language>

Target:
private void nonTransactionalRemoveGroup(String groupName, long explicitFlags) { InvocationContext context = invocationContextFactory.createInvocationContext(false, UNBOUNDED); Map<K, V> keys = internalGetGroup(groupName, explicitFlags, context); long removeFlags = addIgnoreReturnValuesFlag(explicitFlags); for (K key : keys.keySet()) { assertKeyNotNull(key); executeCommandAndCommitIfNeeded(contextBuilder, createRemoveCommand(key, removeFlags), 1); } }
Source:
<code>private @NonNull Action[] getRevisionActions(@NonNull SCMRevision revision, String rawName) { Action[] revisionActions = new Action[0]; try { List<Action> actions = source.fetchActions(revision, event, listener); <START> revisionActions = actions.toArray(new Action[0]); <END> } catch (IOException | InterruptedException e) { printStackTrace(e, listener.error("Could not fetch metadata for revision %s of branch %s", revision, rawName)); } return revisionActions; }</code><technical_language>Slight performance enhancement... suggestion revisionActions = actions.toArray(new Action[actions.size()]);</technical_language>

Target:
private Action[] getRevisionActions(@NonNull SCMRevision revision, String rawName) { Action[] revisionActions = new Action[0]; try { List<Action> actions = source.fetchActions(revision, event, listener); revisionActions = actions.toArray(new Action[actions.size()]); } catch (IOException | InterruptedException e) { printStackTrace(e, listener.error("Could not fetch metadata for revision %s of branch %s", revision, rawName)); } return revisionActions; }
Source:
<code>public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException { if (!TimeZoneRulesDataContract.DATA_URI.equals(uri)) { return null; } if (mAssetName == null) { throw new FileNotFoundException(); } if (!mode.equals("r")) { throw new SecurityException("Only read-only access supported."); } Context context = getContext(); try { AssetFileDescriptor fd = context.getAssets().openFd(mAssetName); return fd.getParcelFileDescriptor(); } catch (IOException e) { throw new <START> RuntimeException("Unable <END> to open asset file", e); } }</code><technical_language>throwing FileNotFoundException here? some subclass of RuntimeException, SecurityException</technical_language>

Target:
public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException { if (!TimeZoneRulesDataContract.DATA_URI.equals(uri)) { return null; } if (!"r".equals(mode)) { throw new SecurityException("Only read-only access supported."); } File distroFile = null; try { distroFile = File.createTempFile("distro", null, getContext().getFilesDir()); AssetManager assets = getContext().getAssets(); try (InputStream is = assets.open(TimeZoneDistro.FILE_NAME, ACCESS_STREAMING); FileOutputStream fos = new FileOutputStream(distroFile, false )) { copy(is, fos); } return ParcelFileDescriptor.open(distroFile, ParcelFileDescriptor.MODE_READ_ONLY); } catch (IOException e) { throw new RuntimeException("Unable to copy distro asset file", e); } finally { if (distroFile != null) { distroFile.delete(); } } }
Source:
<code>private static void handleLaunchArguments(String[] args) { Path homePath = null; for (String arg : args) { boolean recognized = true; if (arg.startsWith(USE_SPECIFIED_DIR_AS_HOME)) { homePath = Paths.get(arg.substring(USE_SPECIFIED_DIR_AS_HOME.length())); } else if (arg.equals(USE_CURRENT_DIR_AS_HOME)) { homePath = Paths.get(""); } else if (arg.equals(START_HEADLESS)) { isHeadless = true; crashReportEnabled = false; } else if (arg.equals(NO_SAVE_GAMES)) { writeSaveGamesEnabled = false; } else if (arg.equals(NO_CRASH_REPORT)) { crashReportEnabled = false; } else if (arg.equals(NO_SOUND)) { soundEnabled = false; } else if (arg.equals(LOAD_LAST_GAME)) { loadLastGame = true; } else if(arg.startsWith(SERVER_PORT)) { try { serverPort = Integer.parseInt(arg.substring(SERVER_PORT.length())); } catch (NumberFormatException e) { new TransientConfig().setServerPort(TerasologyConstants.DEFAULT_PORT); System.out.println("Couldn't parse server port. Using default port."); <START> } <END> } else { recognized = false; } System.out.println((recognized ? "Recognized" : "Invalid") + " argument: " + arg); } try { if (homePath != null) { PathManager.getInstance().useOverrideHomePath(homePath); } else { PathManager.getInstance().useDefaultHomePath(); } } catch (IOException e) { if (!isHeadless) { reportException(e); } System.exit(0); } }</code><technical_language>Again, I expert in networking, if I a mistake in writing port number, enough unparseable, I Terasology start report error instead of smoothly switching default port. Also, depending current warning printout speed, swamped subsequent startup log statments, point user realize server port is expects</technical_language>

Target:
private static void handleLaunchArguments(String[] args) { Path homePath = null; for (String arg : args) { boolean recognized = true; if (arg.startsWith(USE_SPECIFIED_DIR_AS_HOME)) { homePath = Paths.get(arg.substring(USE_SPECIFIED_DIR_AS_HOME.length())); } else if (arg.equals(USE_CURRENT_DIR_AS_HOME)) { homePath = Paths.get(""); } else if (arg.equals(START_HEADLESS)) { isHeadless = true; crashReportEnabled = false; } else if (arg.equals(NO_SAVE_GAMES)) { writeSaveGamesEnabled = false; } else if (arg.equals(NO_CRASH_REPORT)) { crashReportEnabled = false; } else if (arg.equals(NO_SOUND)) { soundEnabled = false; } else if (arg.equals(LOAD_LAST_GAME)) { loadLastGame = true; } else if (arg.startsWith(SERVER_PORT)) { try { serverPort = Integer.parseInt(arg.substring(SERVER_PORT.length())); } catch (NumberFormatException e) { reportException(e); } } else { recognized = false; } System.out.println((recognized ? "Recognized" : "Invalid") + " argument: " + arg); } try { if (homePath != null) { PathManager.getInstance().useOverrideHomePath(homePath); } else { PathManager.getInstance().useDefaultHomePath(); } } catch (IOException e) { if (!isHeadless) { reportException(e); } System.exit(0); } }
Source:
<code>public String bannerCreate(@ModelAttribute BannerDto bannerDto, HttpServletRequest request) { String loginName = LoginUserInfo.getLoginName(); bannerService.create(bannerDto, loginName); String ip = RequestIPParser.parse(request); <START> String description = loginName + "在 " + sdf.format(new Date()) +"创建了" +"名称为:" + bannerDto.getName() + "的banner." ; <END> auditLogService.createAuditLog(loginName, loginName, OperationType.BANNER, bannerDto.getName(), description, ip); return "redirect:/banner-manage/list"; }</code><technical_language>aspect</technical_language>

Target:
public String bannerCreate(@ModelAttribute BannerDto bannerDto, HttpServletRequest request) { String loginName = LoginUserInfo.getLoginName(); String ip = RequestIPParser.parse(request); bannerService.create(bannerDto, loginName, ip); return "redirect:/banner-manage/list"; }
Source:
<code>public Iterator<Entry<Key,Value>> iterator() { smi.scanner.setBatchSize(size); smi.scanner.setTimeout(timeOut, TimeUnit.MILLISECONDS); smi.scanner.setBatchTimeout(batchTimeOut, TimeUnit.MILLISECONDS); smi.scanner.setReadaheadThreshold(readaheadThreshold); if (isolated) smi.scanner.enableIsolation(); else smi.scanner.disableIsolation(); smi.samplerConfig = getSamplerConfiguration(); final TreeMap<Integer,IterInfo> tm = new TreeMap<>(); for (IterInfo iterInfo : serverSideIteratorList) { tm.put(iterInfo.getPriority(), iterInfo); } try (SortedKeyValueIterator<Key,Value> skvi = IteratorUtil.loadIterators(smi, tm.values(), serverSideIteratorOptions, new ClientSideIteratorEnvironment( getSamplerConfiguration() != null, getIteratorSamplerConfigurationInternal()), false, null)) { final Set<ByteSequence> colfs = new TreeSet<>(); for (Column c : this.getFetchedColumns()) { colfs.add(new ArrayByteSequence(c.getColumnFamily())); } skvi.seek(range, colfs, true); return new IteratorAdapter(skvi); <START> } catch (Exception e) { <END> throw new RuntimeException(e); } }</code><technical_language>This catch exceptions extend RuntimeException rethrow a exception. undesirable. this is of AutoCloseable. I need do a smarter</technical_language>

Target:
public Iterator<Entry<Key,Value>> iterator() { smi.scanner.setBatchSize(size); smi.scanner.setTimeout(timeOut, TimeUnit.MILLISECONDS); smi.scanner.setBatchTimeout(batchTimeOut, TimeUnit.MILLISECONDS); smi.scanner.setReadaheadThreshold(readaheadThreshold); if (isolated) smi.scanner.enableIsolation(); else smi.scanner.disableIsolation(); smi.samplerConfig = getSamplerConfiguration(); final TreeMap<Integer,IterInfo> tm = new TreeMap<>(); for (IterInfo iterInfo : serverSideIteratorList) { tm.put(iterInfo.getPriority(), iterInfo); } SortedKeyValueIterator<Key,Value> skvi; try { skvi = IteratorUtil.loadIterators(smi, tm.values(), serverSideIteratorOptions, new ClientSideIteratorEnvironment(getSamplerConfiguration() != null, getIteratorSamplerConfigurationInternal()), false, null); } catch (IOException e) { throw new RuntimeException(e); } final Set<ByteSequence> colfs = new TreeSet<>(); for (Column c : this.getFetchedColumns()) { colfs.add(new ArrayByteSequence(c.getColumnFamily())); } try { skvi.seek(range, colfs, true); } catch (IOException e) { throw new RuntimeException(e); } return new IteratorAdapter(skvi); }
Source:
<code>public void setRowData(int start, final List<? extends T> values) { if (values.size() == 1) { addStyleName(HIDE_ONE_ROW_SCROLL); } else { removeStyleName(HIDE_ONE_ROW_SCROLL); } super.setRowData(start, values); <START> updateGridSize(calculateGridHeightOnlyRows(values.size())); <END> }</code><technical_language>In case changing code change to: updateGridSize(calculateGridHeight(values.size()));</technical_language>

Target:
public void setRowData(int start, final List<? extends T> values) { if (values.size() == 1) { addStyleName(HIDE_ONE_ROW_SCROLL); } else { removeStyleName(HIDE_ONE_ROW_SCROLL); } super.setRowData(start, values); updateGridSize(calculateGridHeight(values.size())); }
Source:
<code>private static List<VdcOption> getAllReloadableVdcOptions() { List<VdcOption> list = getVdcOptionDAO().getAll(); List<VdcOption> result = new ArrayList<>(); for (VdcOption option : list) { try { if (isReloadable(option.getoption_name())) { result.add(option); } <START> } catch (NoSuchFieldException e) { <END> log.error("Not refreshing field '{}': does not exist in class {}.", option.getoption_name(), ConfigValues.class.getSimpleName()); } } return result; }</code><technical_language>I move exception handling isReloadable() returning false exception raised</technical_language>

Target:
private static List<VdcOption> getAllReloadableVdcOptions() { List<VdcOption> list = getVdcOptionDAO().getAll(); List<VdcOption> result = new ArrayList<>(); for (VdcOption option : list) { if (isReloadable(option.getoption_name())) { result.add(option); } } return result; }
Source:
<code>public final GHIntArrayList reverse() { final int[] buffer = this.buffer; for (int start = 0, end = size() - 1; start < end; start++, end--) { <START> int tmp = buffer[start]; <END> buffer[start] = buffer[end]; buffer[end] = tmp; } return this; }</code><technical_language>define int of for? if this optimized, I introduced a "bug" String once, I a bit cautious things</technical_language>

Target:
public final GHIntArrayList reverse() { final int[] buffer = this.buffer; int tmp; for (int start = 0, end = size() - 1; start < end; start++, end--) { tmp = buffer[start]; buffer[start] = buffer[end]; buffer[end] = tmp; } return this; }
Source:
<code>protected void releaseInstance(T instance) throws IOException { <START> if(providedVsCount.containsKey(instance)) { <END> AtomicInteger currentCount = providedVsCount.get(instance); if(currentCount.getAndDecrement() == 1) { providedVsCount.remove(instance); } } else { throw new IllegalArgumentException("Given instance of " + instance.getClass().getName() + " is not managed by this provider"); } if(instance instanceof Closeable) { ((Closeable)instance).close(); } }</code><technical_language>purpose of this providedVsCount? close removing</technical_language>

Target:
protected void releaseInstance(T instance) throws IOException { AtomicInteger currentCount = providedVsCount.get(instance); if(currentCount != null) { if(currentCount.decrementAndGet() < 0) { currentCount.incrementAndGet(); throw new IllegalArgumentException("Given instance of " + instance.getClass().getName() + " is not managed by this provider"); } } else { throw new IllegalArgumentException("Given instance of " + instance.getClass().getName() + " is not managed by this provider"); } if(instance instanceof Closeable) { ((Closeable)instance).close(); } }
Source:
<code>public boolean testNull() { <START> if (failNext > 0) { <END> filterIdx++; failNext--; return false; } Filter filter = nextFilter(); if (filter != null) { return processResult(filter.testNull()); } return true; }</code><technical_language>Consider extracting helper method tryConsumeFailedPosition: @Override public boolean testNull() { if (tryConsumeFailedPosition()) { return false; } ... } private boolean tryConsumeFailedPosition() { if (numNextPositionsToFail > 0) { filterIndex++; numNextPositionsToFail--; return true; } return false; }</technical_language>

Target:
public boolean testNull() { if (numNextPositionsToFail > 0) { filterIndex++; numNextPositionsToFail--; return false; } Filter filter = nextFilter(); if (filter != null) { return processResult(filter.testNull()); } return true; }
Source:
<code>public TmfEventTableColumn(ITmfEventAspect<?> aspect) { fAspect = aspect; <START> fAspectDuplicate.add(aspect); <END> }</code><technical_language>put aspects in list (in case, want change name of field), duplicates</technical_language>

Target:
public TmfEventTableColumn(ITmfEventAspect<?> aspect) { fAspects.add(aspect); }
Source:
<code>private void copyContents() { try { File baseDir = new File(buildName, serverName); FileUtils.deleteRecursive(baseDir); final Path path = Paths.get(baseDir.getAbsolutePath()); <START> final Path baseFile = project.getBasedir().toPath().resolve(configDir.getPath()); <END> doCopy(path.resolve(Locations.CONTENT), baseFile.resolve(Locations.CONTENT)); doCopy(path.resolve(Locations.MODULES), baseFile.resolve(Locations.MODULES)); doCopy(path.resolve(Locations.CONFIGURATION), baseFile.resolve(Locations.CONFIGURATION)); doCopy(path.resolve(Locations.SUBSYSTEM_TEMPLATES), baseFile.resolve(Locations.SUBSYSTEM_TEMPLATES)); } catch (IOException e) { throw new RuntimeException(e); } }</code><technical_language>This work. combining directories more result in invalid directory</technical_language>

Target:
private void copyContents() { try { File baseDir = new File(buildName, serverName); FileUtils.deleteRecursive(baseDir); final Path path = Paths.get(baseDir.getAbsolutePath()); final Path baseFile = Paths.get(configDir.getAbsolutePath() + resourcesDir); doCopy(path.resolve(Locations.CONTENT), baseFile.resolve(Locations.CONTENT)); doCopy(path.resolve(Locations.MODULES), baseFile.resolve(Locations.MODULES)); doCopy(path.resolve(Locations.CONFIGURATION), baseFile.resolve(Locations.CONFIGURATION)); doCopy(path.resolve(Locations.SUBSYSTEM_TEMPLATES), baseFile.resolve(Locations.SUBSYSTEM_TEMPLATES)); } catch (IOException e) { throw new RuntimeException(e); } }
Source:
<code><START> public void testListActivePlatformTypes() throws Exception { <END> Set<PlatformType> platformTypes = dao.listActivePlatformTypes(); assertEquals(1, platformTypes.size()); assertTrue(platformTypes.contains(PlatformType.ILLUMINA)); }</code><technical_language>worth including a negative test for SOLID 454</technical_language>

Target:
public void testListActivePlatformTypes() throws Exception { Set<PlatformType> platformTypes = dao.listActivePlatformTypes(); assertEquals(1, platformTypes.size()); assertFalse(platformTypes.contains(PlatformType.SOLID)); assertTrue(platformTypes.contains(PlatformType.ILLUMINA)); }
Source:
<code>private List<CloudResource> createCloudResources(String fqdn) { List<CloudResource> databaseResources = Lists.newArrayList(); <START> databaseResources.add(CloudResource.builder() <END> .type(ResourceType.RDS_HOSTNAME) .name(fqdn) .build()); databaseResources.add(CloudResource.builder() .type(ResourceType.RDS_PORT) .name(Integer.toString(POSTGRESQL_SERVER_PORT)) .build()); return databaseResources; }</code><technical_language>This of createCloudResource method</technical_language>

Target:
private List<CloudResource> createCloudResources(String fqdn) { List<CloudResource> databaseResources = Lists.newArrayList(); databaseResources.add(createCloudResource(RDS_HOSTNAME, fqdn)); databaseResources.add(createCloudResource(ResourceType.RDS_PORT, Integer.toString(POSTGRESQL_SERVER_PORT))); return databaseResources; }
Source:
<code>public void start() { LOG.info("Starting Azure job coordinator."); systemAdmins = new SystemAdmins(config); streamMetadataCache = new StreamMetadataCache(systemAdmins, METADATA_CACHE_TTL_MS, SystemClock.instance()); <START> systemAdmins.start(); <END> table.addProcessorEntity(INITIAL_STATE, processorId, false); LOG.info("Starting scheduler for heartbeating."); heartbeat.scheduleTask(); azureLeaderElector.tryBecomeLeader(); LOG.info("Starting scheduler to check for job model version upgrades."); versionUpgrade.setStateChangeListener(createJMVersionUpgradeListener()); versionUpgrade.scheduleTask(); LOG.info("Starting scheduler to check for leader liveness."); leaderAlive.setStateChangeListener(createLeaderLivenessListener()); leaderAlive.scheduleTask(); }</code><technical_language>Minor: prefer starting this passing StreamMetadataCache, in case do passed in systemAdmins</technical_language>

Target:
public void start() { LOG.info("Starting Azure job coordinator."); systemAdmins = new SystemAdmins(config); systemAdmins.start(); streamMetadataCache = new StreamMetadataCache(systemAdmins, METADATA_CACHE_TTL_MS, SystemClock.instance()); table.addProcessorEntity(INITIAL_STATE, processorId, false); LOG.info("Starting scheduler for heartbeating."); heartbeat.scheduleTask(); azureLeaderElector.tryBecomeLeader(); LOG.info("Starting scheduler to check for job model version upgrades."); versionUpgrade.setStateChangeListener(createJMVersionUpgradeListener()); versionUpgrade.scheduleTask(); LOG.info("Starting scheduler to check for leader liveness."); leaderAlive.setStateChangeListener(createLeaderLivenessListener()); leaderAlive.scheduleTask(); }
Source:
<code>public void checkTimeoutOnPendingOperations() { int timedOutOperations = completionObjects.removeIf(timeoutCheck); synchronized (this) { Iterator<CompletionValue> iterator = completionObjectsV2Conflicts.values().iterator(); while (iterator.hasNext()) { CompletionValue value = iterator.next(); if (value.maybeTimeout()) { ++timedOutOperations; iterator.remove(); } } } if (timedOutOperations > 0) { LOG.info("Timed-out operations to channel for {}", <START> new Object[] { timedOutOperations, channel, addr }); <END> } }</code><technical_language>nit: need new Object[] for current version of slf4j</technical_language>

Target:
public void checkTimeoutOnPendingOperations() { int timedOutOperations = completionObjects.removeIf(timeoutCheck); synchronized (this) { Iterator<CompletionValue> iterator = completionObjectsV2Conflicts.values().iterator(); while (iterator.hasNext()) { CompletionValue value = iterator.next(); if (value.maybeTimeout()) { ++timedOutOperations; iterator.remove(); } } } if (timedOutOperations > 0) { LOG.info("Timed-out operations to channel for {}", timedOutOperations, channel, addr); } }
Source:
<code>public JsonObject getStats() { return new JsonObject() .add("default_topic", defaultTopic) .add("seen_messages", seenMessages.get()) <START> .add("propagated_messages", propagatedMessages.get()) <END> .add("failed_to_send", failedToSendMessageExceptions.get()) .add("failed_send", meterToJsonObject(producerStats.failedSendRate())) .add("resend", meterToJsonObject(producerStats.resendRate())) .add("serialization_error", meterToJsonObject(producerStats.serializationErrorRate())) .add("message", meterToJsonObject(producerAllTopicsStats.messageRate())) .add("dropped_message", meterToJsonObject(producerAllTopicsStats.droppedMessageRate())) .add("byte", meterToJsonObject(producerAllTopicsStats.byteRate())); }</code><technical_language>propagate flag is for messages, seen_messages propagated_messages same. amirite? remove metric</technical_language>

Target:
public JsonObject getStats() { return new JsonObject() .add("default_topic", defaultTopic) .add("seen_messages", seenMessages.get()) .add("failed_to_send", failedToSendMessageExceptions.get()) .add("failed_send", meterToJsonObject(producerStats.failedSendRate())) .add("resend", meterToJsonObject(producerStats.resendRate())) .add("serialization_error", meterToJsonObject(producerStats.serializationErrorRate())) .add("message", meterToJsonObject(producerAllTopicsStats.messageRate())) .add("dropped_message", meterToJsonObject(producerAllTopicsStats.droppedMessageRate())) .add("byte", meterToJsonObject(producerAllTopicsStats.byteRate())); }
Source:
<code><START> public HaplotypeProbabilitiesFromContaminatorSequence(HaplotypeProbabilitiesFromContaminatorSequence other){ <END> this(other.getHaplotype(),other.contamination); for (final Genotype g : Genotype.values()) { System.arraycopy(other.likelihoodMap[g.v], 0, likelihoodMap[g.v], 0, nGeno); } }</code><technical_language>whitespace suggestion public HaplotypeProbabilitiesFromContaminatorSequence(HaplotypeProbabilitiesFromContaminatorSequence other) {</technical_language>

Target:
public HaplotypeProbabilitiesFromContaminatorSequence(HaplotypeProbabilitiesFromContaminatorSequence other) { super(other); contamination = other.contamination; for (final Genotype g : Genotype.values()) { System.arraycopy(other.likelihoodMap[g.v], 0, likelihoodMap[g.v], 0, NUM_GENOTYPES); } }
Source:
<code>public void checkHasCorrectResponseStatus(Endpoint endpoint) { try { mockMvc.perform(endpoint.toRequestBuilder()).andExpect(STATUS_NOT_401_OR_403); } catch (Exception e) { throw new AssertionError("Exception when calling endpoint: " + endpoint, e); } catch (AssertionError e) { <START> throw e; <END> } }</code><technical_language>If throw exception - this block sense, throw caught. add is create throw AssertionError contains endpoint (like lines above), if mockMvc check fails - provide information endpoint</technical_language>

Target:
public void checkHasCorrectResponseStatus(Endpoint endpoint) { try { mockMvc.perform(endpoint.toRequestBuilder()).andExpect(STATUS_NOT_401_OR_403); } catch (Exception e) { throw new AssertionError("Exception when calling endpoint: " + endpoint, e); } catch (AssertionError e) { throw new AssertionError("Assertion error when calling endpoint: " + endpoint, e); } }
Source:
<code>ArrayList<Pojo> getFavorites(Context context, int limit) { <START> ArrayList<Pojo> favorites = new ArrayList<>(); <END> String favApps = PreferenceManager.getDefaultSharedPreferences(context). getString("favorite-apps-list", ""); List<String> favAppsList = Arrays.asList(favApps.split(";")); for (int i = 0; i < favAppsList.size(); i++) { Pojo pojo = getPojo(favAppsList.get(i)); if (pojo != null) { favorites.add(pojo); } } return favorites; }</code><technical_language>add limit size of array list</technical_language>

Target:
ArrayList<Pojo> getFavorites(Context context, int limit) { ArrayList<Pojo> favorites = new ArrayList<>(limit); String favApps = PreferenceManager.getDefaultSharedPreferences(context). getString("favorite-apps-list", ""); List<String> favAppsList = Arrays.asList(favApps.split(";")); for (int i = 0; i < favAppsList.size(); i++) { Pojo pojo = getPojo(favAppsList.get(i)); if (pojo != null) { favorites.add(pojo); } if (favorites.size()>=limit) { break; } } return favorites; }
Source:
<code>public View create(boolean shortSummary, RecordAdapter.HeaderViewHolder mainViewHolder) { view = layoutInflater.inflate(R.layout.view_summary_records, null); view.findViewById(R.id.iv_more).setVisibility(shortSummary ? View.VISIBLE : View.INVISIBLE); <START> if (mainViewHolder == null) <END> view.setTag(new ViewHolder(view)); else view.setTag(mainViewHolder); return view; }</code><technical_language>do view.setTag(mainViewHolder == null ? new ViewHolder(view) : mainViewHolder);</technical_language>

Target:
public View create(boolean shortSummary, RecordAdapter.HeaderViewHolder mainViewHolder) { view = layoutInflater.inflate(R.layout.view_summary_records, null); view.findViewById(R.id.iv_more).setVisibility(shortSummary ? View.VISIBLE : View.INVISIBLE); view.setTag(mainViewHolder != null ? mainViewHolder : new ViewHolder(view)); return view; }
Source:
<code>public void compact() { if (getRetainedSizeInBytes() <= getSizeInBytes()) { return; } for (int i = 0; i < blocks.length; i++) { Block block = blocks[i]; if (block instanceof DictionaryBlock) { continue; } Block compactedBlock = block.copyRegion(0, block.getPositionCount()); <START> blocks[i] = compactedBlock; <END> } Map<DictionaryId, DictionaryBlockIndexes> dictionaryBlocks = getRelatedDictionaryBlocks(); for (DictionaryBlockIndexes blockIndexes : dictionaryBlocks.values()) { List<DictionaryBlock> compactBlocks = compactRelatedBlocks(blockIndexes.getBlocks()); List<Integer> indexes = blockIndexes.getIndexes(); for (int i = 0; i < compactBlocks.size(); i++) { blocks[indexes.get(i)] = compactBlocks.get(i); } } long retainedSize = 0; for (Block block : blocks) { retainedSize += block.getRetainedSizeInBytes(); } retainedSizeInBytes.set(retainedSize); }</code><technical_language>inline compactedBlock</technical_language>

Target:
public void compact() { if (getRetainedSizeInBytes() <= getSizeInBytes()) { return; } for (int i = 0; i < blocks.length; i++) { Block block = blocks[i]; if (block instanceof DictionaryBlock) { continue; } blocks[i] = block.copyRegion(0, block.getPositionCount()); } Map<DictionaryId, DictionaryBlockIndexes> dictionaryBlocks = getRelatedDictionaryBlocks(); for (DictionaryBlockIndexes blockIndexes : dictionaryBlocks.values()) { List<DictionaryBlock> compactBlocks = compactRelatedBlocks(blockIndexes.getBlocks()); List<Integer> indexes = blockIndexes.getIndexes(); for (int i = 0; i < compactBlocks.size(); i++) { blocks[indexes.get(i)] = compactBlocks.get(i); } } long retainedSize = 0; for (Block block : blocks) { retainedSize += block.getRetainedSizeInBytes(); } retainedSizeInBytes.set(retainedSize); }
Source:
<code>public static AuthenticationScheme getAuthenticationScheme() { AuthenticationScheme scheme = new UsernamePasswordAuthenticationScheme(); try { scheme = Context.getServiceContext().getApplicationContext().getBean(AuthenticationScheme.class); log.info("An authentication scheme override was provided. Using this one in place of the OpenMRS default authentication scheme."); } catch(NoUniqueBeanDefinitionException e) { log.error("Multiple authentication schemes overrides are being provided, this is currently not supported. Sticking to OpenMRS default authentication scheme."); } catch(NoSuchBeanDefinitionException e) { log.debug("No authentication scheme override was provided. Sticking to OpenMRS default authentication scheme."); } catch(BeansException e){ log.error("Fatal error encountered when injecting the authentication scheme override. Sticking to OpenMRS default authentication scheme."); } <START> if (scheme instanceof DaoAuthenticationScheme) { <END> ((DaoAuthenticationScheme) scheme).setContextDao(getContextDAO()); } return scheme; }</code><technical_language>a get method a side effect of setting something</technical_language>

Target:
public static AuthenticationScheme getAuthenticationScheme() { return authenticationScheme; }