auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected ListenableFuture<Empty> deleteTableAsyncInternal(TableName tableName) throws IOException { <START> Builder deleteBuilder = DeleteTableRequest.newBuilder(); <END> deleteBuilder.setName(toBigtableName(tableName)); try { return bigtableTableAdminClient.deleteTableAsync(deleteBuilder.build()); } catch (Throwable throwable) { throw new IOException(String.format("Failed to delete table '%s'", tableName.getNameAsString()), throwable); } }</code><technical_language>Please DeleteTableRequest.Builder instead of Builder. protobuf objects a Builder, of Builder confusing. Also, do this: DeleteTableRequest request = DeleteTableRequest.newBuilder() .setName(...) .build()</technical_language>

Target:
protected CompletableFuture<Void> deleteTableAsyncInternal(TableName tableName) { DeleteTableRequest deleteTableRequest = DeleteTableRequest.newBuilder() .setName(toBigtableName(tableName)) .build(); return FutureUtils.toCompletableFuture( bigtableTableAdminClient.deleteTableAsync(deleteTableRequest)) .thenApply(r -> null); }
Source:
<code>private String pendingQueueKey(SingularityPendingRequest pendingRequest) { SingularityDeployKey deployKey = new SingularityDeployKey(pendingRequest.getRequestId(), pendingRequest.getDeployId()); <START> return String.format("%s%s", deployKey.toString(), pendingRequest.getTimestamp()); <END> }</code><technical_language>I is need handle pending requests currently in queue singularity starts. delete correctly calculate wrong path, continually process a getChildren call. able write a simple zk migration for this reads writes correct path deletes path startup</technical_language>

Target:
private String pendingQueueKey(SingularityPendingRequest pendingRequest) { SingularityDeployKey deployKey = new SingularityDeployKey(pendingRequest.getRequestId(), pendingRequest.getDeployId()); if (pendingRequest.getPendingType() == PendingType.ONEOFF || pendingRequest.getPendingType() == PendingType.IMMEDIATE) { return String.format("%s%s", deployKey.toString(), pendingRequest.getTimestamp()); } else { return deployKey.toString(); } }
Source:
<code>public IOseeBranch adapt(Attribute<?> attribute, Identity<String> identity) throws OseeCoreException { String uuid = identity.getGuid(); <START> return uuid.matches("^\\d+$") ? BranchManager.getBranchByUuid(Long.valueOf(uuid)) : null; <END> }</code><technical_language>Strings.isNumeric</technical_language>

Target:
public IOseeBranch adapt(Attribute<?> attribute, Identity<String> identity) throws OseeCoreException { String uuid = identity.getGuid(); return Strings.isNumeric(uuid) ? BranchManager.getBranchByUuid(Long.valueOf(uuid)) : null; }
Source:
<code>private void startReconstruct() { StorageDomainStatic masterDomain = null; List<StorageDomainStatic> storageDomainStaticList = DbFacade.getInstance() .getStorageDomainStaticDao().getAllForStoragePool(getParameters().getStoragePoolId()); for (StorageDomainStatic storageDomainStatic : storageDomainStaticList) { if (storageDomainStatic.getStorageDomainType() == StorageDomainType.Master) { masterDomain = storageDomainStatic; break; } } if (masterDomain != null) { final Guid masterDomainId = masterDomain.getId(); eventQueue.submitEventAsync(new Event(getParameters().getStoragePoolId(), masterDomainId, null, EventType.RECONSTRUCT, "IrsBrokerCommand.startReconstruct()"), () -> <START> resourceManager.getEventListener().masterDomainNotOperational( <END> masterDomainId, getParameters().getStoragePoolId(), true, getVDSReturnValue().getVdsError() != null && getVDSReturnValue().getVdsError().getCode() == EngineError.StoragePoolWrongMaster)); } else { log.error( "IrsBroker::IRSNoMasterDomainException:: Could not find master domain for pool '{}'", getParameters().getStoragePoolId()); } }</code><technical_language>annotate this getter @Provides inject event listener</technical_language>

Target:
private void startReconstruct() { StorageDomainStatic masterDomain = null; List<StorageDomainStatic> storageDomainStaticList = DbFacade.getInstance() .getStorageDomainStaticDao().getAllForStoragePool(getParameters().getStoragePoolId()); for (StorageDomainStatic storageDomainStatic : storageDomainStaticList) { if (storageDomainStatic.getStorageDomainType() == StorageDomainType.Master) { masterDomain = storageDomainStatic; break; } } if (masterDomain != null) { final Guid masterDomainId = masterDomain.getId(); eventQueue.submitEventAsync(new Event(getParameters().getStoragePoolId(), masterDomainId, null, EventType.RECONSTRUCT, "IrsBrokerCommand.startReconstruct()"), () -> eventListener.masterDomainNotOperational( masterDomainId, getParameters().getStoragePoolId(), true, getVDSReturnValue().getVdsError() != null && getVDSReturnValue().getVdsError().getCode() == EngineError.StoragePoolWrongMaster)); } else { log.error( "IrsBroker::IRSNoMasterDomainException:: Could not find master domain for pool '{}'", getParameters().getStoragePoolId()); } }
Source:
<code>public LinkedFileViewModel(LinkedFile linkedFile, BibEntry entry, BibDatabaseContext databaseContext, TaskExecutor taskExecutor, DialogService dialogService, XmpPreferences xmpPreferences, FilePreferences filePreferences, ExternalFileTypes externalFileTypes) { this.linkedFile = linkedFile; this.filePreferences = filePreferences; this.linkedFileHandler = new LinkedFileHandler(linkedFile, entry, databaseContext, filePreferences); this.databaseContext = databaseContext; this.entry = entry; this.dialogService = dialogService; this.taskExecutor = taskExecutor; this.externalFileTypes = externalFileTypes; this.xmpPreferences = xmpPreferences; fileExistsValidator = new FunctionBasedValidator<>( linkedFile.linkProperty(), link -> { <START> Optional<Path> path = FileHelper.expandFilename(databaseContext, link, filePreferences); <END> return path.isPresent() && Files.exists(path.get()); }, ValidationMessage.warning(Localization.lang("Could not find file '%0'.", linkedFile.getLink()))); downloadOngoing.bind(downloadProgress.greaterThanOrEqualTo(0).and(downloadProgress.lessThan(1))); canWriteXMPMetadata.setValue(!linkedFile.isOnlineLink() && linkedFile.getFileType().equalsIgnoreCase("pdf")); }</code><technical_language>if a website url is linked</technical_language>

Target:
public LinkedFileViewModel(LinkedFile linkedFile, BibEntry entry, BibDatabaseContext databaseContext, TaskExecutor taskExecutor, DialogService dialogService, XmpPreferences xmpPreferences, FilePreferences filePreferences, ExternalFileTypes externalFileTypes) { this.linkedFile = linkedFile; this.filePreferences = filePreferences; this.linkedFileHandler = new LinkedFileHandler(linkedFile, entry, databaseContext, filePreferences); this.databaseContext = databaseContext; this.entry = entry; this.dialogService = dialogService; this.taskExecutor = taskExecutor; this.externalFileTypes = externalFileTypes; this.xmpPreferences = xmpPreferences; fileExistsValidator = new FunctionBasedValidator<>( linkedFile.linkProperty(), link -> { if (linkedFile.isOnlineLink()) { return true; } else { Optional<Path> path = FileHelper.expandFilename(databaseContext, link, filePreferences); return path.isPresent() && Files.exists(path.get()); } }, ValidationMessage.warning(Localization.lang("Could not find file '%0'.", linkedFile.getLink()))); downloadOngoing.bind(downloadProgress.greaterThanOrEqualTo(0).and(downloadProgress.lessThan(1))); canWriteXMPMetadata.setValue(!linkedFile.isOnlineLink() && linkedFile.getFileType().equalsIgnoreCase("pdf")); }
Source:
<code>private void remove() { if (getWindow() != null) { return; } RemoveStorageModel model = new RemoveStorageModel(); setWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().removeStoragesTitle()); model.setHelpTag(HelpTag.remove_storage); model.setHashName("remove_storage"); StorageDomain storage = getSelectedItem(); boolean localFsOnly = storage.getStorageType() == StorageType.LOCALFS; AsyncDataProvider.getInstance().getHostsForStorageOperation(new AsyncQuery(new Object[]{this, model}, new INewAsyncCallback() { @Override public void onSuccess(Object target, Object returnValue) { Object[] array = (Object[]) target; StorageListModel storageListModel = (StorageListModel) array[0]; RemoveStorageModel removeStorageModel = (RemoveStorageModel) array[1]; List<VDS> hosts = (List<VDS>) returnValue; removeStorageModel.getHostList().setItems(hosts); removeStorageModel.getHostList().setSelectedItem(Linq.firstOrDefault(hosts)); <START> removeStorageModel.getFormat().setEntity(false); <END> if (hosts.isEmpty()) { UICommand tempVar = createCancelCommand("Cancel"); tempVar.setIsDefault(true); removeStorageModel.getCommands().add(tempVar); } else { UICommand command; command = UICommand.createDefaultOkUiCommand("OnRemove", StorageListModel.this); removeStorageModel.getCommands().add(command); command = createCancelCommand("Cancel"); removeStorageModel.getCommands().add(command); } } }), null, localFsOnly); }</code><technical_language>please move RemoveStorageModel ctr (i.e. default of format false)</technical_language>

Target:
private void remove() { if (getWindow() != null) { return; } RemoveStorageModel model = new RemoveStorageModel(); setWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().removeStoragesTitle()); model.setHelpTag(HelpTag.remove_storage); model.setHashName("remove_storage"); StorageDomain storage = getSelectedItem(); boolean localFsOnly = storage.getStorageType() == StorageType.LOCALFS; AsyncDataProvider.getInstance().getHostsForStorageOperation(new AsyncQuery(new Object[]{this, model}, new INewAsyncCallback() { @Override public void onSuccess(Object target, Object returnValue) { Object[] array = (Object[]) target; RemoveStorageModel removeStorageModel = (RemoveStorageModel) array[1]; List<VDS> hosts = (List<VDS>) returnValue; removeStorageModel.getHostList().setItems(hosts); removeStorageModel.getHostList().setSelectedItem(Linq.firstOrDefault(hosts)); if (hosts.isEmpty()) { UICommand tempVar = createCancelCommand("Cancel"); tempVar.setIsDefault(true); removeStorageModel.getCommands().add(tempVar); } else { UICommand command; command = UICommand.createDefaultOkUiCommand("OnRemove", StorageListModel.this); removeStorageModel.getCommands().add(command); command = createCancelCommand("Cancel"); removeStorageModel.getCommands().add(command); } } }), null, localFsOnly); }
Source:
<code>@Override public Object fromJson(JsonReader reader) throws IOException { Object result = delegate.fromJson(reader); if (result == null) { <START> result = defaultIfNull; <END> } return result; }</code><technical_language>neat</technical_language>

Target:
@Override public Object fromJson(JsonReader reader) throws IOException { Object result = delegate.fromJson(reader); if (result == null) { result = defaultIfNull(); } return result; }
Source:
<code>public void run() { taskExecutor.execute(new Runnable() { @Override public void run() { int count = 0; while (initialized && (maxMessagesPerPoll <= 0 || count < maxMessagesPerPoll)) { try { if (!pollingTask.call()) { break; } count++; } catch (Exception e) { if (!Thread.interrupted()) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new MessageHandlingException(new ErrorMessage(e), e); } } else { if (logger.isDebugEnabled()) { <START> logger.debug("The interruption error occurred during stop: " + e.getMessage()); <END> } } } } } }); }</code><technical_language>logger.debug("Poll interrupted - stop()? : " + e.getMessage()); However, thinking this some more, I suppress message if receiveMessage() is interrupted, handleMessage(), in case, throw MessageHandlingException</technical_language>

Target:
public void run() { taskExecutor.execute(new Runnable() { @Override public void run() { int count = 0; while (initialized && (maxMessagesPerPoll <= 0 || count < maxMessagesPerPoll)) { try { if (!pollingTask.call()) { break; } count++; } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new MessageHandlingException(new ErrorMessage(e), e); } } } } }); }
Source:
<code><START> private void popAndRedirectMessageToStore(MessageProducer messageProducer, MessageConsumer messageConsumer) <END> throws AxisFault { try { MessageContext messageContext = messageConsumer.receive(); messageProducer.storeMessage(messageContext); messageConsumer.ack(); } catch (SynapseException e) { handleException(log, "Failed to redirect the message : ", e); } }</code><technical_language>This method is called popAndRedirectMessage() right? move logic upper class</technical_language>

Target:
private void popAndRedirectMessageToStore(MessageProducer messageProducer, MessageConsumer messageConsumer) throws AxisFault { try { MessageContext messageContext = messageConsumer.receive(); messageProducer.storeMessage(messageContext); messageConsumer.ack(); } catch (SynapseException e) { handleException(log, "Failed to redirect message. ", e); } }
Source:
<code>private Long findFreeId(){ <START> while(personRepository.findOne(lastId) != null){ END> lastId++; } return lastId; }</code><technical_language>[existsById(long id)](<LINK_0></technical_language>

Target:
private Long findFreeId(){ while(personRepository.exists(lastId)){ lastId++; } return lastId; }
Source:
<code>public void onResume() { super.onResume(); Helper.setOrientationAndOn(this); Intent intent = new Intent(this, StorageService.class); getApplicationContext().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); mWebView.requestFocus(); <START> mWebView.resumeTimers(); END> }</code><technical_language>Is this related feature in description</technical_language>

Target:
public void onResume() { super.onResume(); Helper.setOrientationAndOn(this); Intent intent = new Intent(this, StorageService.class); getApplicationContext().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); mWebView.requestFocus(); }
Source:
<code>public void test() { connect(); waitResponse(); click(jq(".z-groupbox-title")); waitResponse(); <START> Assert.assertTrue(jq("@div").height() > 300); <END> }</code><technical_language>explain</technical_language>

Target:
public void test() { connect(); waitResponse(); click(jq(".z-groupbox-title")); waitResponse(); Assert.assertEquals(jq(".z-groupbox-content").height(), jq("@div").height(), 3); }
Source:
<code>public void addStitchPoint(float x, float y) { DSTStitchPoint point = new DSTStitchPoint(x, y); point.setColorChange(colorChangeBitSet); point.setJump(jumpBitSet); colorChangeBitSet = false; jumpBitSet = false; <START> if (firstPoint) { <END> firstPoint = false; header.initialize(x, y); point.setRelativeCoordinatesToPreviousPoint(x, y); } else { addInterpolatedPoints(x, y); header.update(x, y); PointF previousPoint = points.get(points.size() - 1).getPoint(); point.setRelativeCoordinatesToPreviousPoint(previousPoint.x, previousPoint.y); } points.add(point); }</code><technical_language>please check if list is empty instead</technical_language>

Target:
public void addStitchPoint(float x, float y) { DSTStitchPoint point = new DSTStitchPoint(x, y); point.setColorChange(colorChangeBitSet); point.setJump(jumpBitSet); colorChangeBitSet = false; jumpBitSet = false; if (points.isEmpty()) { header.initialize(x, y); point.setRelativeCoordinatesToPreviousPoint(x, y); } else { addInterpolatedPoints(x, y); header.update(x, y); StitchPoint previousPoint = points.get(points.size() - 1); point.setRelativeCoordinatesToPreviousPoint(previousPoint.getX(), previousPoint.getY()); } points.add(point); }
Source:
<code>private void configureReflections() { <START> Optional<String> basePackage = Optional.of(ninjaProperties.get(NinjaConstant.APPLICATION_MODULES_BASE_PACKAGE)); <END> if(basePackage.isPresent()) { reflections = new Reflections( basePackage.get() + "." + NinjaConstant.CONTROLLERS_DIR, new MethodAnnotationsScanner()); } else { reflections = new Reflections( NinjaConstant.CONTROLLERS_DIR, new MethodAnnotationsScanner()); } }</code><technical_language>I ofNullable... get exception if property is defined..</technical_language>

Target:
private void configureReflections() { Optional<String> basePackage = Optional.ofNullable(ninjaProperties.get(NinjaConstant.APPLICATION_MODULES_BASE_PACKAGE)); if (basePackage.isPresent()) { reflections = new Reflections( basePackage.get() + "." + NinjaConstant.CONTROLLERS_DIR, new MethodAnnotationsScanner()); } else { reflections = new Reflections( NinjaConstant.CONTROLLERS_DIR, new MethodAnnotationsScanner()); } }
Source:
<code>private static int maxPartition(Collection<StreamEdge> edges) { <START> if (edges.size() == 0) { <END> return StreamEdge.PARTITIONS_UNKNOWN; } return edges.stream().map(StreamEdge::getPartitionCount).reduce(Integer::max).get(); }</code><technical_language>I edges.size() 0? Is this a bug for a test case? If latter, this handled in test instead? If decide it, final get line 309 for? reduce return Optional? If so, getOrElse instead</technical_language>

Target:
static int maxPartition(Collection<StreamEdge> edges) { return edges.stream().map(StreamEdge::getPartitionCount).reduce(Integer::max).orElse(StreamEdge.PARTITIONS_UNKNOWN); }
Source:
<code>public void testWithParameters() throws IOException { try (Analyzer ws = newHomoglyphStemmer()) { TokenStream ts = ws.tokenStream("", input); <START> BaseTokenStreamTestCase.assertTokenStreamContents(ts, <END> expected); } }</code><technical_language>touch position increments I assert correct</technical_language>

Target:
public void testWithParameters() throws IOException { try (Analyzer ws = newHomoglyphFilter()) { TokenStream ts = ws.tokenStream("", input); BaseTokenStreamTestCase.assertTokenStreamContents(ts, expected); } }
Source:
<code>public static int[] getFileVersionDetails(String filePath) { IntByReference dwDummy = new IntByReference(); dwDummy.setValue(0); <START> int versionlength = Version.INSTANCE.GetFileVersionInfoSize(filePath, dwDummy); <END> if (versionlength == 0) { return null; } byte[] bufferarray = new byte[versionlength]; Pointer lpData = new Memory(bufferarray.length); PointerByReference lplpBuffer = new PointerByReference(); IntByReference puLen = new IntByReference(); if (Version.INSTANCE.GetFileVersionInfo(filePath, 0, versionlength, lpData) && Version.INSTANCE.VerQueryValue(lpData, "\\", lplpBuffer, puLen)) { VS_FIXEDFILEINFO lplpBufStructure = new VS_FIXEDFILEINFO(lplpBuffer.getValue()); lplpBufStructure.read(); int[] v = new int[4]; v[0] = lplpBufStructure.dwFileVersionMS.intValue() >> 16; v[1] = lplpBufStructure.dwFileVersionMS.intValue() & 0xffff; v[2] = lplpBufStructure.dwFileVersionLS.intValue() >> 16; v[3] = lplpBufStructure.dwFileVersionLS.intValue() & 0xffff; return v; } return null; }</code><technical_language>Please camel-case _versionLength_</technical_language>

Target:
public static int[] getFileVersionDetails(String filePath) { IntByReference dwDummy = new IntByReference(); dwDummy.setValue(0); int versionLength = Version.INSTANCE.GetFileVersionInfoSize(filePath, dwDummy); if (versionLength == 0) { return null; } byte[] bufferarray = new byte[versionLength]; Pointer lpData = new Memory(bufferarray.length); PointerByReference lplpBuffer = new PointerByReference(); IntByReference puLen = new IntByReference(); if (Version.INSTANCE.GetFileVersionInfo(filePath, 0, versionLength, lpData) && Version.INSTANCE.VerQueryValue(lpData, "\\", lplpBuffer, puLen)) { VS_FIXEDFILEINFO lplpBufStructure = new VS_FIXEDFILEINFO(lplpBuffer.getValue()); lplpBufStructure.read(); int[] v = new int[4]; v[0] = lplpBufStructure.dwFileVersionMS.intValue() >> 16; v[1] = lplpBufStructure.dwFileVersionMS.intValue() & 0xffff; v[2] = lplpBufStructure.dwFileVersionLS.intValue() >> 16; v[3] = lplpBufStructure.dwFileVersionLS.intValue() & 0xffff; return v; } return null; }
Source:
<code>public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { <START> SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); <END> format.setTimeZone(TimeZone.getTimeZone("UTC")); String dateString = format.format(dateValue); gen.writeString(dateString); }</code><technical_language>format a static property class, is call. Check if is thread safe making change though</technical_language>

Target:
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { String dateString = dateValue.toInstant().atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); gen.writeString(dateString); }
Source:
<code>public boolean isHealthy(ServiceEndPoint endPoint) { URI adminUrl = Payload.valueOf(endPoint.getPayload()).getAdminUrl(); Response response = _client.target(adminUrl).path("/healthcheck").request().method("HEAD"); int status = response.getStatus(); response.close(); <START> return status == 200; <END> }</code><technical_language>nitpick, change HttpStatus.SC_OK</technical_language>

Target:
public boolean isHealthy(ServiceEndPoint endPoint) { URI adminUrl = Payload.valueOf(endPoint.getPayload()).getAdminUrl(); Response response = _client.target(adminUrl).path("/healthcheck").request().method("HEAD"); int status = response.getStatus(); response.close(); return status == Response.Status.OK.getStatusCode(); }
Source:
<code>protected void resetAlignment() { markAlignmentEnd(0); <START> latestAlignmentDurationNanos = new CompletableFuture<>(); <END> }</code><technical_language>This method is odd: fit markCheckpointStart (markAlignmentEnd() does). simply called setAlignmentDuration</technical_language>

Target:
private void resetAlignment() { markAlignmentEnd(0); latestAlignmentDurationNanos = new CompletableFuture<>(); latestBytesProcessedDuringAlignment = new CompletableFuture<>(); }
Source:
<code>private int nameScore(String a, String b) { int aDirLen = a.lastIndexOf("/") + 1; int bDirLen = b.lastIndexOf("/") + 1; int dirMin = Math.min(aDirLen, bDirLen); int dirMax = Math.max(aDirLen, bDirLen); final int dirScoreLtr; final int dirScoreRtl; if (dirMax == 0) { dirScoreLtr = 100; dirScoreRtl = 100; } else { int dirSim = 0; for (; dirSim < dirMin; dirSim++) { <START> if (a.charAt(dirSim) != b.charAt(dirSim)) break; <END> } dirScoreLtr = (dirSim * 100) / dirMax; for (dirSim = 0; dirSim < dirMin; dirSim++) { if (a.charAt(aDirLen - 1 - dirSim) != b.charAt(bDirLen - 1 - dirSim)) break; } dirScoreRtl = (dirSim * 100) / dirMax; } int fileMin = Math.min(a.length() - aDirLen, b.length() - bDirLen); int fileMax = Math.max(a.length() - aDirLen, b.length() - bDirLen); int fileSim = 0; for (; fileSim < fileMin; fileSim++) { if (a.charAt(a.length() - 1 - fileSim) != b.charAt(b.length() - 1 - fileSim)) break; } int fileScore = (fileSim * 100) / fileMax; int nameScore = (((dirScoreLtr + dirScoreRtl) * 25) + (fileScore * 50)) / 100; return nameScore; }</code><technical_language>Style-nit: Break next line</technical_language>

Target:
private int nameScore(String a, String b) { int aDirLen = a.lastIndexOf("/") + 1; int bDirLen = b.lastIndexOf("/") + 1; int dirMin = Math.min(aDirLen, bDirLen); int dirMax = Math.max(aDirLen, bDirLen); final int dirScoreLtr; final int dirScoreRtl; if (dirMax == 0) { dirScoreLtr = 100; dirScoreRtl = 100; } else { int dirSim = 0; for (; dirSim < dirMin; dirSim++) { if (a.charAt(dirSim) != b.charAt(dirSim)) break; } dirScoreLtr = (dirSim * 100) / dirMax; if (dirScoreLtr == 100) { dirScoreRtl = 100; } else { for (dirSim = 0; dirSim < dirMin; dirSim++) { if (a.charAt(aDirLen - 1 - dirSim) != b.charAt(bDirLen - 1 - dirSim)) break; } dirScoreRtl = (dirSim * 100) / dirMax; } } int fileMin = Math.min(a.length() - aDirLen, b.length() - bDirLen); int fileMax = Math.max(a.length() - aDirLen, b.length() - bDirLen); int fileSim = 0; for (; fileSim < fileMin; fileSim++) { if (a.charAt(a.length() - 1 - fileSim) != b.charAt(b.length() - 1 - fileSim)) break; } int fileScore = (fileSim * 100) / fileMax; return (((dirScoreLtr + dirScoreRtl) * 25) + (fileScore * 50)) / 100; }
Source:
<code>void deleteBucket(final String rawPath, final MantaHttpHeaders requestHeaders) throws IOException { Validate.notBlank(rawPath, "rawPath must not be blank"); final String path = formatPath(rawPath); LOG.debug("DELETE bucket", path); try { httpHelper.httpDelete(path, requestHeaders); } catch (MantaClientHttpResponseException e) { if (e.getServerCode().equals(MantaErrorCode.BUCKET_NOT_FOUND_ERROR) || e.getServerCode().equals(MantaErrorCode.BUCKET_NOT_EMPTY_ERROR)) { final MantaIOException mioe = new MantaIOException("Unable to delete bucket", e); mioe.setContextValue("bucket", path); throw mioe; } } catch (ConnectionPoolTimeoutException e) { final MantaClientException clientException = new MantaClientException( "Connection pool timeout while deleting bucket" + e.getMessage()); clientException.setContextValue("path", path); throw clientException; <START> } catch (IOException e) { <END> throw new IOException(e); } LOG.debug("Finished deleting bucket {}.", path); }</code><technical_language>This sense</technical_language>

Target:
void deleteBucket(final String rawPath, final MantaHttpHeaders requestHeaders) throws IOException { Validate.notBlank(rawPath, "rawPath must not be blank"); final String path = formatPath(rawPath); LOG.debug("DELETE bucket", path); try { httpHelper.httpDelete(path, requestHeaders); } catch (MantaClientHttpResponseException e) { if (e.getServerCode().equals(MantaErrorCode.BUCKET_NOT_FOUND_ERROR) || e.getServerCode().equals(MantaErrorCode.BUCKET_NOT_EMPTY_ERROR)) { final MantaIOException mioe = new MantaIOException("Unable to delete bucket", e); mioe.setContextValue("bucket", path); throw mioe; } } catch (ConnectionPoolTimeoutException e) { final MantaClientException clientException = new MantaClientException( "Connection pool timeout while deleting bucket" + e.getMessage()); clientException.setContextValue("path", path); throw clientException; } LOG.debug("DELETE [bucket]", path); }
Source:
<code>public void apply(OnlineCommandContext ctx) throws Exception { Operations ops = new Operations(ctx.client); Address address = Address.subsystem("resource-adapters").and("resource-adapter", resourceAdapterId) .and("admin-objects", poolName); ops.add(address, Values.of("class-name", className) .and("jndi-name", localJndiName).and("use-java-context", useJavaContext)); if (properties.size() > 0) { <START> <END> Iterator it = properties.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); Address configPropsAddress = Address.subsystem("resource-adapters") .and("resource-adapter", resourceAdapterId) .and("admin-objects", poolName).and("config-properties", (String) pair.getKey()); ops.add(configPropsAddress, Values.of("value", (String) pair.getValue())); } } }</code><technical_language>empty line? :-)</technical_language>

Target:
public void apply(OnlineCommandContext ctx) throws Exception { Batch batch = new Batch(); Address address = Address.subsystem("resource-adapters").and("resource-adapter", resourceAdapterId) .and("admin-objects", poolName); batch.add(address, Values.of("class-name", className) .and("jndi-name", localJndiName).and("use-java-context", useJavaContext)); for (Map.Entry<String, String> pair : properties.entrySet()) { Address configPropsAddress = Address.subsystem("resource-adapters") .and("resource-adapter", resourceAdapterId) .and("admin-objects", poolName).and("config-properties", pair.getKey()); batch.add(configPropsAddress, Values.of("value", pair.getValue())); } new Operations(ctx.client).batch(batch); }
Source:
<code>public long tryLockBlock(long sessionId, long blockId, BlockLockType blockLockType, long time, TimeUnit unit) { ClientRWLock blockLock = getBlockLock(blockId); Lock lock = blockLockType == BlockLockType.READ ? blockLock.readLock() : blockLock.writeLock(); if (blockLockType == BlockLockType.WRITE && sessionHoldsLock(sessionId, blockId)) { throw new IllegalStateException(String .format("Session %s attempted to take a write lock on block %s, but the session already" + " holds a lock on the block", sessionId, blockId)); } <START> try { <END> if (!lock.tryLock(time, unit)) { LOG.warn("Failed to acquire lock for block after {}. " + "session: {}, blockLockType: {}, lock reference count = {}", blockId, time, unit, sessionId, blockLockType, blockLock.getReferenceCount()); return INVALID_LOCK_ID; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } try { return allocateLockId(sessionId, blockId, lock); } catch (Throwable e) { unlock(lock, blockId); throw e; } }</code><technical_language>if abstract a private method lockBlock(long, long, BlockLockType, boolean useTryLock, long, unit), add logic this method java if (useTryLock) { try { if (!lock.tryLock(time, unit)) { LOG.warn("Failed acquire lock for block {}. " + "session: {}, blockLockType: {}, lock reference count = {}", blockId, time, unit, sessionId, blockLockType, blockLock.getReferenceCount()); return INVALID_LOCK_ID; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } else { lock.lock() } reduce redundancy code</technical_language>

Target:
public long tryLockBlock(long sessionId, long blockId, BlockLockType blockLockType, long time, TimeUnit unit) { return lockBlockInternal(sessionId, blockId, blockLockType, false, time, unit); }
Source:
<code>private void assertDispatchForCommand(ReplicableCommand command, boolean expected) throws Exception { log.debugf("Testing " + command.getClass().getCanonicalName()); commandsFactory.initializeReplicableCommand(command, true); executorService.reset(); CountDownLatchResponse response = new CountDownLatchResponse(); invocationHandler.handleFromCluster(address, command, response, DeliverOrder.NONE); <START> transport.receiveRequest(address, command, Request.NO_REQUEST_ID, DeliverOrder.NONE); <END> response.await(30, TimeUnit.SECONDS); Assert.assertEquals(executorService.hasExecutedCommand, expected, "Command " + command.getClass() + " dispatched wrongly."); executorService.reset(); response = new CountDownLatchResponse(); invocationHandler.handleFromCluster(address, command, response, DeliverOrder.PER_SENDER); response.await(30, TimeUnit.SECONDS); Assert.assertFalse(executorService.hasExecutedCommand, "Command " + command.getClass() + " dispatched wrongly."); }</code><technical_language>transport testing a removed</technical_language>

Target:
private void assertDispatchForCommand(ReplicableCommand command, boolean expected) throws Exception { log.debugf("Testing " + command.getClass().getCanonicalName()); commandsFactory.initializeReplicableCommand(command, true); executorService.reset(); CountDownLatchResponse response = new CountDownLatchResponse(); invocationHandler.handleFromCluster(address, command, response, DeliverOrder.NONE); response.await(30, TimeUnit.SECONDS); Assert.assertEquals(executorService.hasExecutedCommand, expected, "Command " + command.getClass() + " dispatched wrongly."); executorService.reset(); response = new CountDownLatchResponse(); invocationHandler.handleFromCluster(address, command, response, DeliverOrder.PER_SENDER); response.await(30, TimeUnit.SECONDS); Assert.assertFalse(executorService.hasExecutedCommand, "Command " + command.getClass() + " dispatched wrongly."); }
Source:
<code>public BoundingBox getBoundingBox() { if (getPathPartList().size() < 1) { <START> if (!parse(getAttributes())) { <END> return new BoundingBox(0, 0, 0, 0); } } return getPathPartList().getBoundingBox(); }</code><technical_language>if statements erased, parse returns true. WDYT</technical_language>

Target:
public BoundingBox getBoundingBox() { if (getPathPartList().size() < 1) { return new BoundingBox(0, 0, 0, 0); } return getPathPartList().getBoundingBox(); }
Source:
<code>public void testSqlPathCreation() { ImmutableList.Builder<SqlPathElement> correctValues = ImmutableList.builder(); correctValues.add(new SqlPathElement("normal", "schema")); correctValues.add(new SqlPathElement("\"who.uses.periods\"", "\"in.schema.names\"")); correctValues.add(new SqlPathElement("\"same,deal\"", "\"with,commas\"")); correctValues.add(new SqlPathElement("a\"\"terrible", "\"thing!@#$%^&*()\"")); List<SqlPathElement> correctList = correctValues.build(); SqlPath path = new SqlPath("normal.schema," + "\"who.uses.periods\".\"in.schema.names\"," + "\"same,deal\".\"with,commas\"," + "a\"\"terrible.\"thing!@#$%^&*()\""); List<SqlPathElement> testList = path.getParsedPath(); <START> assertEquals(correctList, testList); <END> }</code><technical_language>assertEquals takes actual result parameter, expected result (the result is same, consistent API of this method). rename correctList -> expected testList -> actual, do assertEquals(actual, expected)</technical_language>

Target:
public void testSqlPathCreation() { ImmutableList.Builder<SqlPathElement> correctValues = ImmutableList.builder(); correctValues.add(new SqlPathElement( Optional.of(new Identifier("normal")), new Identifier("schema"))); correctValues.add(new SqlPathElement( Optional.of(new Identifier("who.uses.periods")), new Identifier("in.schema.names"))); correctValues.add(new SqlPathElement( Optional.of(new Identifier("same,deal")), new Identifier("with,commas"))); correctValues.add(new SqlPathElement( Optional.of(new Identifier("aterrible")), new Identifier("thing!@#$%^&*()"))); List<SqlPathElement> expected = correctValues.build(); SqlPath path = new SqlPath(Optional.of("normal.schema," + "\"who.uses.periods\".\"in.schema.names\"," + "\"same,deal\".\"with,commas\"," + "aterrible.\"thing!@#$%^&*()\"")); assertEquals(path.getParsedPath(), expected); assertEquals(path.toString(), Joiner.on(", ").join(expected)); }
Source:
<code>public void copyVhdImageIfNecessary(AuthenticatedContext ac, CloudStack stack, Image image, String region, AzureClient client) { CloudContext cloudContext = ac.getCloudContext(); String resourceGroupName = azureResourceGroupMetadataProvider.getResourceGroupName(cloudContext, stack); String imageStorageName = armStorage.getImageStorageName(new AzureCredentialView(ac.getCloudCredential()), cloudContext, stack); String imageResourceGroupName = azureResourceGroupMetadataProvider.getImageResourceGroupName(cloudContext, stack); createResourceGroupIfNotExists(client, resourceGroupName, region, stack); createResourceGroupIfNotExists(client, imageResourceGroupName, region, stack); azureStorageAccountService.createStorageAccount(ac, client, imageResourceGroupName, imageStorageName, region, stack); if (!storageContainsImage(client, imageResourceGroupName, imageStorageName, image.getImageName())) { try { LOGGER.info("Starting to copy image: {}, into storage account: {}", image.getImageName(), imageStorageName); client.copyImageBlobInStorageContainer(imageResourceGroupName, imageStorageName, IMAGES_CONTAINER, image.getImageName()); <START> } catch (CloudConnectorException e) { <END> LOGGER.warn("Something happened during start image copy.", e); } } }</code><technical_language>pls log "else" of this if</technical_language>

Target:
public void copyVhdImageIfNecessary(AuthenticatedContext ac, CloudStack stack, Image image, String region, AzureClient client) { CloudContext cloudContext = ac.getCloudContext(); String resourceGroupName = azureResourceGroupMetadataProvider.getResourceGroupName(cloudContext, stack); String imageStorageName = armStorage.getImageStorageName(new AzureCredentialView(ac.getCloudCredential()), cloudContext, stack); String imageResourceGroupName = azureResourceGroupMetadataProvider.getImageResourceGroupName(cloudContext, stack); createResourceGroupIfNotExists(client, resourceGroupName, region, stack); createResourceGroupIfNotExists(client, imageResourceGroupName, region, stack); azureStorageAccountService.createStorageAccount(ac, client, imageResourceGroupName, imageStorageName, region, stack); azureStorageAccountService.createContainerInStorage(client, imageResourceGroupName, imageStorageName); if (!storageContainsImage(client, imageResourceGroupName, imageStorageName, image.getImageName())) { try { LOGGER.info("Starting to copy image: {}, into storage account: {}", image.getImageName(), imageStorageName); client.copyImageBlobInStorageContainer(imageResourceGroupName, imageStorageName, IMAGES_CONTAINER, image.getImageName()); } catch (CloudConnectorException e) { LOGGER.warn("Something happened during start image copy.", e); } } else { LOGGER.info("The image is already exists in the storage account."); } }
Source:
<code>public static Pipeline getFromProtobuf(HddsProtos.Pipeline pipeline) throws UnknownPipelineStateException { Preconditions.checkNotNull(pipeline, "Pipeline is null"); return new Builder().setId(PipelineID.getFromProtobuf(pipeline.getId())) .setFactor(pipeline.getFactor()) .setType(pipeline.getType()) .setState(PipelineState.fromProtobuf(pipeline.getState())) <START> .setLeaderId(StringUtils.isNotEmpty(pipeline.getLeaderID()) ? <END> RaftPeerId.valueOf(pipeline.getLeaderID()) : null) .setNodes(pipeline.getMembersList().stream() .map(DatanodeDetails::getFromProtoBuf).collect(Collectors.toList())) .setNodesInOrder(pipeline.getMemberOrdersList()) .build(); }</code><technical_language>lets change this pipeline.hasLeaderID()</technical_language>

Target:
public static Pipeline getFromProtobuf(HddsProtos.Pipeline pipeline) throws UnknownPipelineStateException { Preconditions.checkNotNull(pipeline, "Pipeline is null"); return new Builder().setId(PipelineID.getFromProtobuf(pipeline.getId())) .setFactor(pipeline.getFactor()) .setType(pipeline.getType()) .setState(PipelineState.fromProtobuf(pipeline.getState())) .setLeaderId(pipeline.getLeaderID()) .setNodes(pipeline.getMembersList().stream() .map(DatanodeDetails::getFromProtoBuf).collect(Collectors.toList())) .setNodesInOrder(pipeline.getMemberOrdersList()) .build(); }
Source:
<code>public void testStitchPointsHashCode() { StitchPoint stitchPoint1 = new DSTStitchPoint(1, 2); StitchPoint stitchPoint2 = new DSTStitchPoint(0, 0); stitchPoint2.setJump(true); StitchPoint stitchPoint3 = new DSTStitchPoint(0, 0); stitchPoint1.setColorChange(true); StitchPoint stitchPoint4 = new DSTStitchPoint(2, 1); <START> StitchPoint stitchPoint5 = stitchPoint1; <END> assertNotEquals(stitchPoint1.hashCode(), stitchPoint2.hashCode()); assertNotEquals(stitchPoint1.hashCode(), stitchPoint3.hashCode()); assertNotEquals(stitchPoint1.hashCode(), stitchPoint4.hashCode()); assertEquals(stitchPoint1.hashCode(), stitchPoint5.hashCode()); }</code><technical_language>Please assign a new point</technical_language>

Target:
public void testStitchPointsHashCode() { StitchPoint stitchPoint1 = new DSTStitchPoint(1, 2); StitchPoint stitchPoint2 = new DSTStitchPoint(0, 0); stitchPoint2.setJump(true); StitchPoint stitchPoint3 = new DSTStitchPoint(0, 0); stitchPoint3.setColorChange(true); StitchPoint stitchPoint4 = new DSTStitchPoint(2, 1); StitchPoint stitchPoint5 = new DSTStitchPoint(1, 2); assertNotEquals(stitchPoint1.hashCode(), stitchPoint2.hashCode()); assertNotEquals(stitchPoint1.hashCode(), stitchPoint3.hashCode()); assertNotEquals(stitchPoint1.hashCode(), stitchPoint4.hashCode()); assertEquals(stitchPoint1.hashCode(), stitchPoint5.hashCode()); }
Source:
<code>public void whenSchedulerRestartedThenTimerIsFired() throws Exception { countDownListener.configure(PROCESS_ID, 1); long processInstanceId = processService.startProcess(unit.getIdentifier(), PROCESS_ID); assertNotNull(processInstanceId); pauseScheduler(); CountDownLatch latch = new CountDownLatch(1); <START> latch.await(20, TimeUnit.SECONDS); <END> restartScheduler(); countDownListener.getCountDown().await(); assertTrue(countDownListener.getExecutingThread().startsWith("SpringBootScheduler")); ProcessInstance pi = processService.getProcessInstance(processInstanceId); assertNull(pi); }</code><technical_language>here. call await countDownListener</technical_language>

Target:
public void whenSchedulerRestartedThenTimerIsFired() throws Exception { long processInstanceId = processService.startProcess(unit.getIdentifier(), PROCESS_ID); assertNotNull(processInstanceId); pauseScheduler(); awaitWithoutInterruption(); restartScheduler(); countDownListener.getCountDown().await(); assertTrue(countDownListener.getExecutingThread().startsWith("SpringBootScheduler")); ProcessInstance pi = processService.getProcessInstance(processInstanceId); assertNull(pi); }
Source:
<code>public void deleteServiceTypes(String Uuid) { RestApi restApi = RestServiceBuilder.createService(RestApi.class); Call<Services> call = restApi.deleteServiceTypes(Uuid, true); call.enqueue(new Callback<Services>() { @Override public void onResponse(Call<Services> call, Response<Services> response) { if (response.isSuccessful()) { mFormAddEditServiceView.endActivity(); } } @Override public void onFailure(Call<Services> call, Throwable t) { <START> Log.e("jvk", "vkvkjkj"); <END> } }); }</code><technical_language>Consider replacing this a more helpful error message</technical_language>

Target:
public void deleteServiceTypes(String Uuid) { RestApi restApi = RestServiceBuilder.createService(RestApi.class); Call<Services> call = restApi.deleteServiceTypes(Uuid, true); call.enqueue(new Callback<Services>() { @Override public void onResponse(Call<Services> call, Response<Services> response) { if (response.isSuccessful()) { mFormAddEditServiceView.endActivity(); } } @Override public void onFailure(Call<Services> call, Throwable t) { } }); }
Source:
<code>private synchronized void fetchLatestTopology() { LOG.log(Level.INFO, "Fetching topology from state manager: {0}", topologyName); <START> this.topology = stateManagerAdaptor.getTopology(topologyName); <END> if (topology == null) { throw new RuntimeException("Failed to fetch topology from the State Manager"); } }</code><technical_language>This is topology time of submission, latest one, is want right?. latest current physicalPlan.getTopology(), updates config (e.g. parallelism) creation. If needed UpdateTopologyMaster</technical_language>

Target:
private synchronized void fetchLatestTopology() { LOG.log(Level.INFO, "Fetching topology from state manager: {0}", topologyName); this.topology = stateManagerAdaptor.getPhysicalPlan(topologyName).getTopology(); if (topology == null) { throw new InvalidStateException(topologyName, "Failed to fetch topology info"); } }
Source:
<code>public Runtime getServerRuntime(String name) { List<Runtime> resultRuntimes = getServerRuntimes() .stream() .filter((runtime) -> runtime.getName().equals(name)) .collect(Collectors.toList()); if (resultRuntimes.size() > 1) { <START> throw new IllegalStateException("There are more than one runtime fulfilling conditions. Result is ambiguous."); <END> } return resultRuntimes.isEmpty() ? null : resultRuntimes.get(0); }</code><technical_language>throw EclipseLayerEx</technical_language>

Target:
public Runtime getServerRuntime(String name) { List<Runtime> resultRuntimes = getServerRuntimes() .stream() .filter((runtime) -> runtime.getName().equals(name)) .collect(Collectors.toList()); if (resultRuntimes.size() > 1) { throw new EclipseLayerException("There are more than one runtime fulfilling conditions. Result is ambiguous."); } return resultRuntimes.isEmpty() ? null : resultRuntimes.get(0); }
Source:
<code>private LocalDBEntry getLocalDBEntry(final FileUploadResult fileUploadResult, final LocalDB localDB) throws Exception { if (localDB == null || localDB.getLocalDb().isEmpty()) return null; <START> <END> List<LocalDBEntry> localDBEntries = localDB.getLocalDb().stream().filter(localDBEntry -> (localDBEntry.getFileUploadResult().getFileName().toFile().getName().toLowerCase().equals(fileUploadResult.getFileName().toFile().getName().toLowerCase()))) .filter(localDBEntry -> (localDBEntry.getFileUploadResult().getLastModifiedTime().equals(fileUploadResult.getLastModifiedTime()))) .filter(localDBEntry -> (localDBEntry.getFileUploadResult().getCompression().equals(fileUploadResult.getCompression()))) .collect(Collectors.toList()); if (localDBEntries == null || localDBEntries.isEmpty()) return null; if (localDBEntries.size() == 1) { if (logger.isDebugEnabled()) logger.debug("Local entry found: {}", localDBEntries.get(0)); return localDBEntries.get(0); } throw new Exception("Unexpected behavior: More than one entry found in local database for the same file. FileUploadResult: " + fileUploadResult); }</code><technical_language>trouble reading this. I easier if filters unified a single filter, a multiline anonymous function</technical_language>

Target:
private LocalDBEntry getLocalDBEntry(final FileUploadResult fileUploadResult, final LocalDB localDB) throws Exception { if (localDB == null || localDB.getLocalDBEntries() == null || localDB.getLocalDBEntries().isEmpty()) return null; List<LocalDBEntry> localDBEntries = localDB.getLocalDBEntries().stream().filter(localDBEntry -> (localDBEntry.getFileUploadResult().getFileName().toFile().getName().toLowerCase(). equals(fileUploadResult.getFileName().toFile().getName().toLowerCase()))) .filter(localDBEntry -> (localDBEntry.getFileUploadResult().getLastModifiedTime(). equals(fileUploadResult.getLastModifiedTime()))) .filter(localDBEntry -> (localDBEntry.getFileUploadResult().getCompression(). equals(fileUploadResult.getCompression()))) .collect(Collectors.toList()); if (localDBEntries.isEmpty()) return null; if (localDBEntries.size() == 1) { if (logger.isDebugEnabled()) logger.debug("Local entry found: {}", localDBEntries.get(0)); return localDBEntries.get(0); } throw new Exception("Unexpected behavior: More than one entry found in local database for the same file. FileUploadResult: " + fileUploadResult); }
Source:
<code>private void commandLineReport(String reportName, String command) { System.err.println(reportName + ":"); Runtime rt = Runtime.getRuntime(); Writer logOutput = null; try { java.lang.Process p = Runtime.getRuntime().exec(command); if (mRequestBugreport) { logOutput = new BufferedWriter(new FileWriter(new File(Environment .getLegacyExternalStorageDirectory(), reportName), true)); } InputStream inStream = p.getInputStream(); InputStreamReader inReader = new InputStreamReader(inStream); BufferedReader inBuffer = new BufferedReader(inReader); String s; while ((s = inBuffer.readLine()) != null) { if (mRequestBugreport && <START> logOutput != null) { <END> try { logOutput.write(s); logOutput.write("\n"); } catch (IOException e) { while(inBuffer.readLine() != null) System.err.println(e.toString()); break; } } else { System.err.println(s); } } int status = p.waitFor(); System.err.println(" if (logOutput != null) { logOutput.close(); } } catch (Exception e) { System.err.println(" System.err.println(e.toString()); } }</code><technical_language>this check is unnecessary (see L425)</technical_language>

Target:
private void commandLineReport(String reportName, String command) { System.err.println(reportName + ":"); Runtime rt = Runtime.getRuntime(); Writer logOutput = null; try { java.lang.Process p = Runtime.getRuntime().exec(command); if (mRequestBugreport) { logOutput = new BufferedWriter(new FileWriter(new File(Environment .getLegacyExternalStorageDirectory(), reportName), true)); } InputStream inStream = p.getInputStream(); InputStreamReader inReader = new InputStreamReader(inStream); BufferedReader inBuffer = new BufferedReader(inReader); String s; while ((s = inBuffer.readLine()) != null) { if (mRequestBugreport) { try { logOutput.write(s); logOutput.write("\n"); } catch (IOException e) { while(inBuffer.readLine() != null) System.err.println(e.toString()); break; } } else { System.err.println(s); } } int status = p.waitFor(); System.err.println(" if (logOutput != null) { logOutput.close(); } } catch (Exception e) { System.err.println(" System.err.println(e.toString()); } }