auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public String getJourneyJson(final String plan, final String itineraryPoints, final String leaving, final String arriving, final int speed) throws IOException { Response<String> response = v1Api.getJourneyJson(plan, itineraryPoints, leaving, arriving, speed).execute(); <START> return JourneyStringTransformer.INSTANCE.fromV1ApiJson(response.body()); <END> }</code><technical_language>I avoid this .INSTANCE. business putting fromV1APIJson method a companion object</technical_language>

Target:
public String getJourneyJson(final String plan, final String itineraryPoints, final String leaving, final String arriving, final int speed) throws IOException { Response<String> response = v1Api.getJourneyJson(plan, itineraryPoints, leaving, arriving, speed).execute(); return JourneyStringTransformerKt.fromV1ApiJson(response.body()); }
Source:
<code>public TestUtils() { File userHome = customUserHome(); if (userHome == null) userHome = FS.DETECTED.userHome(); <START> rootDir = new File(userHome, "egitTest" + System.currentTimeMillis() <END> + "-" + Integer.toHexString(System.identityHashCode(this))); }</code><technical_language>change string "EGitTestTemp-" + ...? Including "temp" "tmp" clear safely deleted in case is lying aborted test</technical_language>

Target:
public TestUtils() { File testDir = getCustomTestDirectory(); if (testDir == null) { testDir = FS.DETECTED.userHome(); testDir = new File(testDir, "egit.test.tmpdir"); } rootDir = new File(testDir, "egitTest" + System.currentTimeMillis() + "-" + Integer.toHexString(System.identityHashCode(this))); }
Source:
<code>protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException { TaggedValuePointable key, value, qmc, tvp; ArrayBackedValueStorage abvs = abvsPool.takeOne(); <START> ArrayBackedValueStorage abvs1 = abvsPool.takeOne(); <END> try { abvs.reset(); ob.reset(abvs); tvps.clear(); int len = args.length; for (int i = 0; i < len; i += 3) { key = args[i]; value = args[i + 1]; qmc = args[i + 2]; if (!isDuplicateKeys(key, tvps)) { tvps.add(key); key.getValue(sp); if (value.getTag() == ValueTag.SEQUENCE_TAG) { qmc.getValue(bp); value.getValue(seqp); if (seqp.getEntryCount() == 0) { if (bp.getBoolean()) { continue; } XDMConstants.setJsNull(value); ob.addItem(sp, value); } else { abvs1.reset(); ab.reset(abvs1); int l = seqp.getEntryCount(); for (int j = 0; j < l; j++) { seqp.getEntry(j, value); ab.addItem(value); } ab.finish(); vp.set(abvs1); ob.addItem(sp, vp); } } else { ob.addItem(sp, value); } } else { throw new SystemException(ErrorCode.JNDY0003); } } ob.finish(); result.set(abvs); } catch (IOException e) { throw new SystemException(ErrorCode.SYSE0001, e); } finally { abvsPool.giveBack(abvs); abvsPool.giveBack(abvs1); } }</code><technical_language>more descriptive names for abvs variables? abvsResult abvsItem? Do sense</technical_language>

Target:
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException { TaggedValuePointable key, value, qmc, tvp; ArrayBackedValueStorage abvsResult = abvsPool.takeOne(); ArrayBackedValueStorage abvsItem = abvsPool.takeOne(); try { abvsResult.reset(); ob.reset(abvsResult); tvps.clear(); int len = args.length; for (int i = 0; i < len; i += 3) { key = args[i]; value = args[i + 1]; qmc = args[i + 2]; if (!isDuplicateKeys(key, tvps)) { tvps.add(key); key.getValue(sp); if (value.getTag() == ValueTag.SEQUENCE_TAG) { qmc.getValue(bp); value.getValue(seqp); if (seqp.getEntryCount() == 0) { if (bp.getBoolean()) { continue; } XDMConstants.setJsNull(value); ob.addItem(sp, value); } else { abvsItem.reset(); ab.reset(abvsItem); int l = seqp.getEntryCount(); for (int j = 0; j < l; j++) { seqp.getEntry(j, value); ab.addItem(value); } ab.finish(); vp.set(abvsItem); ob.addItem(sp, vp); } } else { ob.addItem(sp, value); } } else { throw new SystemException(ErrorCode.JNDY0003); } } ob.finish(); result.set(abvsResult); } catch (IOException e) { throw new SystemException(ErrorCode.SYSE0001, e); } finally { abvsPool.giveBack(abvsResult); abvsPool.giveBack(abvsItem); } }
Source:
<code>public void deleteAllGrants(final String username, final String password) throws Exception { List<String> grandsId = getAllGrants(username, password); for (String grandId : grandsId) { String url = "<LINK_1>" + grandId; requestFactory .fromUrl(url) .useDeleteMethod() .setAuthorizationHeader(createBasicAuthHeader(username, password)) .request(); } <START> LOG.debug(format("Application grants '%s' were removed from github.com", grandsId)); <END> }</code><technical_language><LINK_0></technical_language>

Target:
public void deleteAllGrants(final String username, final String password) throws Exception { List<String> grandsId = getAllGrants(username, password); for (String grandId : grandsId) { String url = "<LINK_1>" + grandId; requestFactory .fromUrl(url) .useDeleteMethod() .setAuthorizationHeader(createBasicAuthHeader(username, password)) .request(); } LOG.debug("Application grants '{}' were removed from github.com", grandsId); }
Source:
<code>public List<Integer> getMemberPartitions(Address target) { <START> List<Integer> ownedPartitions = new ArrayList<>(); <END> for (int i = 0; i < partitionCount; i++) { final Address owner = getPartitionOwner(i); if (target.equals(owner)) { ownedPartitions.add(i); } } return ownedPartitions; }</code><technical_language>create arrays this change if high partition counts? calculate size upfront</technical_language>

Target:
public List<Integer> getMemberPartitions(Address target) { List<Integer> ownedPartitions = new LinkedList<>(); for (int i = 0; i < partitionCount; i++) { final Address owner = getPartitionOwner(i); if (target.equals(owner)) { ownedPartitions.add(i); } } return ownedPartitions; }
Source:
<code>private void validateInput() { if (getShell() == null) { return; } String tagNameMessage = tagNameValidator.isValid(tagNameText.getText()); setErrorMessage(tagNameMessage); String tagMessageVal = tagMessageText.getText().trim(); boolean isLightWeight = lightweightButton.getSelection(); Control button = getButton(IDialogConstants.OK_ID); if (button != null) { boolean containsTagNameAndMessage = (tagNameMessage == null || tagMessageVal .length() == 0) && tagMessageVal.length() != 0; boolean shouldOverwriteTag = (overwriteButton.getSelection() && Repository .isValidRefName(Constants.R_TAGS + tagNameText.getText())); boolean enabled = containsTagNameAndMessage || shouldOverwriteTag || (isLightWeight && tagNameMessage == null && !tagNameText.getText().isEmpty()); button.setEnabled(enabled); Button createTagAndStartPush = getButton(CREATE_AND_START_PUSH_ID); if (createTagAndStartPush != null) createTagAndStartPush.setEnabled(enabled); } boolean existingTagSelected = existingTag != null; <START> if ((existingTagSelected && !overwriteButton.getSelection()) || isLightWeight) { <END> tagMessageText.getTextWidget().setEditable(false); } else tagMessageText.getTextWidget().setEditable(true); overwriteButton.setEnabled(existingTagSelected); if (!existingTagSelected) overwriteButton.setSelection(false); }</code><technical_language>while this if-else previously, please convert this simple statements editable = ... setEditable(...)</technical_language>

Target:
private void validateInput() { if (getShell() == null) { return; } String tagNameMessage = tagNameValidator.isValid(tagNameText.getText()); setErrorMessage(tagNameMessage); String tagMessageVal = tagMessageText.getText().trim(); boolean isLightWeight = lightweightButton.getSelection(); Control button = getButton(IDialogConstants.OK_ID); if (button != null) { boolean containsTagNameAndMessage = (tagNameMessage == null || tagMessageVal .length() == 0) && tagMessageVal.length() != 0; boolean shouldOverwriteTag = (overwriteButton.getSelection() && Repository .isValidRefName(Constants.R_TAGS + tagNameText.getText())); boolean enabled = containsTagNameAndMessage || shouldOverwriteTag || (isLightWeight && tagNameMessage == null && !tagNameText.getText().isEmpty()); button.setEnabled(enabled); Button createTagAndStartPush = getButton(CREATE_AND_START_PUSH_ID); if (createTagAndStartPush != null) createTagAndStartPush.setEnabled(enabled); } boolean existingTagSelected = existingTag != null; boolean editable = (existingTagSelected && !overwriteButton.getSelection()) || isLightWeight; tagMessageText.getTextWidget().setEditable(editable); overwriteButton.setEnabled(existingTagSelected); if (!existingTagSelected) overwriteButton.setSelection(false); }
Source:
<code>public void javaToNative(Object object, TransferData transferData) { if (!checkMyType(object) || !isSupportedType(transferData)) { DND.error(DND.ERROR_INVALID_DATA); } ArrayList<CapraOfficeObject> officeObjects = (ArrayList<CapraOfficeObject>) object; try (ByteArrayOutputStream out = new ByteArrayOutputStream(); DataOutputStream writeOut = new DataOutputStream(out)) { for (int i = 0; i < officeObjects.size(); i++) { CapraOfficeObject currOfficeObject = officeObjects.get(i); byte[] buffer = currOfficeObject.getData().getBytes(); writeOut.writeInt(buffer.length); writeOut.write(buffer); buffer = currOfficeObject.getUri().getBytes(); writeOut.writeInt(buffer.length); writeOut.write(buffer); } byte[] bufferOut = out.toByteArray(); super.javaToNative(bufferOut, transferData); } catch (IOException e) { <START> <END> } }</code><technical_language>If happen here, please add // Deliberately do nothing</technical_language>

Target:
public void javaToNative(Object object, TransferData transferData) { if (!checkMyType(object) || !isSupportedType(transferData)) { DND.error(DND.ERROR_INVALID_DATA); } ArrayList<CapraOfficeObject> officeObjects = (ArrayList<CapraOfficeObject>) object; try (ByteArrayOutputStream out = new ByteArrayOutputStream(); DataOutputStream writeOut = new DataOutputStream(out)) { for (int i = 0; i < officeObjects.size(); i++) { CapraOfficeObject currOfficeObject = officeObjects.get(i); byte[] buffer = currOfficeObject.getData().getBytes(); writeOut.writeInt(buffer.length); writeOut.write(buffer); buffer = currOfficeObject.getUri().getBytes(); writeOut.writeInt(buffer.length); writeOut.write(buffer); } byte[] bufferOut = out.toByteArray(); super.javaToNative(bufferOut, transferData); } catch (IOException e) { e.printStackTrace(); } }
Source:
<code>public String toString() { <START> return "CloudObjectLocation {" <END> + "bucket=" + bucket + ",path=" + path + "}"; }</code><technical_language>formatting is a weird here</technical_language>

Target:
public String toString() { return "CloudObjectLocation{" + "bucket='" + bucket + '\'' + ", path='" + path + '\'' + '}'; }
Source:
<code>public List<String> getQueries() throws Exception { List<String> queries = new ArrayList<>(); <START> queries.add(getClearTableQuery()); <END> if (log.isDebugEnabled()) { log.debug("Generated SQL queries to clear table:"); for (String q : queries) { log.debug(q); } } return queries; }</code><technical_language>nice **queries.add(query)** in for loop logg added. do think</technical_language>

Target:
public List<String> getQueries() throws Exception { List<String> queries = new ArrayList<>(); queries.add(getClearTableQuery()); if (LOG.isDebugEnabled()) { LOG.debug("Generated SQL queries to clear table:"); for (String q : queries) { LOG.debug(q); } } return queries; }
Source:
<code>public void eventDispatched(IExitedDMEvent e) { <START> IDMContext dmc = e.getDMContext(); <END> boolean restarting = fProcRestarting.contains(dmc); if (!restarting && dmc instanceof IContainerDMContext) { MIBreakpointsManager bpService = getServicesTracker().getService(MIBreakpointsManager.class); bpService.removeTargetFilter((IContainerDMContext) dmc); } if (dmc instanceof IBreakpointsTargetDMContext) { if (!fProcRestarting.remove(dmc)) { if (fBackend.getSessionType() != SessionType.CORE) { IBreakpointsTargetDMContext bpTargetDmc = (IBreakpointsTargetDMContext)dmc; MIBreakpointsManager bpmService = getServicesTracker().getService(MIBreakpointsManager.class); if (bpmService != null) { bpmService.stopTrackingBreakpoints(bpTargetDmc, new ImmediateRequestMonitor() { @Override protected void handleCompleted() { } }); } } } } super.eventDispatched(e); }</code><technical_language>avoid line for thread-exit event, I suggest putting if (dmc instanceof IContainerDMContext) everything, logic already. if (dmc instanceof IBreakpointsTargetDMContext) care of before, do anyway</technical_language>

Target:
public void eventDispatched(IExitedDMEvent e) { IDMContext dmc = e.getDMContext(); if (dmc instanceof IContainerDMContext) { MIBreakpointsManager bpmService = getServicesTracker().getService(MIBreakpointsManager.class); boolean restarting = fProcRestarting.remove(dmc); if (bpmService != null) { if (!restarting) { bpmService.removeTargetFilter((IContainerDMContext) dmc); if (dmc instanceof IBreakpointsTargetDMContext) { if (fBackend.getSessionType() != SessionType.CORE) { IBreakpointsTargetDMContext bpTargetDmc = (IBreakpointsTargetDMContext) dmc; bpmService.stopTrackingBreakpoints(bpTargetDmc, new ImmediateRequestMonitor() { @Override protected void handleCompleted() { } }); } } } } } super.eventDispatched(e); }
Source:
<code>private Optional<IdentifiedVersion> processEventLogUpdate(LockWatchStateUpdate update) { Optional<IdentifiedVersion> currentVersion = eventLog.getLatestKnownVersion(); Optional<IdentifiedVersion> latestVersion = eventLog.processUpdate(update); <START> if (!(latestVersion.isPresent() <END> && currentVersion.isPresent() && latestVersion.get().id().equals(currentVersion.get().id()) && update.accept(SuccessVisitor.INSTANCE))) { timestampMap.clear(); } return latestVersion; }</code><technical_language>This scary here: I want return type of #processUpdate event reset</technical_language>

Target:
private Optional<IdentifiedVersion> processEventLogUpdate(LockWatchStateUpdate update) { CacheUpdate cacheUpdate = eventLog.processUpdate(update); if (cacheUpdate.shouldClearCache()) { timestampStateStore.clear(); } return cacheUpdate.getVersion(); }
Source:
<code>public static boolean setLockscreenBackground() { <START> return prefs.getBoolean(PREF_LOCKSCREEN_BACKGROUND, false); <END> }</code><technical_language>I 'false' needs get changed true. For some reason 'default' in preferences work otherwise. shows checked work uncheck/check again. works this way. :( (Tested 5.0.0 5.1)</technical_language>

Target:
public static boolean setLockscreenBackground() { return prefs.getBoolean(PREF_LOCKSCREEN_BACKGROUND, true); }
Source:
<code>private boolean createNewLogFile() { if (!outputDirectory.exists()) { <START> if (!outputDirectory.mkdirs()) { <END> new RobobuggyLogicNotification("Couldn't create logs folder!", RobobuggyMessageLevel.EXCEPTION); return false; } if (!outputDirectory.isDirectory()) { new RobobuggyLogicNotification("Output directory path isn't a folder!", RobobuggyMessageLevel.EXCEPTION); return false; } } Date logCreationDate = new Date(); outputDirectory = new File(RobobuggyConfigFile.LOG_FILE_LOCATION + "/" + formatDateIntoFile(logCreationDate)); if (!outputDirectory.mkdirs()) { new RobobuggyLogicNotification("Couldn't create log's container!", RobobuggyMessageLevel.EXCEPTION); return false; } outputFile = new File(outputDirectory.getPath() + "/" + RobobuggyConfigFile.LOG_FILE_NAME + "_" + formatDateIntoFile(logCreationDate) + ".txt") ; try { if (!outputFile.createNewFile()) { new RobobuggyLogicNotification("Couldn't create log file!", RobobuggyMessageLevel.EXCEPTION); return false; } } catch (IOException e) { new RobobuggyLogicNotification("Error reading the filesystem!", RobobuggyMessageLevel.EXCEPTION); return false; } return true; }</code><technical_language>mkdirs necessary parent directories, do need call twice</technical_language>

Target:
private boolean createNewLogFile() { Date logCreationDate = new Date(); outputDirectory = new File(RobobuggyConfigFile.LOG_FILE_LOCATION + "/" + formatDateIntoFile(logCreationDate)); if (!outputDirectory.mkdirs()) { new RobobuggyLogicNotification("Couldn't create log's container!", RobobuggyMessageLevel.EXCEPTION); return false; } outputFile = new File(outputDirectory.getPath() + "/" + RobobuggyConfigFile.LOG_FILE_NAME + "_" + formatDateIntoFile(logCreationDate) + ".txt") ; try { if (!outputFile.createNewFile()) { new RobobuggyLogicNotification("Couldn't create log file!", RobobuggyMessageLevel.EXCEPTION); return false; } } catch (IOException e) { new RobobuggyLogicNotification("Error reading the filesystem!", RobobuggyMessageLevel.EXCEPTION); return false; } return true; }
Source:
<code>LoadElasticsearch(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { <START> super(config, parent, child, context); <END> elapsedTime = getTimer(Metrics.ELAPSED_TIME); Config elasticsearchConfig = getConfigs().getConfig(config, ELASTICSEARCH_CONFIGURATION); String loaderType = config.getString(DOCUMENT_LOADER_TYPE); indexName = config.getString(COLLECTION); indexType = config.getString(TYPE); ttl = config.getInt(TTL); DocumentLoaderFactory documentLoaderFactory = new DocumentLoaderFactory(); try { loader = documentLoaderFactory.getClient(loaderType, elasticsearchConfig); } catch (NoSuchDocumentLoaderException e) { throw new MorphlineRuntimeException(e); } }</code><technical_language>this constructor is deprecated - instead super(builder, config, parent, child, context);</technical_language>

Target:
LoadElasticsearch(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); elapsedTime = getTimer(Metrics.ELAPSED_TIME); Config elasticsearchConfig = getConfigs().getConfig(config, ELASTICSEARCH_CONFIGURATION); String loaderType = getConfigs().getString(config, DOCUMENT_LOADER_TYPE); indexName = getConfigs().getString(config, COLLECTION); indexType = getConfigs().getString(config, TYPE); ttl = getConfigs().getInt(config, TTL); validateArguments(); DocumentLoaderFactory documentLoaderFactory = new DocumentLoaderFactory(); try { loader = documentLoaderFactory.getClient(loaderType, elasticsearchConfig); } catch (IllegalArgumentException e) { throw new MorphlineRuntimeException(e); } }
Source:
<code>public Response getContentTypeFieldByVar(@PathParam("typeId") final String typeId, @PathParam("fieldVar") final String fieldVar, @Context final HttpServletRequest req) throws DotDataException, DotSecurityException { <START> <END> Response response = null; try { Field field = fieldAPI.byContentTypeIdAndVar(typeId, fieldVar); response = Response.ok(new ResponseEntityView(new JsonFieldTransformer(field).mapObject())).build(); } catch (Exception e) { response = ResponseUtil.mapExceptionResponse(e); } return response; }</code><technical_language>I this validation removed <LINK_0></technical_language>

Target:
public Response getContentTypeFieldByVar(@PathParam("typeId") final String typeId, @PathParam("fieldVar") final String fieldVar, @Context final HttpServletRequest req) throws DotDataException, DotSecurityException { this.webResource.init(null, false, req, false, null); Response response = null; try { final Field field = fieldAPI.byContentTypeIdAndVar(typeId, fieldVar); response = Response.ok(new ResponseEntityView(new JsonFieldTransformer(field).mapObject())).build(); } catch (Exception e) { response = ResponseUtil.mapExceptionResponse(e); } return response; }
Source:
<code>public static boolean verifyBucketsSupport(final ConfigContext config, final MantaClient client) { <START> AtomicBoolean isBucketsSupported = new AtomicBoolean(); <END> try { String path = String.format("%s/buckets", config.getMantaHomeDirectory()); client.get(path); isBucketsSupported.set(true); } catch (IOException io) { isBucketsSupported.set(false); } return isBucketsSupported.get(); }</code><technical_language>AtomicBoolean is unneeded here. Please research correct usage of it. A normal boolean variable is fine</technical_language>

Target:
private static boolean verifyBucketsSupport(final ConfigContext config, final MantaClient client) throws IOException { try { String path = String.format("%s%sbuckets", config.getMantaHomeDirectory(), MantaClient.SEPARATOR); client.options(path); } catch (MantaClientHttpResponseException me) { if (MantaErrorCode.RESOURCE_NOT_FOUND_ERROR.equals(me.getServerCode())) { return false; } } return true; }
Source:
<code>private CompletableFuture<Object> futureInvoke(final Message request, Function<Message, Object> fn) throws Exception { ResponseFuture responseFuture = new ResponseFuture(fn); <START> futures.putIfAbsent(responseFuture.correlationId(), responseFuture); <END> Message requestMessage = composeRequest(request, responseFuture.correlationId()); CompletableFuture<Void> sendFuture = sendRemote(requestMessage); sendFuture.whenComplete((success, error) -> { if (error != null) { ResponseFuture future = futures.remove(requestMessage.correlationId()); LOGGER.debug("cid send remote service request message failed , error {}", requestMessage.correlationId(), requestMessage, error); future.completeExceptionally(error); } }); return responseFuture.future(); }</code><technical_language>handling methods return void, put objects this map methods do send response removed a memory leak. I this map of futures is cleared for case if service response message lost. in case future in this map memory leak</technical_language>

Target:
private CompletableFuture<Object> futureInvoke(final Message request, Function<Message, Object> fn) throws Exception { ResponseFuture responseFuture = new ResponseFuture(fn); Message requestMessage = composeRequest(request, responseFuture.correlationId()); CompletableFuture<Void> sendFuture = sendRemote(requestMessage); sendFuture.whenComplete((success, error) -> { if (error != null) { LOGGER.debug("cid send remote service request message failed , error {}", requestMessage.correlationId(), requestMessage, error); Optional<ResponseFuture> future = ResponseFuture.get(requestMessage.correlationId()); if (future.isPresent()) { future.get().completeExceptionally(error); } } }); return responseFuture.future(); }
Source:
<code><START> int computeHeightDifference (GtkRequisition requisition, int height) { <END> int diffheight; diffheight = requisition.height - height; if (height - diffheight < 0) { return requisition.height; } else { return height; } }</code><technical_language>Group. motivation for defining in Control? other widgets also</technical_language>

Target:
int computeHeightDifference (GtkRequisition requisition, int height) { return (requisition.height - height) < 0 ? requisition.height : height; }
Source:
<code>private void onSimRefresh(AsyncResult ar, Integer index) { if (ar.exception != null) { Rlog.e(LOG_TAG, "Sim REFRESH with exception: " + ar.exception); return; } if (!isValidCardIndex(index)) { Rlog.e(LOG_TAG,"onSimRefresh: invalid index : " + index); return; } IccRefreshResponse resp = (IccRefreshResponse) ar.result; Rlog.d(LOG_TAG, "onSimRefresh: " + resp); if (resp == null) { Rlog.e(LOG_TAG, "onSimRefresh: received without input"); return; } if (mUiccCards[index] == null) { Rlog.e(LOG_TAG,"onSimRefresh: refresh on null card : " + index); return; } Rlog.d(LOG_TAG, "Handling refresh: " + resp); boolean changed = false; switch(resp.refreshResult) { case IccRefreshResponse.REFRESH_RESULT_RESET: case IccRefreshResponse.REFRESH_RESULT_INIT: changed = mUiccCards[index].resetAppWithAid(resp.aid); break; default: return; } if (changed && resp.refreshResult == IccRefreshResponse.REFRESH_RESULT_RESET) { boolean requirePowerOffOnSimRefreshReset = mContext.getResources().getBoolean( com.android.internal.R.bool.config_requireRadioPowerOffOnSimRefreshReset); if (requirePowerOffOnSimRefreshReset) { mCis[index].setRadioPower(false, null); } } mCis[index].getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE)); <START> mIccChangedRegistrants.notifyRegistrants(new <END> AsyncResult(null, index, null)); }</code><technical_language>I this is needed if changed is false</technical_language>

Target:
private void onSimRefresh(AsyncResult ar, Integer index) { if (ar.exception != null) { Rlog.e(LOG_TAG, "Sim REFRESH with exception: " + ar.exception); return; } if (!isValidCardIndex(index)) { Rlog.e(LOG_TAG,"onSimRefresh: invalid index : " + index); return; } IccRefreshResponse resp = (IccRefreshResponse) ar.result; Rlog.d(LOG_TAG, "onSimRefresh: " + resp); if (resp == null) { Rlog.e(LOG_TAG, "onSimRefresh: received without input"); return; } if (mUiccCards[index] == null) { Rlog.e(LOG_TAG,"onSimRefresh: refresh on null card : " + index); return; } Rlog.d(LOG_TAG, "Handling refresh: " + resp); boolean changed = false; switch(resp.refreshResult) { case IccRefreshResponse.REFRESH_RESULT_RESET: case IccRefreshResponse.REFRESH_RESULT_INIT: changed = mUiccCards[index].resetAppWithAid(resp.aid); break; default: return; } if (changed && resp.refreshResult == IccRefreshResponse.REFRESH_RESULT_RESET) { boolean requirePowerOffOnSimRefreshReset = mContext.getResources().getBoolean( com.android.internal.R.bool.config_requireRadioPowerOffOnSimRefreshReset); if (requirePowerOffOnSimRefreshReset) { mCis[index].setRadioPower(false, null); } } mCis[index].getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE, index)); }
Source:
<code>private void scanProjectTypes() { projectTypes = new ArrayList<>(); ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false); scanner.addIncludeFilter(new AnnotationTypeFilter(ProjectType.class)); for (BeanDefinition bd : scanner.findCandidateComponents("de.tudarmstadt.ukp")) { try { Class<?> clazz = (Class<?>) Class.forName(bd.getBeanClassName()); ProjectType pt = clazz.getAnnotation(ProjectType.class); if (projectTypes.stream().anyMatch(t -> t.id().equals(pt.id()))) { log.debug("Ignoring duplicate project type: ({})", pt.id(), pt.prio()); } else { log.debug("Found project type: ({})", pt.id(), pt.prio()); projectTypes.add(pt); } } catch (ClassNotFoundException e) { log.error("Class not found", bd.getBeanClassName(), e); } } projectTypes.sort((a, b) -> { <START> return a.prio() - b.prio(); <END> }); }</code><technical_language>comparingInt well, right</technical_language>

Target:
private void scanProjectTypes() { projectTypes = new ArrayList<>(); ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false); scanner.addIncludeFilter(new AnnotationTypeFilter(ProjectType.class)); for (BeanDefinition bd : scanner.findCandidateComponents("de.tudarmstadt.ukp")) { try { Class<?> clazz = (Class<?>) Class.forName(bd.getBeanClassName()); ProjectType pt = clazz.getAnnotation(ProjectType.class); if (projectTypes.stream().anyMatch(t -> t.id().equals(pt.id()))) { log.debug("Ignoring duplicate project type: ({})", pt.id(), pt.prio()); } else { log.debug("Found project type: ({})", pt.id(), pt.prio()); projectTypes.add(pt); } } catch (ClassNotFoundException e) { log.error("Class not found", bd.getBeanClassName(), e); } } projectTypes.sort(Comparator.comparingInt(ProjectType::prio)); }
Source:
<code>private void updateGMFFontStyle(View view, BasicLabelStyle basicLabelStyle) { FontStyle fontStyle = (FontStyle) createOrFindStyle(view, NotationPackage.eINSTANCE.getFontStyle()); List<FontFormat> labelFormat = basicLabelStyle.getLabelFormat(); if (labelFormat <START> == null) { <END> fontStyle.setBold(false); fontStyle.setItalic(false); fontStyle.setUnderline(false); fontStyle.setStrikeThrough(false); } else { for (FontFormat fontFormat : labelFormat) { switch (fontFormat.getValue()) { case FontFormat.BOLD: fontStyle.setBold(true); break; case FontFormat.ITALIC: fontStyle.setItalic(true); break; case FontFormat.UNDERLINE: fontStyle.setUnderline(true); break; case FontFormat.STRIKE_THROUGH: fontStyle.setStrikeThrough(true); break; default: break; } } } fontStyle.setFontHeight(basicLabelStyle.getLabelSize()); if (fontStyle.getFontName() == null) { fontStyle.setFontName(DEFAULT_FONT_STYLE); } RGBValues labelColor = basicLabelStyle.getLabelColor(); if (labelColor != null) { fontStyle.setFontColor(FigureUtilities.RGBToInteger(new RGB(labelColor.getRed(), labelColor.getGreen(), labelColor.getBlue()))); } }</code><technical_language>getLabelFormat return empty collection</technical_language>

Target:
private void updateGMFFontStyle(View view, BasicLabelStyle basicLabelStyle) { FontStyle fontStyle = (FontStyle) createOrFindStyle(view, NotationPackage.eINSTANCE.getFontStyle()); List<FontFormat> labelFormat = basicLabelStyle.getLabelFormat(); fontStyle.setBold(false); fontStyle.setItalic(false); fontStyle.setUnderline(false); fontStyle.setStrikeThrough(false); for (FontFormat fontFormat : labelFormat) { switch (fontFormat.getValue()) { case FontFormat.BOLD: fontStyle.setBold(true); break; case FontFormat.ITALIC: fontStyle.setItalic(true); break; case FontFormat.UNDERLINE: fontStyle.setUnderline(true); break; case FontFormat.STRIKE_THROUGH: fontStyle.setStrikeThrough(true); break; default: break; } } fontStyle.setFontHeight(basicLabelStyle.getLabelSize()); if (fontStyle.getFontName() == null) { fontStyle.setFontName(DEFAULT_FONT_STYLE); } RGBValues labelColor = basicLabelStyle.getLabelColor(); if (labelColor != null) { fontStyle.setFontColor(FigureUtilities.RGBToInteger(new RGB(labelColor.getRed(), labelColor.getGreen(), labelColor.getBlue()))); } }
Source:
<code>protected void setSchema(final String schema) throws DatabaseEngineException { try { this.conn.setSchema(schema); } catch (Exception e) { throw new DatabaseEngineException(String.format("Could not set current schema to '%s'", schema), e); <START> } <END> }</code><technical_language>final missing. for other ones</technical_language>

Target:
protected void setSchema(final String schema) throws DatabaseEngineException { try { this.conn.setSchema(schema); } catch (final Exception e) { throw new DatabaseEngineException(String.format("Could not set current schema to '%s'", schema), e); } }
Source:
<code>public void sessionDestroyed(HttpSessionEvent se) { LocationService locationService; ServletContext context = se.getSession().getServletContext(); Object principal = getPrincipalFromSession(se.getSession()); if (principal != null) { try { <START> locationService = getBeanFormApplicationContext(context, LocationService.class, "locationService"); <END> locationService.clearUserLocation(principal); } catch (Exception ex) { logger.warn("Error clearing user location when session being destroyed: " + ex.getMessage()); } } }</code><technical_language>Is retrieve bean once? performant this operation is in Spring.</technical_language>

Target:
public void sessionDestroyed(HttpSessionEvent se) { Object principal = getPrincipalFromSession(se.getSession()); if (principal != null) { try { locationService.clearUserLocation(principal); } catch (Exception ex) { logger.warn("Error clearing user location when session being destroyed: " + ex.getMessage()); } } }
Source:
<code>private static AbstractHandleClient getHandleServiceClient( final URL handleServiceUrl, final AuthToken handleMgrToken, final InitReporter rep) { final AbstractHandleClient cli; try { cli = new AbstractHandleClient( handleServiceUrl, handleMgrToken); if (handleServiceUrl.getProtocol().equals("http")) { rep.reportInfo("Warning - the Handle Service url uses insecure http. " + "https is recommended."); cli.setIsInsecureHttpConnectionAllowed(true); } } catch (Exception e) { <START> rep.reportFail("Could not establish a connection to the Handle Service at " <END> + handleServiceUrl + ": " + e.getMessage()); return null; } try { cli.isOwner(Arrays.asList("FAKEHANDLE_-100")); } catch (Exception e) { rep.reportFail("Could not successfullly run methods on the Handle Service at " + handleServiceUrl + ": " + e.getMessage()); return null; } return cli; }</code><technical_language>This message is misleading - initializing client validate anything. I IOException is for constructor if client code is thrown. I left isOwner() call in block</technical_language>

Target:
private static AbstractHandleClient getHandleServiceClient( final URL handleServiceUrl, final AuthToken handleMgrToken, final InitReporter rep) { final AbstractHandleClient cli; try { cli = new AbstractHandleClient( handleServiceUrl, handleMgrToken); if (handleServiceUrl.getProtocol().equals("http")) { rep.reportInfo("Warning - the Handle Service url uses insecure http. " + "https is recommended."); cli.setIsInsecureHttpConnectionAllowed(true); } cli.isOwner(Arrays.asList("FAKEHANDLE_-100")); } catch (Exception e) { rep.reportFail("Could not establish a connection to the Handle Service at " + handleServiceUrl + ": " + e.getMessage()); return null; } return cli; }
Source:
<code>private JSONBuilder writeCoordinate(Point point) throws JSONException { CoordinateSequence seq = point.getCoordinateSequence(); <START> if (!seq.hasM() || !encodeMeasures) { <END> if (seq.hasZ()) { return writeCoordinate(seq.getX(0), seq.getY(0), seq.getZ(0)); } else { return writeCoordinate(seq.getX(0), seq.getY(0)); } } else { if (seq.hasZ()) { return writeCoordinate(seq.getX(0), seq.getY(0), seq.getZ(0), seq.getM(0)); } else { return writeCoordinate(seq.getX(0), seq.getY(0), 0, seq.getM(0)); } } }</code><technical_language>logic this wish for EnumSet of XYZ, XYZM</technical_language>

Target:
private JSONBuilder writeCoordinate(Point point) throws JSONException { CoordinateSequence coordinates = point.getCoordinateSequence(); double m = encodeMeasures ? coordinates.getM(0) : Double.NaN; return writeCoordinate(coordinates.getX(0), coordinates.getY(0), coordinates.getZ(0), m); }
Source:
<code>private void showInfoLostDialog() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( this); <START> alertDialogBuilder.setTitle(getResources().getString(R.string.dialog_title_are_you_sure)); <END> alertDialogBuilder .setMessage(getResources().getString(R.string.dialog_message_data_lost)) .setCancelable(false) .setPositiveButton(getResources().getString(R.string.dialog_button_stay), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }) .setNegativeButton(getResources().getString(R.string.dialog_button_leave), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(AddEditPatientActivity.this, DashboardActivity.class); startActivity(intent); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }</code><technical_language>Is pass string id (you'd need import R) instead of calling getString? is more readable 64K limit issue</technical_language>

Target:
private void showInfoLostDialog() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( this); alertDialogBuilder.setTitle(R.string.dialog_title_are_you_sure); alertDialogBuilder .setMessage(R.string.dialog_message_data_lost) .setCancelable(false) .setPositiveButton(R.string.dialog_button_stay, (dialog, id) -> dialog.cancel()) .setNegativeButton(R.string.dialog_button_leave, (dialog, id) -> { Intent intent = new Intent(AddEditPatientActivity.this, DashboardActivity.class); startActivity(intent); }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
Source:
<code>public void testInverseBetaCdf() { <START> assertFunction("inverse_beta_cdf(3, 3.6, 0.)", DOUBLE, 0.); <END> assertFunction("inverse_beta_cdf(3, 3.6, 1.)", DOUBLE, 1.); assertFunction("inverse_beta_cdf(3, 3.6, 0.3)", DOUBLE, 0.3469675485440618); assertFunction("inverse_beta_cdf(3, 3.6, 0.95)", DOUBLE, 0.7600272463100223); assertInvalidFunction("inverse_beta_cdf(0, 3, 0.5)", "a, b must be > 0"); assertInvalidFunction("inverse_beta_cdf(3, 0, 0.5)", "a, b must be > 0"); assertInvalidFunction("inverse_beta_cdf(3, 5, -0.1)", "p must be 0 >= p >= 1"); assertInvalidFunction("inverse_beta_cdf(3, 5, 1.1)", "p must be 0 >= p >= 1"); }</code><technical_language>0. 1. read funny. 0.0 1.0, instead</technical_language>

Target:
public void testInverseBetaCdf() { assertFunction("inverse_beta_cdf(3, 3.6, 0.0)", DOUBLE, 0.0); assertFunction("inverse_beta_cdf(3, 3.6, 1.0)", DOUBLE, 1.0); assertFunction("inverse_beta_cdf(3, 3.6, 0.3)", DOUBLE, 0.3469675485440618); assertFunction("inverse_beta_cdf(3, 3.6, 0.95)", DOUBLE, 0.7600272463100223); assertInvalidFunction("inverse_beta_cdf(0, 3, 0.5)", "a must be > 0"); assertInvalidFunction("inverse_beta_cdf(3, 0, 0.5)", "b must be > 0"); assertInvalidFunction("inverse_beta_cdf(3, 5, -0.1)", "p must be in the interval [0, 1]"); assertInvalidFunction("inverse_beta_cdf(3, 5, 1.1)", "p must be in the interval [0, 1]"); }
Source:
<code>public ClientResponseImpl shouldAccept(AuthUser user, StoredProcedureInvocation invocation, Procedure sysProc) { final String procName = invocation.getProcName(); if ( ! procName.equals("@AdHoc") && ! procName.equals("@AdHocSpForTest")) { return null; } ParameterSet params = invocation.getParams(); <START> Object paramsArray = params.toArray(); <END> if (paramsArray.length < 1) { return new ClientResponseImpl(ClientResponseImpl.GRACEFUL_FAILURE, new VoltTable[0], "Adhoc system procedure requires at least the query parameter.", invocation.clientHandle); } if ((paramsArray[0] instanceof String) == false) { return new ClientResponseImpl(ClientResponseImpl.GRACEFUL_FAILURE, new VoltTable[0], "Adhoc system procedure requires the query parameter to be of String type.", invocation.clientHandle); } return null; }</code><technical_language>final</technical_language>

Target:
public ClientResponseImpl shouldAccept(AuthUser user, StoredProcedureInvocation invocation, Procedure sysProc) { final String procName = invocation.getProcName(); if ( ! procName.equals("@AdHoc") && ! procName.equals("@AdHocSpForTest")) { return null; } ParameterSet params = invocation.getParams(); final Object paramsArray = params.toArray(); if (paramsArray.length < 1) { return new ClientResponseImpl(ClientResponseImpl.GRACEFUL_FAILURE, new VoltTable[0], "Adhoc system procedure requires at least the query parameter.", invocation.clientHandle); } if ((paramsArray[0] instanceof String) == false) { return new ClientResponseImpl(ClientResponseImpl.GRACEFUL_FAILURE, new VoltTable[0], "Adhoc system procedure requires the query parameter to be of String type.", invocation.clientHandle); } return null; }
Source:
<code><START> public void createCustomPaymentPlan(final DateTime exemptionDate, final Map<LocalDate, Money> map) { <END> final DateTime when = new DateTime().minusSeconds(2); final DebtInterestCalculator debtInterestCalculator = getDebtInterestCalculator(when); final Money dueAmount = new Money(debtInterestCalculator.getDueAmount()); if (dueAmount.isZero() || dueAmount.isNegative()) { throw new DomainException("error.custom.payment.plan.cannot.be.created.for.event.without.debt"); } final Money mapValue = map.values().stream().reduce(Money.ZERO, Money::add); if (!dueAmount.equals(mapValue)) { throw new DomainException("error.custom.payment.plan.value.does.not.match.current.debt.value"); } final DueDateAmountMap currentMap = getDueDateAmountMap(); final LocalDate firstCustomDate = map.keySet().stream().min((d1, d2) -> d1.compareTo(d2)).orElse(null); final LocalDate lastCurrentDate = currentMap.keySet().stream().max((d1, d2) -> d1.compareTo(d2)).orElse(null); if (firstCustomDate.isBefore(lastCurrentDate)) { throw new DomainException("error.custom.payment.plan.must.be.after.currentPlan"); } currentMap.entrySet().forEach(e -> map.put(e.getKey(), e.getValue())); final EventExemption eventExemption = new EventExemption(this, Authenticate.getUser().getPerson(), dueAmount, EventExemptionJustificationType.CUSTOM_PAYMENT_PLAN, new DateTime(), EventExemptionJustificationType.CUSTOM_PAYMENT_PLAN.getLocalizedName()); eventExemption.setWhenCreated(when); setDueDateAmountMap(new DueDateAmountMap(map)); }</code><technical_language>parameter exemptionDate is used, passed exemption constructor</technical_language>

Target:
public void createCustomPaymentPlan(final DateTime exemptionDate, final Map<LocalDate, Money> map) { final DateTime when = new DateTime().minusSeconds(2); final DebtInterestCalculator debtInterestCalculator = getDebtInterestCalculator(when); final Money dueAmount = new Money(debtInterestCalculator.getDueAmount()); if (dueAmount.isZero() || dueAmount.isNegative()) { throw new DomainException("error.custom.payment.plan.cannot.be.created.for.event.without.debt"); } final Money mapValue = map.values().stream().reduce(Money.ZERO, Money::add); if (!dueAmount.equals(mapValue)) { throw new DomainException("error.custom.payment.plan.value.does.not.match.current.debt.value"); } final DueDateAmountMap currentMap = getDueDateAmountMap(); final LocalDate firstCustomDate = map.keySet().stream().min((d1, d2) -> d1.compareTo(d2)).orElse(null); final LocalDate lastCurrentDate = currentMap.keySet().stream().max((d1, d2) -> d1.compareTo(d2)).orElse(null); if (firstCustomDate.isBefore(lastCurrentDate)) { throw new DomainException("error.custom.payment.plan.must.be.after.currentPlan"); } currentMap.entrySet().forEach(e -> map.put(e.getKey(), e.getValue())); final EventExemption eventExemption = new EventExemption(this, Authenticate.getUser().getPerson(), dueAmount, EventExemptionJustificationType.CUSTOM_PAYMENT_PLAN, new DateTime(), EventExemptionJustificationType.CUSTOM_PAYMENT_PLAN.getLocalizedName()); eventExemption.setWhenCreated(exemptionDate); setDueDateAmountMap(new DueDateAmountMap(map)); }
Source:
<code>public void remove(Replicator replicator) { synchronized (replicatorsInProgress) { if (replicatorsInProgress.remove(replicator)) { <START> replicator.getEventBus().unregister(this); <END> } } }</code><technical_language>discussed some subtle issues eventBus registration de-registration</technical_language>

Target:
public boolean remove(Replicator replicator) { synchronized (replicatorsInProgress) { boolean removed = replicatorsInProgress.remove(replicator); if (removed) { replicator.getEventBus().unregister(this); } return removed; } }
Source:
<code>private Object getName(Fixture fixture) { if (fixture instanceof VerifyFact) { return ((VerifyFact) fixture).getName(); } else if (fixture instanceof VerifyScorecardScore) { return TestScenarioConstants.INSTANCE.ScoreCardScore(); } else { <START> return ""; <END> } }</code><technical_language>This branch added this PR, code setText("'" + verifyFact.getName() + "'");. that? If this happen I prefer throw exception else. Wdyt</technical_language>

Target:
private Object getName(Fixture fixture) { if (fixture instanceof VerifyFact) { return ((VerifyFact) fixture).getName(); } else if (fixture instanceof VerifyScorecardScore) { return TestScenarioConstants.INSTANCE.ScoreCardScore(); } else { throw new IllegalArgumentException("Fixture type not supported " + fixture); } }
Source:
<code>public PackingPlan repack(PackingPlan currentPackingPlan, Map<String, Integer> componentChanges) { this.numContainers = currentPackingPlan.getContainers().size(); resetToFirstContainer(); int additionalContainers = computeNumAdditionalContainers(componentChanges, currentPackingPlan); if (additionalContainers > 0) { increaseNumContainers(additionalContainers); LOG.info(String.format( "Allocated %s additional containers for repack bring the number of containers to %s.", additionalContainers, this.numContainers)); } while (true) { try { PackingPlanBuilder planBuilder = newPackingPlanBuilder(currentPackingPlan); planBuilder.updateNumContainers(numContainers); planBuilder = getResourceCompliantRRAllocation(planBuilder, componentChanges); return planBuilder.build(); } catch (ConstraintViolationException e) { LOG.info(String.format( "%s Increasing the number of containers to %s and attempting packing again.", e.getMessage(), this.numContainers)); increaseNumContainers(1); resetToFirstContainer(); <START> int totalInstances = TopologyUtils.getTotalInstance(topology); <END> if (numContainers > totalInstances) { throw new PackingException("Cannot add to that container"); } } } }</code><technical_language>above. refactor check a function if necessary</technical_language>

Target:
public PackingPlan repack(PackingPlan currentPackingPlan, Map<String, Integer> componentChanges) { this.numContainers = currentPackingPlan.getContainers().size(); resetToFirstContainer(); int additionalContainers = computeNumAdditionalContainers(componentChanges, currentPackingPlan); if (additionalContainers > 0) { increaseNumContainers(additionalContainers); LOG.info(String.format( "Allocated %s additional containers for repack bring the number of containers to %s.", additionalContainers, this.numContainers)); } while (true) { try { PackingPlanBuilder planBuilder = newPackingPlanBuilder(currentPackingPlan); planBuilder.updateNumContainers(numContainers); planBuilder = getResourceCompliantRRAllocation(planBuilder, componentChanges); return planBuilder.build(); } catch (ConstraintViolationException e) { LOG.info(String.format( "%s Increasing the number of containers to %s and attempting to repack again.", e.getMessage(), this.numContainers + 1)); retryWithAdditionalContainer(); } } }
Source:
<code>private void <START> updateEid() <END> { List<UiccCardInfo> infos = mTelephonyManager.getUiccCardsInfo(); for (UiccCardInfo info : infos) { if (info != null && info.getSlotIndex() == mSlotId) { if (info.isEuicc()) { String eid = info.getEid(); if (!TextUtils.isEmpty(eid)) { mDialog.setText(EID_INFO_VALUE_ID, eid); } } else { mDialog.removeSettingFromScreen(EID_INFO_LABEL_ID); mDialog.removeSettingFromScreen(EID_INFO_VALUE_ID); } break; } } }</code><technical_language>This code respect devices in single-SIM mode (i.e. phoneCount == 1) pSIM eSIM slots, active a time. This case needs accounted for logic</technical_language>

Target:
private void updateEid() { Map<Integer, Integer> slotMapping = mTelephonyManager.getLogicalToPhysicalSlotMapping(); Integer physicalSlotId = slotMapping.get(mSlotId); if (physicalSlotId != null) { List<UiccCardInfo> infos = mTelephonyManager.getUiccCardsInfo(); for (UiccCardInfo info : infos) { if (info != null && info.getSlotIndex() == physicalSlotId.intValue()) { if (info.isEuicc()) { String eid = info.getEid(); if (!TextUtils.isEmpty(eid)) { mDialog.setText(EID_INFO_VALUE_ID, eid); } } else { mDialog.removeSettingFromScreen(EID_INFO_LABEL_ID); mDialog.removeSettingFromScreen(EID_INFO_VALUE_ID); } break; } } } }
Source:
<code>public void testEmailWith255CharacterDomainPartIsValid() { <START> for (int num = 1; num < 251; num++) { <END> isValidEmail( "foo@" + stringOfLength( num ) + ".com" ); } }</code><technical_language>here, missing 251</technical_language>

Target:
public void testEmailWith255CharacterDomainPartIsValid() { isValidEmail( "foo@" + stringOfLength( 63 ) + ".com" ); for (int num = 1; num <= 251; num++) { isValidEmail( "foo@" + stringOfLength( num ) + ".com" ); } }
Source:
<code>public void testBufferFinishesWhenClientBuffersDestroyed() { BroadcastOutputBuffer buffer = createBroadcastBuffer( createInitialEmptyOutputBuffers(BROADCAST) .withBuffer(FIRST, BROADCAST_PARTITION_ID) .withBuffer(SECOND, BROADCAST_PARTITION_ID) .withBuffer(THIRD, BROADCAST_PARTITION_ID) .withNoMoreBufferIds(), <START> sizeOfPages(5)); <END> buffer.abort(FIRST); assertFalse(buffer.isFinished()); buffer.abort(SECOND); assertFalse(buffer.isFinished()); buffer.abort(THIRD); assertTrue(buffer.isFinished()); }</code><technical_language>Add some pages closing everything. This ensures buffer closes if pending pages</technical_language>

Target:
public void testBufferFinishesWhenClientBuffersDestroyed() { BroadcastOutputBuffer buffer = createBroadcastBuffer( createInitialEmptyOutputBuffers(BROADCAST) .withBuffer(FIRST, BROADCAST_PARTITION_ID) .withBuffer(SECOND, BROADCAST_PARTITION_ID) .withBuffer(THIRD, BROADCAST_PARTITION_ID) .withNoMoreBufferIds(), sizeOfPages(5)); for (int i = 0; i < 5; i++) { addPage(buffer, createPage(i)); } buffer.abort(FIRST); assertFalse(buffer.isFinished()); buffer.abort(SECOND); assertFalse(buffer.isFinished()); buffer.abort(THIRD); assertTrue(buffer.isFinished()); }