auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void setMetadataCreator(DepositMetadata depositMetadata, Workflow workflow) { String wfAuthor = workflow.getAuthor(); <START> String authorStr = (wfAuthor == null || wfAuthor.isEmpty()) ? "n/a" : workflow.getAuthor(); <END> Author author = new Author(); author.setName(authorStr); depositMetadata.setCreators(Arrays.asList(author)); }</code><technical_language>1. instead StringUtils.isBlank(wfAuthor) 2. "n/a"? asking... Is a convention, Zenodo leave empty</technical_language>

Target:
private void setMetadataCreator(DepositMetadata depositMetadata, Workflow workflow) { String wfAuthor = workflow.getAuthor(); String authorStr = (wfAuthor == null || wfAuthor.isEmpty()) ? "unknown creator" : workflow.getAuthor(); Author author = new Author(); author.setName(authorStr); depositMetadata.setCreators(Arrays.asList(author)); }
Source:
<code>public EventJobFactory getJobFactory() { try { <START> return jobFactoryClass.newInstance(); <END> } catch (ReflectiveOperationException e) { throw new NuxeoException("Failed to instantiate job factory " + jobFactoryClass, e); } }</code><technical_language>jobFactoryClass.getDeclaredConstructor().newInstance() instead avoid a deprecated interface</technical_language>

Target:
public EventJobFactory getJobFactory() { try { return jobFactoryClass.getDeclaredConstructor().newInstance(); } catch (ReflectiveOperationException e) { throw new NuxeoException("Failed to instantiate job factory " + jobFactoryClass, e); } }
Source:
<code>public void configReferenceValidated() { ConfigReference ref1 = new ConfigReference("id:1", 1L); ConfigReference ref2 = new ConfigReference("id:2", 2L); when(appConfigElementService.getElementRevision(any(), any(), anyLong())).thenReturn(AppConfigElement.create()); List<ConfigReference> references = ImmutableList.of(ref1, ref2); appConfig.setConfigReferences(references); <START> assertValidatorMessage(newValidator, appConfig, "criteria", "are required"); <END> }</code><technical_language>This test semantically suggests validator throw criteria missing. means if a bug validator throws anyway, catch bug. call Validate.validateThrowException()</technical_language>

Target:
public void configReferenceValidated() { ConfigReference ref1 = new ConfigReference("id:1", 1L); ConfigReference ref2 = new ConfigReference("id:2", 2L); when(appConfigElementService.getElementRevision(any(), any(), anyLong())).thenReturn(AppConfigElement.create()); List<ConfigReference> references = ImmutableList.of(ref1, ref2); appConfig.setConfigReferences(references); appConfig.setLabel("label"); appConfig.setCriteria(Criteria.create()); Validate.entityThrowingException(newValidator, appConfig); }
Source:
<code>public Set<List<Integer>> getAliveExecutors(String topoId, Set<List<Integer>> allExecutors, Assignment assignment, int taskLaunchSecs) { Map<List<Integer>, ExecutorCache> topoCache = cache.computeIfAbsent(topoId, MAKE_MAP); LOG.debug("Computing alive executors for {}\nExecutors: {}\nAssignment: {}\nHeartbeat cache: {}", topoId, allExecutors, assignment, topoCache); Set<List<Integer>> ret = new HashSet<>(); Map<List<Long>, Long> execToStartTimes = assignment.get_executor_start_time_secs(); for (List<Integer> exec : allExecutors) { List<Long> longExec = new ArrayList<>(exec.size()); for (Integer num : exec) { longExec.add(num.longValue()); } Long startTime = execToStartTimes.get(longExec); ExecutorCache executorCache = topoCache.get(exec); <START> Boolean isTimedOut = executorCache == null ? null : executorCache.isTimedOut(); <END> Integer delta = startTime == null ? null : Time.deltaSecs(startTime.intValue()); if (startTime != null && ((delta < taskLaunchSecs) || (isTimedOut != null && !isTimedOut))) { ret.add(exec); } else { LOG.info("Executor {}:{} not alive", topoId, exec); } } return ret; }</code><technical_language>Nit: simpler set isTimedOut false if executorCache is null. avoids extra null check below</technical_language>

Target:
public Set<List<Integer>> getAliveExecutors(String topoId, Set<List<Integer>> allExecutors, Assignment assignment, int taskLaunchSecs) { Map<List<Integer>, ExecutorCache> topoCache = cache.computeIfAbsent(topoId, MAKE_MAP); LOG.debug("Computing alive executors for {}\nExecutors: {}\nAssignment: {}\nHeartbeat cache: {}", topoId, allExecutors, assignment, topoCache); Set<List<Integer>> ret = new HashSet<>(); Map<List<Long>, Long> execToStartTimes = assignment.get_executor_start_time_secs(); for (List<Integer> exec : allExecutors) { List<Long> longExec = new ArrayList<>(exec.size()); for (Integer num : exec) { longExec.add(num.longValue()); } Long startTime = execToStartTimes.get(longExec); ExecutorCache executorCache = topoCache.get(exec); boolean isTimedOut = executorCache == null ? true : executorCache.isTimedOut(); Integer delta = startTime == null ? null : Time.deltaSecs(startTime.intValue()); if (startTime != null && ((delta < taskLaunchSecs) || !isTimedOut)) { ret.add(exec); } else { LOG.info("Executor {}:{} not alive", topoId, exec); } } return ret; }
Source:
<code><START> public void loadVisitors() <END> { if (!plugins.isEmpty()) { return; } PropertyBasedPluginLocator<DAGSetupPlugin> locator = new PropertyBasedPluginLocator<>(DAGSetupPlugin.class, DAGSETUP_PLUGINS_CONF_KEY); this.plugins.addAll(locator.discoverPlugins(conf)); }</code><technical_language>public</technical_language>

Target:
private void loadVisitors() { if (!plugins.isEmpty()) { return; } PropertyBasedPluginLocator<DAGSetupPlugin> locator = new PropertyBasedPluginLocator<>(DAGSetupPlugin.class, DAGSETUP_PLUGINS_CONF_KEY); this.plugins.addAll(locator.discoverPlugins(conf)); }
Source:
<code>public void annotationToFieldsReturnsUnmodifiableMap() { <START> exception.expect(UnsupportedOperationException.class); <END> TestClass tc = new TestClass(FieldAnnotated.class); Map<Class<? extends Annotation>, List<FrameworkField>> annotationToFields = tc.getAnnotationToFields(); annotationToFields.put(Rule.class, null); }</code><technical_language>put this line right call annotationToFields.put(Rule.class, null)</technical_language>

Target:
public void annotationToFieldsReturnsUnmodifiableMap() { TestClass tc = new TestClass(FieldAnnotated.class); Map<Class<? extends Annotation>, List<FrameworkField>> annotationToFields = tc.getAnnotationToFields(); exception.expect(UnsupportedOperationException.class); annotationToFields.put(Rule.class, null); }
Source:
<code>private static List<StartIdentifiedAtlasDbTransactionResponse> startTransactions( LockLeaseService lockLeaseService, int numberOfTransactions) { List<StartIdentifiedAtlasDbTransactionResponse> result = new ArrayList<>(); while (result.size() < numberOfTransactions) { result.addAll(split(lockLeaseService.startTransactions(numberOfTransactions - result.size()))); } <START> return result.subList(0, numberOfTransactions); <END> }</code><technical_language>sufficient return result</technical_language>

Target:
private static List<StartIdentifiedAtlasDbTransactionResponse> startTransactions( LockLeaseService lockLeaseService, int numberOfTransactions) { List<StartIdentifiedAtlasDbTransactionResponse> result = new ArrayList<>(); while (result.size() < numberOfTransactions) { result.addAll(split(lockLeaseService.startTransactions(numberOfTransactions - result.size()))); } return result; }
Source:
<code>private static Method findEquivalentMethod(Class<?> clazz, Method method) { Method[] candidates = clazz.getDeclaredMethods(); for (Method candidate : candidates) { if (candidate.getName().equals(method.getName()) && Arrays.equals( <START> candidate.getParameterTypes(), method.getParameterTypes())) { <END> return candidate; } } return null; }</code><technical_language>I suggest a pre-check candidate.getParameterCount() == method.getParameterCount()) in order avoid allocations coming getParameterTypes()</technical_language>

Target:
private static Method findEquivalentMethod(Class<?> clazz, Method method) { Method[] candidates = clazz.getDeclaredMethods(); for (Method candidate : candidates) { if (candidate.getName().equals(method.getName()) && candidate.getParameterCount() == method.getParameterCount() && Arrays.equals(candidate.getParameterTypes(), method.getParameterTypes())) { return candidate; } } return null; }
Source:
<code>private String formatTimeForId(Instant instant) { return formatter.format( <START> TimeHelper.convertInstantToLocalDateTime(instant, Const.SystemParams.ADMIN_TIME_ZONE)); <END> }</code><technical_language>This fit line</technical_language>

Target:
private static String formatTimeForId(Instant instant) { return FORMATTER.format(TimeHelper.convertInstantToLocalDateTime(instant, Const.SystemParams.ADMIN_TIME_ZONE)); }
Source:
<code>private boolean buildAndTag() throws MacroEvaluationException, IOException, InterruptedException { <START> File context = new File(defined(getBuildContext()) ? getBuildContext() : "."); <END> Iterator<String> i = getNameAndTag().iterator(); Result lastResult = new Result(); if (i.hasNext()) { lastResult = executeCmd("docker build -t " + i.next() + ((isNoCache()) ? " --no-cache=true " : "") + " " + ((isForcePull()) ? " --pull=true " : "") + " " + (defined(getDockerfilePath()) ? " --file=" + new File(context, getDockerfilePath()) : "") + " " + context); } String image = getImageBuiltFromStdout(lastResult.stdout); if (image != null) { while (lastResult.result && i.hasNext()) { lastResult = executeCmd("docker tag --force=true " + image + " " + i.next()); } processFingerprints(image); } else { while (lastResult.result && i.hasNext()) { lastResult = executeCmd("docker build -t " + i.next() + ((isNoCache()) ? " --no-cache=true " : "") + " " + ((isForcePull()) ? " --pull=true " : "") + " " + (defined(getDockerfilePath()) ? " --file=" + new File(context, getDockerfilePath()) : "") + " " + context); processFingerprintsFromStdout(lastResult.stdout); } } return lastResult.result; }</code><technical_language><code>FilePath</code> default workspace IMO</technical_language>

Target:
private boolean buildAndTag() throws MacroEvaluationException, IOException, InterruptedException { FilePath context = defined(getBuildContext()) ? new FilePath(new File(getBuildContext())) : build.getWorkspace(); Iterator<String> i = getNameAndTag().iterator(); Result lastResult = new Result(); if (i.hasNext()) { lastResult = executeCmd("docker build -t " + i.next() + ((isNoCache()) ? " --no-cache=true " : "") + " " + ((isForcePull()) ? " --pull=true " : "") + " " + (defined(getDockerfilePath()) ? " --file=" + getDockerfilePath() : "") + " " + context); } String image = getImageBuiltFromStdout(lastResult.stdout); if (image != null) { while (lastResult.result && i.hasNext()) { lastResult = executeCmd("docker tag --force=true " + image + " " + i.next()); } processFingerprints(image); } else { while (lastResult.result && i.hasNext()) { lastResult = executeCmd("docker build -t " + i.next() + ((isNoCache()) ? " --no-cache=true " : "") + " " + ((isForcePull()) ? " --pull=true " : "") + " " + (defined(getDockerfilePath()) ? " --file=" + getDockerfilePath() : "") + " " + context); processFingerprintsFromStdout(lastResult.stdout); } } return lastResult.result; }
Source:
<code>private void testReadWithHeader() throws IOException { File file = makeFile(); DataFileReader<Object> reader = new DataFileReader<>(file, new GenericDatumReader<>()); DataFileStream.Header header = reader.getHeader(); SeekableFileInput sin = new SeekableFileInput(file); sin.seek(sin.length() / 2); reader = DataFileReader.openReader(sin, new GenericDatumReader<>(), header, true); assertNotNull("Should be able to reopen from arbitrary point", reader.next()); long validPos = reader.previousSync(); sin.seek(validPos); reader = DataFileReader.openReader(sin, new GenericDatumReader<>(), header, false); assertEquals("Should not move from sync point on reopen", validPos, sin.tell()); assertNotNull("Should be able to reopen at sync point", reader.next()); <START> reader.close(); <END> }</code><technical_language>a try-with-resource pattern here</technical_language>

Target:
private void testReadWithHeader() throws IOException { File file = makeFile(); try (DataFileReader<Object> reader = new DataFileReader<>(file, new GenericDatumReader<>())) { DataFileStream.Header header = reader.getHeader(); SeekableFileInput sin = new SeekableFileInput(file); sin.seek(sin.length() / 2); try (DataFileReader<Object> readerTrue = DataFileReader.openReader(sin, new GenericDatumReader<>(), header, true);) { assertNotNull("Should be able to reopen from arbitrary point", readerTrue.next()); long validPos = readerTrue.previousSync(); sin.seek(validPos); try (DataFileReader<Object> readerFalse = DataFileReader.openReader(sin, new GenericDatumReader<>(), header, false)) { assertEquals("Should not move from sync point on reopen", validPos, sin.tell()); assertNotNull("Should be able to reopen at sync point", readerFalse.next()); } } } }
Source:
<code>public float getRegenerationTimerStart() { <START> return this.REGEN_TIMER_START; <END> }</code><technical_language>Formatting..</technical_language>

Target:
public float getRegenerationTimerStart() { return regenTimerStart > 0 ? regenTimerStart : TIMER_START; }
Source:
<code>public Group groupUnion(PerunSession sess, Group resultGroup, Group operandGroup) throws InternalErrorException, WrongReferenceAttributeValueException, NotMemberOfParentGroupException, AlreadyMemberException, WrongAttributeValueException, GroupNotExistsException, NotGroupMemberException { if(resultGroup.getName().equals(VosManager.MEMBERS_GROUP) || operandGroup.getName().equals(VosManager.MEMBERS_GROUP)) { throw new InternalErrorException("Union cannot be created on members group."); } if (resultGroup.getVoId() != operandGroup.getVoId()) { throw new InternalErrorException("Groups are not from same VO"); } if (resultGroup.getId() == operandGroup.getId()) { throw new InternalErrorException("Result group cannot be the same as operand group."); } if (this.groupsManagerImpl.isRelationBetweenGroups(resultGroup, operandGroup)) { throw new InternalErrorException("There is already an operation defined between these two groups: " + resultGroup + " and " + operandGroup); } if (areGroupsTransitive(sess, resultGroup.getId(), operandGroup.getId())) { throw new InternalErrorException("This relation would create group transitivity."); } processRelationMembers(sess, resultGroup, getGroupMembers(sess, operandGroup), operandGroup.getId(), OPERATION_UNION, true); <START> groupsManagerImpl.saveGroupRelation(sess, resultGroup, operandGroup, OPERATION_UNION); <END> return resultGroup; }</code><technical_language>Switch methods</technical_language>

Target:
public Group groupUnion(PerunSession sess, Group resultGroup, Group operandGroup) throws GroupOperationsException, InternalErrorException { if(resultGroup.getName().equals(VosManager.MEMBERS_GROUP) || operandGroup.getName().equals(VosManager.MEMBERS_GROUP)) { throw new InternalErrorException("Union cannot be created on members group."); } if (resultGroup.getVoId() != operandGroup.getVoId()) { throw new InternalErrorException("Groups are not from same VO"); } if (resultGroup.getId() == operandGroup.getId()) { throw new InternalErrorException("Result group cannot be the same as operand group."); } if (this.groupsManagerImpl.isRelationBetweenGroups(resultGroup, operandGroup)) { throw new InternalErrorException("There is already an operation defined between these two groups: " + resultGroup + " and " + operandGroup); } if (checkGroupsCycle(sess, resultGroup.getId(), operandGroup.getId())) { throw new InternalErrorException("This relation would create group transitivity."); } groupsManagerImpl.saveGroupRelation(sess, resultGroup, operandGroup, GroupOperations.UNION); processRelationMembers(sess, resultGroup, getGroupActiveMembers(sess, operandGroup), operandGroup.getId(), GroupOperations.UNION, true); return resultGroup; }
Source:
<code>private Account(JSONObject metadata) throws JSONException { if (metadata == null) { throw new IllegalArgumentException("metadata cannot be null."); } <START> short metadataVersion = (short) metadata.getInt(JSON_VERSION_KEY); <END> if (metadataVersion == JSON_VERSION_1) { id = (short) metadata.getInt(ACCOUNT_ID_KEY); name = metadata.getString(ACCOUNT_NAME_KEY); status = AccountStatus.valueOf(metadata.getString(STATUS_KEY)); snapshotVersion = metadata.optInt(SNAPSHOT_VERSION_KEY, SNAPSHOT_VERSION_DEFAULT_VALUE); lastModifiedTime = metadata.optLong(LAST_MODIFIED_TIME_KEY, LAST_MODIFIED_TIME_DEFAULT_VALUE); checkRequiredFieldsForBuild(); JSONArray containerArray = metadata.optJSONArray(CONTAINERS_KEY); if (containerArray != null) { for (int index = 0; index < containerArray.length(); index++) { Container container = Container.fromJson(containerArray.getJSONObject(index), id); checkParentAccountIdInContainers(container); checkDuplicateContainerNameOrId(container); updateContainerMap(container); } } } else { throw new IllegalStateException("Unsupported account json version=" + metadataVersion); } }</code><technical_language>change switch if/else</technical_language>

Target:
private Account(JSONObject metadata) throws JSONException { if (metadata == null) { throw new IllegalArgumentException("metadata cannot be null."); } short metadataVersion = (short) metadata.getInt(JSON_VERSION_KEY); switch (metadataVersion) { case JSON_VERSION_1: id = (short) metadata.getInt(ACCOUNT_ID_KEY); name = metadata.getString(ACCOUNT_NAME_KEY); status = AccountStatus.valueOf(metadata.getString(STATUS_KEY)); snapshotVersion = metadata.optInt(SNAPSHOT_VERSION_KEY, SNAPSHOT_VERSION_DEFAULT_VALUE); lastModifiedTime = metadata.optLong(LAST_MODIFIED_TIME_KEY, LAST_MODIFIED_TIME_DEFAULT_VALUE); checkRequiredFieldsForBuild(); JSONArray containerArray = metadata.optJSONArray(CONTAINERS_KEY); if (containerArray != null) { List<Container> containers = new ArrayList<>(); for (int index = 0; index < containerArray.length(); index++) { containers.add(Container.fromJson(containerArray.getJSONObject(index), id)); } updateContainerMap(containers); } break; default: throw new IllegalStateException("Unsupported account json version=" + metadataVersion); } }
Source:
<code>public Object visitGetAllCommand(InvocationContext ctx, GetAllCommand command) throws Throwable { try { if (ctx.isInTxScope() && command.hasFlag(Flag.FORCE_WRITE_LOCK) && !hasSkipLocking(command)) { acquireRemoteIfNeeded(ctx, command.getKeys(), command); final TxInvocationContext txContext = (TxInvocationContext) ctx; long lockTimeout = getLockAcquisitionTimeout(command, false); for (Object key : command.getKeys()) { lockAndRegisterBackupLock(txContext, key, lockTimeout, false); } } return invokeNextInterceptor(ctx, command); } catch (Throwable t) { releaseLocksOnFailureBeforePrepare(ctx); throw t; } finally { <START> if (!ctx.isInTxScope()) lockManager.unlockAll(ctx); <END> } }</code><technical_language>Is this needed? Above, locks acquired in a tx context</technical_language>

Target:
public Object visitGetAllCommand(InvocationContext ctx, GetAllCommand command) throws Throwable { try { if (ctx.isInTxScope() && command.hasFlag(Flag.FORCE_WRITE_LOCK) && !hasSkipLocking(command)) { acquireRemoteIfNeeded(ctx, command.getKeys(), command); final TxInvocationContext txContext = (TxInvocationContext) ctx; long lockTimeout = getLockAcquisitionTimeout(command, false); for (Object key : command.getKeys()) { lockAndRegisterBackupLock(txContext, key, lockTimeout, false); } } return invokeNextInterceptor(ctx, command); } catch (Throwable t) { releaseLocksOnFailureBeforePrepare(ctx); throw t; } }
Source:
<code>public void validate(Object obj, Errors err) { ValidationUtils.rejectIfEmptyOrWhitespace(err, "title", "about_title.required"); <START> ValidationUtils.rejectIfEmptyOrWhitespace(err, "description", "about_description.required"); <END> }</code><technical_language>validate submitted html contains allowed tags javascript</technical_language>

Target:
public void validate(Object obj, Errors err) { IAboutText abtText = (IAboutText) obj; String description = abtText.getDescription(); String title = abtText.getTitle(); Whitelist whitelist = Whitelist.basicWithImages(); Whitelist titleWhitelist = Whitelist.simpleText(); ValidationUtils.rejectIfEmptyOrWhitespace(err, "title", "about_title.required"); ValidationUtils.rejectIfEmptyOrWhitespace(err, "description", "about_description.required"); if (!Jsoup.isValid(description, whitelist)) { err.rejectValue("description", "about_description.proper"); } if (!Jsoup.isValid(title, titleWhitelist)) { err.rejectValue("title", "about_title.proper"); } }
Source:
<code>private IAction createFlatAction() { IAction action = new Action(Messages.ControlFlowView_flatViewLabel, IAction.AS_RADIO_BUTTON) { @Override public void run() { if (!fIsFlatViewClicked) { setTraceEntryChildren(fFlatList); fIsFlatViewClicked = true; } } }; action.setToolTipText(Messages.ControlFlowView_flatViewToolTip); <START> action.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(IControlflowImageConstants.IMG_UI_FLAT_VIEW)); <END> return action; }</code><technical_language>This ImageDescriptor a private static final constant</technical_language>

Target:
private IAction createFlatAction() { IAction action = new Action(Messages.ControlFlowView_flatViewLabel, IAction.AS_RADIO_BUTTON) { @Override public void run() { if (!fIsFlatViewClicked) { ITmfTrace parentTrace = getTrace(); for (ITmfTrace trace : TmfTraceManager.getTraceSet(parentTrace)) { final ITmfStateSystem ss = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID); List<TimeGraphEntry> currentRootList = getEntryList(ss); addEntriesToFlatTree(currentRootList, parentTrace, ss); } fIsFlatViewClicked = true; refresh(); } } }; action.setToolTipText(Messages.ControlFlowView_flatViewToolTip); action.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(IControlflowImageConstants.IMG_UI_FLAT_VIEW)); return action; }
Source:
<code><START> public String toString() <END> { if (extractionFn != null) { return StringUtils.format("%s(%s) = %s", extractionFn, dimension, hash.toString()); } else { return StringUtils.format("%s = %s", dimension, hash.toString()); } }</code><technical_language>Please add filterTuning in toString() form</technical_language>

Target:
public String toString() { return new DimFilterToStringBuilder().appendDimension(dimension, extractionFn) .appendEquals(hash.toString()) .appendFilterTuning(filterTuning) .build(); }
Source:
<code>private static BiConsumer<MergingCompletableFuture<Object>, Object> moveListItemsToFuture(int myOffset) { <START> return (f, rv) -> { <END> if (rv instanceof List) { List list = (List) rv; if (trace) { log.tracef("Copying %d items %s to results (%s), starting offset %d", list.size(), list, Arrays.toString(f.results), myOffset); } for (int i = 0; i < list.size(); ++i) { f.results[myOffset + i] = list.get(i); } } else if (rv != null || f.results != null) { f.completeExceptionally(new IllegalArgumentException("Unexpected result value " + rv)); } }; }</code><technical_language>I this works a regular method, creating a lambda needed</technical_language>

Target:
private static BiConsumer<MergingCompletableFuture<Object>, Object> moveListItemsToFuture(int myOffset) { return (f, rv) -> { Collection<?> items; if (rv == null && f.results == null) { return; } else if (rv instanceof Map) { items = ((Map) rv).entrySet(); } else if (rv instanceof Collection) { items = (Collection<?>) rv; } else { f.completeExceptionally(new IllegalArgumentException("Unexpected result value " + rv)); return; } if (trace) { log.tracef("Copying %d items %s to results (%s), starting offset %d", items.size(), items, Arrays.toString(f.results), myOffset); } Iterator<?> it = items.iterator(); for (int i = 0; it.hasNext(); ++i) { f.results[myOffset + i] = it.next(); } }; }
Source:
<code><START> public synchronized Long size() <END> { final File file = path.toFile(); Long size = (file.exists() && !file.isDirectory()) ? file.length() : 0l; if (childSize < 0l || childModCount > lastSizeCheck) { Long childSize = 0l; lastSizeCheck = childModCount; for (FileCopyResult child : children) { childSize += child.size(); } this.childSize = childSize; } size += childSize; return size; }</code><technical_language>this primitive long avoid unnecessary wrapping</technical_language>

Target:
public long size() { return size; }
Source:
<code>public void onBindViewHolder(@NonNull SettingsViewHolder holder, int position) { holder.mTitle.setText(mItems.get(position).getTitle()); if (position==0){ holder.mRowLayout.setOnClickListener(new View.OnClickListener() { @Override <START> public void onClick(View v) { <END> Intent i = new Intent(v.getContext() , LogsActivity.class); v.getContext().startActivity(i); } }); } if(position == 2){ holder.mRowLayout.setOnClickListener(view -> { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(view.getContext().getString(R.string.url_privacy_policy))); view.getContext().startActivity(i); }); } if (mItems.get(position).getDesc1() != null) { holder.mDesc1.setText(mItems.get(position).getDesc1()); } if (mItems.get(position).getDesc2() != null) { holder.mDesc2.setText(mItems.get(position).getDesc2()); } if (mItems.get(position).getDesc1() == null && mItems.get(position).getDesc2() == null) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holder.mTitle.getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); holder.mTitle.setLayoutParams(layoutParams); } }</code><technical_language>@deepak140596 a lambda for this</technical_language>

Target:
public void onBindViewHolder(@NonNull SettingsViewHolder holder, int position) { holder.mTitle.setText(mItems.get(position).getTitle()); if (position == 0) { holder.mRowLayout.setOnClickListener(view -> { Intent i = new Intent(view.getContext(), LogsActivity.class); view.getContext().startActivity(i); }); } if (position == 2) { holder.mRowLayout.setOnClickListener(view -> { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(view.getContext().getString(R.string.url_privacy_policy))); view.getContext().startActivity(i); }); } if (mItems.get(position).getDesc1() != null) { holder.mDesc1.setText(mItems.get(position).getDesc1()); } if (mItems.get(position).getDesc2() != null) { holder.mDesc2.setText(mItems.get(position).getDesc2()); } if (mItems.get(position).getDesc1() == null && mItems.get(position).getDesc2() == null) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holder.mTitle.getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); holder.mTitle.setLayoutParams(layoutParams); } }
Source:
<code>public static PDataType fromLiteral(Object value) { if (value == null) { return null; } for (PDataType type : PDataType.values()) { <START> if (type.isArrayType() && type.getJavaClass().isInstance(value)) { <END> PhoenixArray arr = (PhoenixArray) value; if ((type.getSqlType() == arr.baseType.sqlType + PDataType.ARRAY_TYPE_BASE)) { return type; } } else { if (type.getJavaClass().isInstance(value)) { return type; } } } throw new UnsupportedOperationException( "Unsupported literal value [" + value + "] of type " + value.getClass().getName()); }</code><technical_language>more readable if move isInstance if (type.getJavaClass().isInstance(value)) { if (type.isArrayType()) { ...... } else { return type; } }</technical_language>

Target:
public static PDataType fromLiteral(Object value) { if (value == null) { return null; } for (PDataType type : PDataType.values()) { if(type.getJavaClass().isInstance(value)){ if (type.isArrayType()) { PhoenixArray arr = (PhoenixArray) value; if ((type.getSqlType() == arr.baseType.sqlType + PDataType.ARRAY_TYPE_BASE)) { return type; } } else { return type; } } } throw new UnsupportedOperationException( "Unsupported literal value [" + value + "] of type " + value.getClass().getName()); }
Source:
<code>public void heartbeat(Event event) { long now = System.currentTimeMillis(); <START> LOG.debug("Heartbeat from mesos. Delta since last heartbeat is {}ms", now - lastHeartbeatTime.getAndSet(now)); <END> }</code><technical_language>a weird getAndSet debug line. I evaluated same, I read this a times convince hit</technical_language>

Target:
public void heartbeat(Event event) { long now = System.currentTimeMillis(); long delta = (now - lastHeartbeatTime.getAndSet(now)); LOG.debug("Heartbeat from mesos. Delta since last heartbeat is {}ms", delta); }
Source:
<code>public GitLabApiForm getQueryParams() { return (new GitLabApiForm() .withParam("iids", iids) .withParam("state", state) .withParam("order_by", orderBy) .withParam("sort", sort) .withParam("milestone", milestone) .withParam("view", (simpleView != null && simpleView ? "simple" : null)) .withParam("labels", (labels != null? String.join(",", labels) : null)) .withParam("created_after", createdAfter) .withParam("created_before", createdBefore) .withParam("updated_after", updatedAfter) .withParam("updated_before", updatedBefore) .withParam("scope", scope) .withParam("assignee_id", assigneeId) .withParam("my_reaction_emoji", myReactionEmoji) .withParam("source_branch", sourceBranch) .withParam("target_branch", targetBranch) .withParam("search", search) .withParam("in", in) <START> .withParam("wip", wip)); <END> }</code><technical_language>Change this to: .withParam("wip", (wip == null ? null : wip ? "yes" : "no"));</technical_language>

Target:
public GitLabApiForm getQueryParams() { return (new GitLabApiForm() .withParam("iids", iids) .withParam("state", state) .withParam("order_by", orderBy) .withParam("sort", sort) .withParam("milestone", milestone) .withParam("view", (simpleView != null && simpleView ? "simple" : null)) .withParam("labels", (labels != null? String.join(",", labels) : null)) .withParam("created_after", createdAfter) .withParam("created_before", createdBefore) .withParam("updated_after", updatedAfter) .withParam("updated_before", updatedBefore) .withParam("scope", scope) .withParam("assignee_id", assigneeId) .withParam("my_reaction_emoji", myReactionEmoji) .withParam("source_branch", sourceBranch) .withParam("target_branch", targetBranch) .withParam("search", search) .withParam("in", in) .withParam("wip", (wip == null ? null : wip ? "yes" : "no"))); }
Source:
<code>public String getRepositoryUrl() { if (repositoryUrl != null) { return repositoryUrl; } else { <START> if (isBlank(apiUri) || "<LINK_0>".equals(apiUri)) <END> return "<LINK_1>" + repoOwner + '/' + repository; else return String.format("%s/%s/%s", removeEnd(apiUri, API_V3), repoOwner, repository); } }</code><technical_language>isBlank(apiUri) impossible field is @Nonnull, a constant for GitHub API: suggestion if (GITHUB_URL.equals(apiUri))</technical_language>

Target:
public String getRepositoryUrl() { if (repositoryUrl != null) { return repositoryUrl; } else { if (GITHUB_URL.equals(apiUri)) return "<LINK_1>" + repoOwner + '/' + repository; else return String.format("%s%s/%s", removeEnd(apiUri, API_V3), repoOwner, repository); } }
Source:
<code>public TableRow createViewRow(TableRow rowView, Value value, int position) { CustomTextView questionTextView = (CustomTextView) rowView.findViewById( R.id.review_title_text); <START> TextView answerText = (TextView) rowView.findViewById(R.id.review_answer); <END> if ((value.getQuestionUId() != null)) { rowView.setTag(value.getQuestionUId()); String question = (QuestionDB.findByUID( value.getQuestionUId()).getInternationalizedCodeDe_Name()); if (!question.contains(TITLE_SEPARATOR)) { question = question + TITLE_SEPARATOR; } String answer = ((value.getInternationalizedName() != null) ? value.getInternationalizedName() : value.getValue()); if (answer.equals("")) { answer = (PreferencesState.getInstance().getContext().getString( R.string.empty_review_value)); } questionTextView.setText(question); answerText.setText(answer); rowView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!DynamicTabAdapter.isClicked) { DynamicTabAdapter.isClicked = true; String questionUId = (String) v.getTag(); onClickListener.onClickOnValue(questionUId); } } }); rowView.setBackgroundColor( Color.parseColor(value.getBackgroundColor())); } return rowView; }</code><technical_language>@xurxodev a CustomTextView, right</technical_language>

Target:
public TableRow createViewRow(TableRow rowView, Value value, int position) { CustomTextView questionTextView = (CustomTextView) rowView.findViewById( R.id.review_title_text); CustomTextView answerText = (CustomTextView) rowView.findViewById(R.id.review_answer); if ((value.getQuestionUId() != null)) { rowView.setTag(value.getQuestionUId()); String question = (QuestionDB.findByUID( value.getQuestionUId()).getInternationalizedCodeDe_Name()); if (!question.contains(TITLE_SEPARATOR)) { question = question + TITLE_SEPARATOR; } String answer = ((value.getInternationalizedName() != null) ? value.getInternationalizedName() : value.getValue()); if (answer.equals("")) { answer = (PreferencesState.getInstance().getContext().getString( R.string.empty_review_value)); } questionTextView.setText(question); answerText.setText(answer); rowView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!DynamicTabAdapter.isClicked) { DynamicTabAdapter.isClicked = true; String questionUId = (String) v.getTag(); onClickListener.onClickOnValue(questionUId); } } }); rowView.setBackgroundColor( Color.parseColor(value.getBackgroundColor())); } return rowView; }
Source:
<code>private SecretKey getMacKey(SecretKey key) { byte[] encodedKey = key.getEncoded(); if (encodedKey != null) <START> return new SecretKeySpec(encodedKey, KEYSPEC_ALGORITHM); <END> return key; }</code><technical_language>I if for MAC is KEYSPEC_ALGORITHM</technical_language>

Target:
private SecretKey getMacKey(SecretKey key) throws NoSuchAlgorithmException { byte[] encodedKey = key.getEncoded(); if (encodedKey != null) { MessageDigest digester = MessageDigest.getInstance(MAC_KEY_HASH_ALGORITHM); return new SecretKeySpec(digester.digest(encodedKey), KEYSPEC_ALGORITHM); } return key; }
Source:
<code>public void testSimpleDuplicatesWithSecondaryAndSupplementaryRecords() throws IOException { final File input = new File(TEST_DATA_DIR, "dupes_with_sos.sam"); final File output = File.createTempFile("estimateLibraryComplexity",".els_metrics"); output.deleteOnExit(); <START> final List<String> args =new ArrayList<String>(); <END> args.add("INPUT=" + input.getAbsolutePath()); args.add("OUTPUT=" + output.getAbsolutePath()); args.add("MIN_GROUP_COUNT=1"); Assert.assertEquals(runPicardCommandLine(args), 0); examineMetricsFile(output, 2, 2); }</code><technical_language>spaces (ha!)</technical_language>

Target:
public void testSimpleDuplicatesWithSecondaryAndSupplementaryRecords() throws IOException { final File input = new File(TEST_DATA_DIR, "dupes_with_sos.sam"); final File output = File.createTempFile("estimateLibraryComplexity",".els_metrics"); output.deleteOnExit(); final List<String> args = new ArrayList<>(); args.add("INPUT=" + input.getAbsolutePath()); args.add("OUTPUT=" + output.getAbsolutePath()); args.add("MIN_GROUP_COUNT=1"); Assert.assertEquals(runPicardCommandLine(args), 0); examineMetricsFile(output, 2, 2); }
Source:
<code>private void initMenuPopup(List<ActionButtonDefinition<T>> actions) { if (menuPopup == null) { menuPopup = new DropDownMenu(); } for (final ActionButtonDefinition<T> buttonDef : actions) { if (buttonDef instanceof UiMenuBarButtonDefinition) { UiMenuBarButtonDefinition<T> menuBarDef = (UiMenuBarButtonDefinition<T>) buttonDef; DropDownHeader subMenuHeader = new DropDownHeader(buttonDef.getText()); menuPopup.add(new Divider()); menuPopup.add(subMenuHeader); initMenuPopup(menuBarDef.getSubActions()); } else { AnchorListItem menuItem = new AnchorListItem(buttonDef.getText()); <START> menuItem.addClickHandler(new ClickHandler() { <END> @Override public void onClick(ClickEvent event) { buttonDef.onClick(selectedItemsProvider.getSelectedItems()); } }); updateMenuItem(menuItem, buttonDef, selectedItemsProvider.getSelectedItems()); menuPopup.add(menuItem); items.add(new Pair<>(menuItem, buttonDef)); } } add(menuPopup); }</code><technical_language>event -> { buttonDef.onClick..</technical_language>

Target:
private void initMenuPopup(List<ActionButtonDefinition<T>> actions) { if (menuPopup == null) { menuPopup = new DropDownMenu(); } for (final ActionButtonDefinition<T> buttonDef : actions) { if (buttonDef instanceof UiMenuBarButtonDefinition) { UiMenuBarButtonDefinition<T> menuBarDef = (UiMenuBarButtonDefinition<T>) buttonDef; DropDownHeader subMenuHeader = new DropDownHeader(buttonDef.getText()); menuPopup.add(new Divider()); menuPopup.add(subMenuHeader); initMenuPopup(menuBarDef.getSubActions()); } else { AnchorListItem menuItem = new AnchorListItem(buttonDef.getText()); menuItem.addClickHandler(e -> { buttonDef.onClick(selectedItemsProvider.getSelectedItems()); }); updateMenuItem(menuItem, buttonDef, selectedItemsProvider.getSelectedItems()); menuPopup.add(menuItem); items.add(new Pair<>(menuItem, buttonDef)); } } add(menuPopup); }
Source:
<code>private MaxwellAbstractRowsEvent processRowsEvent(AbstractRowEvent e) throws SchemaSyncError { MaxwellAbstractRowsEvent ew; Table table; table = tableCache.getTable(e.getTableId()); if ( table == null && this.filter.hasTableBlacklist() ) { LOGGER.warn(String.format("couldn't find table in cache for table id: %d, assuming blacklisted table", e.getTableId())); <START> return null; <END> } else if ( table == null ) { throw new SchemaSyncError("couldn't find table in cache for table id: " + e.getTableId()); } switch (e.getHeader().getEventType()) { case MySQLConstants.WRITE_ROWS_EVENT: ew = new MaxwellWriteRowsEvent((WriteRowsEvent) e, table, filter); break; case MySQLConstants.WRITE_ROWS_EVENT_V2: ew = new MaxwellWriteRowsEvent((WriteRowsEventV2) e, table, filter); break; case MySQLConstants.UPDATE_ROWS_EVENT: ew = new MaxwellUpdateRowsEvent((UpdateRowsEvent) e, table, filter); break; case MySQLConstants.UPDATE_ROWS_EVENT_V2: ew = new MaxwellUpdateRowsEvent((UpdateRowsEventV2) e, table, filter); break; case MySQLConstants.DELETE_ROWS_EVENT: ew = new MaxwellDeleteRowsEvent((DeleteRowsEvent) e, table, filter); break; case MySQLConstants.DELETE_ROWS_EVENT_V2: ew = new MaxwellDeleteRowsEvent((DeleteRowsEventV2) e, table, filter); break; default: return null; } return ew; }</code><technical_language>hmmm, this is a tick unelegant. this approach instead: - in TableMapCache, maintain a separate Set of table ids blacklisted. ask tableCache.isBlacklisted(e.getTableId) leave SchemaSyncError in place</technical_language>

Target:
private MaxwellAbstractRowsEvent processRowsEvent(AbstractRowEvent e) throws SchemaSyncError { MaxwellAbstractRowsEvent ew; Table table; long tableId = e.getTableId(); if ( tableCache.isTableBlacklisted(tableId) ) { LOGGER.debug(String.format("ignoring row event for blacklisted table %s", tableCache.getBlacklistedTableName(tableId))); return null; } table = tableCache.getTable(tableId); if ( table == null ) { throw new SchemaSyncError("couldn't find table in cache for table id: " + tableId); } switch (e.getHeader().getEventType()) { case MySQLConstants.WRITE_ROWS_EVENT: ew = new MaxwellWriteRowsEvent((WriteRowsEvent) e, table, filter); break; case MySQLConstants.WRITE_ROWS_EVENT_V2: ew = new MaxwellWriteRowsEvent((WriteRowsEventV2) e, table, filter); break; case MySQLConstants.UPDATE_ROWS_EVENT: ew = new MaxwellUpdateRowsEvent((UpdateRowsEvent) e, table, filter); break; case MySQLConstants.UPDATE_ROWS_EVENT_V2: ew = new MaxwellUpdateRowsEvent((UpdateRowsEventV2) e, table, filter); break; case MySQLConstants.DELETE_ROWS_EVENT: ew = new MaxwellDeleteRowsEvent((DeleteRowsEvent) e, table, filter); break; case MySQLConstants.DELETE_ROWS_EVENT_V2: ew = new MaxwellDeleteRowsEvent((DeleteRowsEventV2) e, table, filter); break; default: return null; } return ew; }
Source:
<code>public void testFilterWithCredentials() { HttpRequest request = HttpRequest.builder().method("GET").endpoint("htto://localhost/foo").build(); Credentials credentials = LoginCredentials.builder().identity("foo").credential("bar").build(); AuthenticationFilter filter = new AuthenticationFilter(Suppliers.ofInstance(credentials)); HttpRequest filtered = filter.filter(request); String queryLine = filtered.getRequestLine().trim() <START> .substring(filtered.getRequestLine().indexOf('?') + 1, filtered.getRequestLine().lastIndexOf(' ')); <END> Multimap<String, String> params = queryParser().apply(queryLine); assertEquals(getOnlyElement(params.get(IDENTITY_PARAM)), "foo"); assertEquals(getOnlyElement(params.get(CREDENTIAL_PARAM)), "bar"); }</code><technical_language>extracting here? Easier do URL URI of builders</technical_language>

Target:
public void testFilterWithCredentials() { HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost/foo").build(); Credentials credentials = LoginCredentials.builder().identity("foo").credential("bar").build(); AuthenticationFilter filter = new AuthenticationFilter(Suppliers.ofInstance(credentials)); HttpRequest filtered = filter.filter(request); String queryLine = filtered.getRequestLine().trim() .substring(filtered.getRequestLine().indexOf('?') + 1, filtered.getRequestLine().lastIndexOf(' ')); Multimap<String, String> params = queryParser().apply(queryLine); assertEquals(getOnlyElement(params.get(IDENTITY_PARAM)), "foo"); assertEquals(getOnlyElement(params.get(CREDENTIAL_PARAM)), "bar"); }
Source:
<code>public List<TaskInfo> getActiveTaskInfo() { return getConnector().retryWithHandle( handle -> { return handle.createQuery( StringUtils.format( "SELECT id, status_payload, datasource, created_date FROM %s WHERE active = TRUE ORDER BY created_date", entryTable ) <START> ).map(new TaskMapper()).list(); <END> } ); }</code><technical_language>This TaskMapper a singleton, like: java public static final TaskMapper INSTANCE = new TaskMapper(); In TaskMapper class. a big thing, a bit more hygienic (it emphasizes objects data / state is necessary). is a minor efficiency gain well, is small matter</technical_language>

Target:
public List<TaskInfo<EntryType>> getActiveTaskInfo() { return getConnector().retryWithHandle( handle -> { return handle.createQuery( StringUtils.format( "SELECT id, status_payload, payload, datasource, created_date FROM %s WHERE active = TRUE ORDER BY created_date", entryTable ) ).map(new TaskInfoMapper()).list(); } ); }
Source:
<code>public void setMainTabSelectedItem(Erratum selectedItem) { <START> logger.info("setMainTabSelectedItem"); END> updateErrataDetailFormPanel(selectedItem); }</code><technical_language>debug/trace/remove</technical_language>

Target:
public void setMainTabSelectedItem(Erratum selectedItem) { updateErrataDetailFormPanel(selectedItem); }
Source:
<code><START> public void testNonZeroExitCodeException() { <END> DoNothingWinRmSoftwareProcessDriver nativeWindowsScriptRunner = mock(DoNothingWinRmSoftwareProcessDriver.class); when(nativeWindowsScriptRunner.executeCommand(any(Map.class), any(String.class), any(String.class), any(String.class), any(Boolean.class))).thenReturn(1); WinRmExecuteHelper scriptHelper = new WinRmExecuteHelper(nativeWindowsScriptRunner, "test-zero-code-task") .failOnNonZeroResultCode() .setCommand(NON_ZERO_CODE_COMMAND); Asserts.assertTrue(scriptHelper.executeInternal() != 0, "WinRmExecuteHelper return zero code for non-zero code task"); }</code><technical_language>This method's body testNonZeroExitCode. asserting expectedExceptions above, strip out extra code (e.g. assertTrue end of this method)</technical_language>

Target:
public void testNonZeroExitCodeException() { DoNothingWinRmSoftwareProcessDriver nativeWindowsScriptRunner = mock(DoNothingWinRmSoftwareProcessDriver.class); when(nativeWindowsScriptRunner.executeNativeOrPsCommand(any(Map.class), any(String.class), any(String.class), any(String.class), any(Boolean.class))).thenReturn(1); WinRmExecuteHelper scriptHelper = new WinRmExecuteHelper(nativeWindowsScriptRunner, "test-zero-code-task") .failOnNonZeroResultCode() .setCommand(NON_ZERO_CODE_COMMAND); scriptHelper.executeInternal(); }
Source:
<code>private static Collection<?> typeScriptExtensions() { return Arrays.asList( TypeScriptLanguage.class, PropertyDefinition.builder(TypeScriptLanguage.FILE_SUFFIXES_KEY) <START> .defaultValue(TypeScriptLanguage.FILE_SUFFIXES_DEFVALUE) <END> .name("File Suffixes") .description("Comma-separated list of suffixes for files to analyze.") .subCategory(GENERAL_SUBCATEGORY) .category(TYPESCRIPT_CATEGORY) .onQualifiers(Qualifiers.PROJECT) .multiValues(true) .build() ); }</code><technical_language>is indentation here</technical_language>

Target:
private static Collection<?> typeScriptExtensions() { return Arrays.asList( TypeScriptLanguage.class, PropertyDefinition.builder(TypeScriptLanguage.FILE_SUFFIXES_KEY) .defaultValue(TypeScriptLanguage.FILE_SUFFIXES_DEFVALUE) .name(FILE_SUFFIXES_NAME) .description(FILE_SUFFIXES_DESCRIPTION) .subCategory(GENERAL) .category(TYPESCRIPT_CATEGORY) .onQualifiers(Qualifiers.PROJECT) .multiValues(true) .build() ); }
Source:
<code>private void detectSlaveChanges() { for (VdsNetworkInterface newIface : params.getInterfaces()) { if (!isBond(newIface) && newIface.getVlanId() == null) { String bondNameInNewIface = newIface.getBondName(); String bondNameInOldIface = getExistingIfaces().get(newIface.getName()).getBondName(); <START> if (!StringUtils.equals(bondNameInNewIface, bondNameInOldIface)) { <END> if (bondNameInNewIface != null && !modifiedBonds.containsKey(bondNameInNewIface)) { modifiedBonds.put(bondNameInNewIface, getExistingIfaces().get(bondNameInNewIface)); } if (bondNameInOldIface != null && !removedBonds.contains(bondNameInOldIface)) { modifiedBonds.put(bondNameInOldIface, getExistingIfaces().get(bondNameInOldIface)); } } } } }</code><technical_language>need verify bond is in modified list, simplify code</technical_language>

Target:
private void detectSlaveChanges() { for (VdsNetworkInterface newIface : params.getInterfaces()) { if (!isBond(newIface) && newIface.getVlanId() == null) { String bondNameInNewIface = newIface.getBondName(); String bondNameInOldIface = getExistingIfaces().get(newIface.getName()).getBondName(); if (!StringUtils.equals(bondNameInNewIface, bondNameInOldIface)) { if (bondNameInNewIface != null && !modifiedBonds.containsKey(bondNameInNewIface)) { modifiedBonds.put(bondNameInNewIface, getExistingIfaces().get(bondNameInNewIface)); } if (bondNameInOldIface != null && !modifiedBonds.containsKey(bondNameInNewIface) && !removedBonds.contains(bondNameInOldIface)) { modifiedBonds.put(bondNameInOldIface, getExistingIfaces().get(bondNameInOldIface)); } } } } }
Source:
<code>public CommandResult<?> execute(final Object context, final CommandManager commandManager) { if (registry.isEmpty()) { <START> return null; <END> } final C last = registry.peek(); return commandManager.execute(context, last); }</code><technical_language>hey @hasys , this null... knowing I wrote hehe.. sounds good tbh. a null command result means? possible, included!, try refactor throw a runtime exception return some kind of failed result, in order developer idea previously checking registry size. for command results... WDYT? some others null usages this in other classes, sounds incremental task..</technical_language>

Target:
public CommandResult<?> execute(final Object context, final CommandManager commandManager) { if (registry.isEmpty()) { throw new IllegalStateException("Not possible to execute a command: no commands to redo."); } final C last = registry.peek(); return commandManager.execute(context, last); }