auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void setUpWithCasSupportSetTo(boolean supportsCas) throws Exception { quickTimeoutConfig = ImmutableCassandraKeyValueServiceConfig.copyOf(CassandraContainer.KVS_CONFIG) .withSchemaMutationTimeoutMillis(500); CassandraKeyValueServiceConfigManager simpleManager = CassandraKeyValueServiceConfigManager.createSimpleManager(quickTimeoutConfig); TracingQueryRunner queryRunner = new TracingQueryRunner(log, TracingPrefsConfig.create()); writeConsistency = ConsistencyLevel.EACH_QUORUM; clientPool = CassandraClientPoolImpl.create(simpleManager.getConfig(), <START> TokenRangeWritesLogger.createUninitialized()); <END> lockTable = new UniqueSchemaMutationLockTable( new SchemaMutationLockTables(clientPool, quickTimeoutConfig), LockLeader.I_AM_THE_LOCK_LEADER); heartbeatService = new HeartbeatService( clientPool, queryRunner, HeartbeatService.DEFAULT_HEARTBEAT_TIME_PERIOD_MILLIS, lockTable.getOnlyTable(), writeConsistency); schemaMutationLock = getSchemaMutationLock(supportsCas, simpleManager, queryRunner, SchemaMutationLock.DEFAULT_DEAD_HEARTBEAT_TIMEOUT_THRESHOLD_MILLIS); secondSchemaMutationLock = getSchemaMutationLock(supportsCas, simpleManager, queryRunner, SchemaMutationLock.DEFAULT_DEAD_HEARTBEAT_TIMEOUT_THRESHOLD_MILLIS); lockTestTools = new SchemaMutationLockTestTools(clientPool, lockTable); }</code><technical_language>call create need pass this in? I minimise impact of change simply creating TokenRangeWritesLogger in factory method passing in for tests</technical_language>

Target:
private void setUpWithCasSupportSetTo(boolean supportsCas) throws Exception { quickTimeoutConfig = ImmutableCassandraKeyValueServiceConfig.copyOf(CassandraContainer.KVS_CONFIG) .withSchemaMutationTimeoutMillis(500); CassandraKeyValueServiceConfigManager simpleManager = CassandraKeyValueServiceConfigManager.createSimpleManager(quickTimeoutConfig); TracingQueryRunner queryRunner = new TracingQueryRunner(log, TracingPrefsConfig.create()); writeConsistency = ConsistencyLevel.EACH_QUORUM; clientPool = CassandraClientPoolImpl.create(simpleManager.getConfig()); lockTable = new UniqueSchemaMutationLockTable( new SchemaMutationLockTables(clientPool, quickTimeoutConfig), LockLeader.I_AM_THE_LOCK_LEADER); heartbeatService = new HeartbeatService( clientPool, queryRunner, HeartbeatService.DEFAULT_HEARTBEAT_TIME_PERIOD_MILLIS, lockTable.getOnlyTable(), writeConsistency); schemaMutationLock = getSchemaMutationLock(supportsCas, simpleManager, queryRunner, SchemaMutationLock.DEFAULT_DEAD_HEARTBEAT_TIMEOUT_THRESHOLD_MILLIS); secondSchemaMutationLock = getSchemaMutationLock(supportsCas, simpleManager, queryRunner, SchemaMutationLock.DEFAULT_DEAD_HEARTBEAT_TIMEOUT_THRESHOLD_MILLIS); lockTestTools = new SchemaMutationLockTestTools(clientPool, lockTable); }
Source:
<code>public Object execute(JobExecutionContext context) throws JobExecutionException { try { JobArguments arguments = context.getJobArguments(); String ownerKey = arguments.getAsString(OWNER_KEY); Owner owner = ownerCurator.getByKey(ownerKey); if (owner == null) { log.warn("Healing attempted against non-existent org id \"{}\"", ownerKey); throw new JobExecutionException( i18n.tr("Healing attempted against non-existent org id \"{}\"", ownerKey)); } if (owner.isAutobindDisabled() || owner.isContentAccessEnabled()) { String caMessage = owner.isContentAccessEnabled() ? " because of the content access mode setting" : ""; <START> throw new JobExecutionException( <END> i18n.tr("Auto-attach is disabled for owner {0}{1}.", owner.getKey(), caMessage)); } Date entitleDate = arguments.getAs(ENTITLE_DATE_KEY, Date.class); StringBuilder result = new StringBuilder(); for (String uuid : ownerCurator.getConsumerUuids(owner).list()) { try { Consumer consumer = consumerCurator.getConsumer(uuid); healSingleConsumer(consumer, owner, entitleDate); result.append("Successfully healed consumer with UUID: ").append(uuid).append("\n"); } catch (Exception e) { log.debug("Healing failed for UUID \"{}\" with message: {}", uuid, e.getMessage()); result.append("Healing failed for UUID: ").append(uuid).append("\n"); } } return result; } catch (Exception e) { log.error("HealEntireOrgJob encountered a problem.", e); throw new JobExecutionException(e.getMessage(), e, false); } }</code><technical_language>Remember set terminal flag true here: new JobExecutionException(i18n.tr("..."), true);</technical_language>

Target:
public Object execute(JobExecutionContext context) throws JobExecutionException { try { JobArguments arguments = context.getJobArguments(); String ownerKey = arguments.getAsString(OWNER_KEY); Owner owner = ownerCurator.getByKey(ownerKey); if (owner == null) { log.warn("Healing attempted against non-existent org key \"{}\"", ownerKey); throw new JobExecutionException( i18n.tr("Healing attempted against non-existent org key \"{}\"", ownerKey), true); } if (owner.isAutobindDisabled() || owner.isContentAccessEnabled()) { String caMessage = owner.isContentAccessEnabled() ? " because of the content access mode setting" : ""; throw new JobExecutionException( i18n.tr("Auto-attach is disabled for owner {0}{1}.", owner.getKey(), caMessage), true); } Date entitleDate = arguments.getAs(ENTITLE_DATE_KEY, Date.class); StringBuilder result = new StringBuilder(); for (String uuid : ownerCurator.getConsumerUuids(owner).list()) { try { Consumer consumer = consumerCurator.getConsumer(uuid); healSingleConsumer(consumer, owner, entitleDate); result.append("Successfully healed consumer with UUID: ").append(uuid).append("\n"); } catch (Exception e) { log.debug("Healing failed for UUID \"{}\" with message: {}", uuid, e.getMessage()); result.append("Healing failed for UUID: ").append(uuid).append("\n"); } } return result; } catch (Exception e) { log.error("HealEntireOrgJob encountered a problem.", e); throw new JobExecutionException(e.getMessage(), e, false); } }
Source:
<code>public void keyPressed(KeyEvent e) { switch (e.keyCode) { case SWT.SHIFT: { setRangeZoomable(true); return; } case SWT.CTRL: { setDomainZoomable(true); return; } case SWT.SPACE: restoreAutoBounds(); <START> <END> } }</code><technical_language>java return;</technical_language>

Target:
public void keyPressed(KeyEvent e) { switch (e.keyCode) { case SWT.SHIFT: setRangeZoomable(true); return; case SWT.CTRL: setDomainZoomable(true); return; case SWT.SPACE: restoreAutoBounds(); return; } }
Source:
<code>private void tryToLoadWebView(boolean forceLoad) { System.gc(); if ((!forceLoad && pageIsLoaded) || progressWheel == null) { return; } if (!EventBus.getDefault().isRegistered(this)) { EventBus.getDefault().register(this); } if (!NetworkUtil.isConnected(getContext())) { showErrorMessage(R.string.reset_no_network_message, FontAwesomeIcons.fa_wifi); return; } showLoadingProgress(); if (!TextUtils.isEmpty(url)) { <START> Map<String, String> map = new HashMap<>(); <END> final String token = loginPrefs.getAuthorizationHeader(); if (token != null) { map.put("Authorization", token); } final EdxCookieManager cookieManager = EdxCookieManager.getSharedInstance(getContext()); if (cookieManager.isSessionCookieMissingOrExpired()) { cookieManager.tryToRefreshSessionCookie(); } else { didReceiveError = false; webView.loadUrl(url); } } }</code><technical_language>This map deleted cuz unused anyways</technical_language>

Target:
private void tryToLoadWebView(boolean forceLoad) { System.gc(); if ((!forceLoad && pageIsLoaded) || progressWheel == null) { return; } if (!EventBus.getDefault().isRegistered(this)) { EventBus.getDefault().register(this); } if (!NetworkUtil.isConnected(getContext())) { showErrorMessage(R.string.reset_no_network_message, FontAwesomeIcons.fa_wifi); return; } showLoadingProgress(); if (!TextUtils.isEmpty(url)) { final EdxCookieManager cookieManager = EdxCookieManager.getSharedInstance(getContext()); if (cookieManager.isSessionCookieMissingOrExpired()) { cookieManager.tryToRefreshSessionCookie(); } else { didReceiveError = false; webView.loadUrl(url); } } }
Source:
<code>private static void checkFieldTypeForSort(FieldDescriptor descriptor, String fieldDescriptions) { <START> for (RealmFieldType aValidFieldTypesForSort : validFieldTypesForSort) { <END> if (aValidFieldTypesForSort == descriptor.getFieldType()) { return; } } throw new IllegalArgumentException(String.format( "Sort is not supported on '%s' field '%s' in '%s'.", descriptor.toString(), descriptor.getFieldName(), fieldDescriptions)); }</code><technical_language>contains in checkFieldTypeForDistinct</technical_language>

Target:
private static void checkFieldTypeForSort(FieldDescriptor descriptor, String fieldDescriptions) { if (!validFieldTypesForSort.contains(descriptor.getFieldType())) { throw new IllegalArgumentException(String.format( "Sort is not supported on '%s' field '%s' in '%s'.", descriptor.toString(), descriptor.getFieldName(), fieldDescriptions)); } }
Source:
<code>public SpiTransaction createServerTransaction(boolean isExplicit, int isolationLevel) { SpiTransaction t = transactionManager.createTransaction(isExplicit, isolationLevel); <START> try { <END> transactionScopeManager.set(t); } catch (PersistenceException existingTransactionError) { t.end(); throw existingTransactionError; } return t; }</code><technical_language>if (!isExplicit) { // ... try</technical_language>

Target:
public SpiTransaction createServerTransaction(boolean isExplicit, int isolationLevel) { SpiTransaction t = transactionManager.createTransaction(isExplicit, isolationLevel); if (isExplicit) { try { transactionScopeManager.set(t); } catch (PersistenceException existingTransactionError) { t.end(); throw existingTransactionError; } } return t; }
Source:
<code>public void run() { while (!isInterrupted()) { try { sleep(SLEEP_INTERVAL_MILLIS); long currTime = System.currentTimeMillis(); List<Metric> metrics = _metricService.getMetrics(_dataLagQueryExpression, currTime); <START> if(metrics==null || metrics.isEmpty()) { <END> _logger.info("Data lag detected as metric list is empty"); if(!isDataLagging) { isDataLagging=true; sendDataLagEmailNotification(); } continue; } Metric currMetric = metrics.get(0); if(currMetric.getDatapoints()==null || currMetric.getDatapoints().size()==0) { _logger.info("Data lag detected as data point list is empty"); if(!isDataLagging) { isDataLagging=true; sendDataLagEmailNotification(); } continue; }else { long lastDataPointTime = 0L; for(Long dataPointTime : currMetric.getDatapoints().keySet()) { if(dataPointTime > lastDataPointTime) { lastDataPointTime = dataPointTime; } } if((currTime - lastDataPointTime)> _dataLagThreshold) { _logger.info("Data lag detected as the last data point recieved is more than the data threshold of " + _dataLagThreshold + " ms"); if(!isDataLagging) { isDataLagging=true; sendDataLagEmailNotification(); } continue; } } if(isDataLagging) { isDataLagging = false; sendDataLagEmailNotification(); } }catch(Exception e) { _logger.error("Data lag monitor thread sleep interrupted - " + e.getMessage()); } } }</code><technical_language>refactor a method L56-60 similar logic is reused a times</technical_language>

Target:
public void run() { _logger.info("Data lag monitor thread started"); while (!isInterrupted()) { try { sleep(SLEEP_INTERVAL_MILLIS); long currTime = System.currentTimeMillis(); List<Metric> metrics = _metricService.getMetrics(_dataLagQueryExpression, currTime); if(metrics==null || metrics.isEmpty()) { _logger.info("Data lag detected as metric list is empty"); if(!isDataLagging) { isDataLagging=true; sendDataLagEmailNotification(); } continue; } Metric currMetric = metrics.get(0); if(currMetric.getDatapoints()==null || currMetric.getDatapoints().size()==0) { _logger.info("Data lag detected as data point list is empty"); if(!isDataLagging) { isDataLagging=true; sendDataLagEmailNotification(); } continue; }else { long lastDataPointTime = 0L; for(Long dataPointTime : currMetric.getDatapoints().keySet()) { if(dataPointTime > lastDataPointTime) { lastDataPointTime = dataPointTime; } } if((currTime - lastDataPointTime)> _dataLagThreshold) { _logger.info("Data lag detected as the last data point recieved is more than the data threshold of " + _dataLagThreshold + " ms"); if(!isDataLagging) { isDataLagging=true; sendDataLagEmailNotification(); } continue; } } if(isDataLagging) { isDataLagging = false; sendDataLagEmailNotification(); } }catch(Exception e) { _logger.error("Exception thrown in data lag monitor thread - " + ExceptionUtils.getFullStackTrace(e)); } } }
Source:
<code>A loadOrCreate(I id) { A result = load(id).orElseGet(() -> { A created = create(id); lifecycleOf(id).onEntityCreated(AGGREGATE); <START> return created; <END> }); return result; }</code><technical_language>Please extract a separate createNew method</technical_language>

Target:
A loadOrCreate(I id) { A result = load(id).orElseGet(() -> createNew(id)); return result; }
Source:
<code>public SolrFilterResult buildSolrQuery() { StringBuilder cond = new StringBuilder("NOT ("); List<String> excludeSets = this.getExcludeSets(); for (int i = 0; i < excludeSets.size(); i++) { <START> if (excludeSets.get(i).substring(0, 4) == "col_") { <END> cond.append("item.collections:"); } else if (excludeSets.get(i).substring(0, 4) == "com_") { cond.append("item.communities:"); } else { throw new UnsupportedOperationException("DSpaceExcludeSetFilter: Unexpected set prefix " + excludeSets.get(i).substring(0, 4)); } cond.append(excludeSets.get(i)); if (i < excludeSets.size() - 1) cond.append(" OR "); } cond.append(")"); return new SolrFilterResult(cond.toString()); }</code><technical_language>This be: if (excludeSets.get(i).substring(0, 4).equals("col_")) {</technical_language>

Target:
public SolrFilterResult buildSolrQuery() { StringBuilder cond = new StringBuilder("NOT ("); List<String> excludeSets = this.getExcludeSets(); for (int i = 0; i < excludeSets.size(); i++) { if (excludeSets.get(i).substring(0, 4).equals("col_")) { cond.append("item.collections:"); } else if (excludeSets.get(i).substring(0, 4).equals("com_")) { cond.append("item.communities:"); } else { throw new UnsupportedOperationException("DSpaceExcludeSetFilter: Unexpected set prefix " + excludeSets.get(i).substring(0, 4)); } cond.append(excludeSets.get(i)); if (i < excludeSets.size() - 1) cond.append(" OR "); } cond.append(")"); return new SolrFilterResult(cond.toString()); }
Source:
<code>public void emit(Event event) { if (!started.get()) { <START> log.error("WTF emit was called while service is not started yet"); <END> return; } if (event instanceof ServiceMetricEvent) { final GraphiteEvent graphiteEvent = graphiteEventConverter.druidEventToGraphite((ServiceMetricEvent) event); if (graphiteEvent == null) { return; } try { final boolean isSuccessful = eventsQueue.offer( graphiteEvent, graphiteEmitterConfig.getEmitWaitTime(), TimeUnit.MILLISECONDS ); if (!isSuccessful) { if (countLostEvents.getAndIncrement() % 1000 == 0) { log.error( "Lost total of [%s] events because of emitter queue is full. Please increase the capacity or/and the consumer frequency", countLostEvents.get() ); } } } catch (InterruptedException e) { log.error(e, "got interrupted with message [%s]", e.getMessage()); Thread.currentThread().interrupt(); } } else if (!emitterList.isEmpty() && event instanceof AlertEvent) { for (Emitter emitter : emitterList) { emitter.emit(event); } } else { log.error("unknown event type [%s]", event.getClass()); return; } }</code><technical_language>I this exception is fine, a violation of expected usage. HttpPostEmitter throws exception in a similar situation. exceptions "dangerous" occur normal usage</technical_language>

Target:
public void emit(Event event) { if (!started.get()) { throw new ISE("WTF emit was called while service is not started yet"); } if (event instanceof ServiceMetricEvent) { final GraphiteEvent graphiteEvent = graphiteEventConverter.druidEventToGraphite((ServiceMetricEvent) event); if (graphiteEvent == null) { return; } try { final boolean isSuccessful = eventsQueue.offer( graphiteEvent, graphiteEmitterConfig.getEmitWaitTime(), TimeUnit.MILLISECONDS ); if (!isSuccessful) { if (countLostEvents.getAndIncrement() % 1000 == 0) { log.error( "Lost total of [%s] events because of emitter queue is full. Please increase the capacity or/and the consumer frequency", countLostEvents.get() ); } } } catch (InterruptedException e) { log.error(e, "got interrupted with message [%s]", e.getMessage()); Thread.currentThread().interrupt(); } } else if (!emitterList.isEmpty() && event instanceof AlertEvent) { for (Emitter emitter : emitterList) { emitter.emit(event); } } else if (event instanceof AlertEvent) { AlertEvent alertEvent = (AlertEvent) event; log.error( "The following alert is dropped, description is [%s], severity is [%s]", alertEvent.getDescription(), alertEvent.getSeverity() ); } else { log.error("unknown event type [%s]", event.getClass()); } }
Source:
<code>protected void initDetailModels() { super.initDetailModels(); setClusterVmListModel(new ClusterVmListModel()); setClusterServiceModel(new ClusterServiceModel()); setClusterGlusterHookListModel(new ClusterGlusterHookListModel()); <START> setAffinityGroupListModel(new ClusterAffinityGroupListModel(VdcQueryType.GetAffinityGroupsByClusterId)); <END> ObservableCollection<EntityModel> list = new ObservableCollection<EntityModel>(); list.add(new ClusterGeneralModel()); list.add(new ClusterNetworkListModel()); list.add(new ClusterHostListModel()); list.add(getClusterVmListModel()); list.add(getClusterServiceModel()); list.add(getClusterGlusterHookListModel()); list.add(new PermissionListModel()); list.add(getAffinityGroupListModel()); setDetailModels(list); }</code><technical_language>cluster subtab this query, I encapsulate ClusterAffinityGroupListModel constructor no-arg</technical_language>

Target:
protected void initDetailModels() { super.initDetailModels(); setClusterVmListModel(new ClusterVmListModel()); setClusterServiceModel(new ClusterServiceModel()); setClusterGlusterHookListModel(new ClusterGlusterHookListModel()); setAffinityGroupListModel(new ClusterAffinityGroupListModel()); ObservableCollection<EntityModel> list = new ObservableCollection<EntityModel>(); list.add(new ClusterGeneralModel()); list.add(new ClusterNetworkListModel()); list.add(new ClusterHostListModel()); list.add(getClusterVmListModel()); list.add(getClusterServiceModel()); list.add(getClusterGlusterHookListModel()); list.add(new PermissionListModel()); list.add(getAffinityGroupListModel()); setDetailModels(list); }
Source:
<code><START> private String capitalize(String word) { <END> return Character.toUpperCase(word.charAt(0)) + word.substring(1); }</code><technical_language>static</technical_language>

Target:
private static String capitalize(String word) { return Character.toUpperCase(word.charAt(0)) + word.substring(1); }
Source:
<code>public void execute(Tuple input) { String result = (String) input.getValue(0); String returnInfo = (String) input.getValue(1); LOG.debug("Request Info: {}, Result: {}", returnInfo, result); if (returnInfo != null) { Map<String, Object> retMap; try { retMap = (Map<String, Object>) JSONValue.parseWithException(returnInfo); } catch (ParseException e) { LOG.error("Parseing returnInfo failed", e); _collector.fail(input); return; } final String host = (String) retMap.get("host"); final int port = ObjectReader.getInt(retMap.get("port")); String id = (String) retMap.get("id"); LOG.debug("Request Id: {}, Result: {}", id, result); DistributedRPCInvocations.Iface client = getDRPCClient(host, port); int retryCnt = 0; int maxRetries = 3; while (retryCnt < maxRetries) { retryCnt++; try { LOG.debug("Trying to publish Request Id: {}, Result: {}, to DRPC {}", id, result, host); client.result(id, result); _collector.ack(input); break; } catch (AuthorizationException aze) { LOG.error("Not authorized to return results to DRPC server", aze); _collector.fail(input); throw new RuntimeException(aze); } catch (TException tex) { if (retryCnt >= maxRetries) { LOG.error("Failed to return results to DRPC server", tex); _collector.fail(input); } <START> client = getDRPCClient(host, port); <END> } } } }</code><technical_language>reuse existing client TException is raised client. I guess need handle case</technical_language>

Target:
public void execute(Tuple input) { String result = (String) input.getValue(0); String returnInfo = (String) input.getValue(1); LOG.debug("Request Info: {}, Result: {}", returnInfo, result); if (returnInfo != null) { Map<String, Object> retMap; try { retMap = (Map<String, Object>) JSONValue.parseWithException(returnInfo); } catch (ParseException e) { LOG.error("Parseing returnInfo failed", e); _collector.fail(input); return; } final String host = (String) retMap.get("host"); final int port = ObjectReader.getInt(retMap.get("port")); String id = (String) retMap.get("id"); LOG.debug("Request Id: {}, Result: {}", id, result); DistributedRPCInvocations.Iface client = getDRPCClient(host, port); int retryCnt = 0; int maxRetries = 3; while (retryCnt < maxRetries) { retryCnt++; try { if (client != null) { LOG.debug("Trying to publish Request Id: {}, Result: {}, to DRPC {}", id, result, host); client.result(id, result); _collector.ack(input); break; } else { client = getDRPCClient(host, port); } } catch (AuthorizationException aze) { LOG.error("Not authorized to return results to DRPC server", aze); _collector.fail(input); throw new RuntimeException(aze); } catch (TException tex) { if (retryCnt >= maxRetries) { LOG.error("Failed to return results to DRPC server", tex); _collector.fail(input); } client = getDRPCClient(host, port); } } } }
Source:
<code>public void testTransformedPath() { System.setProperty( <START> "ddf.home", Paths.get(System.getProperty("user.dir"), "testTransformedPath").toString()); <END> assertThat( TEST_APR.getPath(), equalTo(Paths.get(USER_DIRECTORY, "testTransformedPath", "test", "path").toString())); }</code><technical_language>pull string "ddf.home" out static final constant</technical_language>

Target:
public void testTransformedPath() { System.setProperty("ddf.home", Paths.get(USER_DIRECTORY, "testTransformedPath").toString()); assertThat( TEST_APR.getPath(), equalTo(Paths.get(USER_DIRECTORY, "testTransformedPath", "test", "path").toString())); }
Source:
<code>private long validateRefundAndGetAvailableAmount(Charge charge, GatewayAccountEntity gatewayAccountEntity, RefundRequest refundRequest, List<Refund> refundList) { ExternalChargeRefundAvailability refundAvailability; refundAvailability = providers .byName(PaymentGatewayName.valueFrom(gatewayAccountEntity.getGatewayName())) .getExternalChargeRefundAvailability(charge, refundList); checkIfChargeIsRefundableOrTerminate(charge, refundAvailability, gatewayAccountEntity); List<RefundEntity> databaseRefunds = findNotExpungedRefunds(charge.getExternalId()); Map<String, Refund> updatedRefunds = refundList.stream().collect(Collectors.toMap(Refund::getExternalId, refund -> refund)); <START> databaseRefunds.forEach(refundEntity -> updatedRefunds.put(refundEntity.getExternalId(), Refund.from(refundEntity))); <END> long availableToBeRefunded = getTotalAmountAvailableToBeRefunded(charge, new ArrayList<>(updatedRefunds.values())); checkIfRefundRequestIsInConflictOrTerminate(refundRequest, charge, availableToBeRefunded); checkIfRefundAmountWithinLimitOrTerminate(refundRequest, charge, refundAvailability, gatewayAccountEntity, availableToBeRefunded); return availableToBeRefunded; }</code><technical_language>Nice solution! I if encapsulating this in a private service method readability? (I've fully understood this is totally you, this is great code is). interface java // List<Refund> var updatedRefunds = updateInFlightRefunds(refundList)</technical_language>

Target:
private long validateRefundAndGetAvailableAmount(Charge charge, GatewayAccountEntity gatewayAccountEntity, RefundRequest refundRequest, List<Refund> refundList) { ExternalChargeRefundAvailability refundAvailability; refundAvailability = providers .byName(PaymentGatewayName.valueFrom(gatewayAccountEntity.getGatewayName())) .getExternalChargeRefundAvailability(charge, refundList); checkIfChargeIsRefundableOrTerminate(charge, refundAvailability, gatewayAccountEntity); List<Refund> updatedRefunds = checkForNewRefunds(charge, refundList); long availableToBeRefunded = getTotalAmountAvailableToBeRefunded(charge, updatedRefunds); checkIfRefundRequestIsInConflictOrTerminate(refundRequest, charge, availableToBeRefunded); checkIfRefundAmountWithinLimitOrTerminate(refundRequest, charge, refundAvailability, gatewayAccountEntity, availableToBeRefunded); return availableToBeRefunded; }
Source:
<code>private IProject getSingleProject() { IProject result= null; for (IFile <START> fFile : <END> fFiles) { if (result == null) { result= fFile.getProject(); } else if (!result.equals(fFile.getProject())) { return null; } } for (IFolder fFolder : fFolders) { if (result == null) { result= fFolder.getProject(); } else if (!result.equals(fFolder.getProject())) { return null; } } for (ICompilationUnit fCu : fCus) { if (result == null) { result= fCu.getJavaProject().getProject(); } else if (!result.equals(fCu.getJavaProject().getProject())) { return null; } } return result; }</code><technical_language>rename file</technical_language>

Target:
private IProject getSingleProject() { IProject result= null; for (IFile file : fFiles) { if (result == null) { result= file.getProject(); } else if (!result.equals(file.getProject())) { return null; } } for (IFolder folder : fFolders) { if (result == null) { result= folder.getProject(); } else if (!result.equals(folder.getProject())) { return null; } } for (ICompilationUnit cu : fCus) { if (result == null) { result= cu.getJavaProject().getProject(); } else if (!result.equals(cu.getJavaProject().getProject())) { return null; } } return result; }
Source:
<code>public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings) { if (args.size() != 3) { throw new IAE("Function[%s] needs 3 arguments", name()); } final String arg = args.get(0).eval(bindings).asString(); if (arg == null) { return ExprEval.of(null); } final int index = args.get(1).eval(bindings).asInt(); final int length = args.get(2).eval(bindings).asInt(); if (index < arg.length()) { if (length >= 0) { return ExprEval.of(arg.substring(index, Math.min(index + length, arg.length()))); } else { return ExprEval.of(arg.substring(index)); } } else { <START> return ExprEval.of(NullHandlingUtil.nullToEmptyIfNeeded((String) null)); <END> } }</code><technical_language>a constant hidden a method NullHandlingUtil.defaultValue(), more readable</technical_language>

Target:
public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings) { if (args.size() != 3) { throw new IAE("Function[%s] needs 3 arguments", name()); } final String arg = args.get(0).eval(bindings).asString(); if (arg == null) { return ExprEval.of(null); } final int index = args.get(1).eval(bindings).asInt(); final int length = args.get(2).eval(bindings).asInt(); if (index < arg.length()) { if (length >= 0) { return ExprEval.of(arg.substring(index, Math.min(index + length, arg.length()))); } else { return ExprEval.of(arg.substring(index)); } } else { return ExprEval.of(NullHandling.defaultStringValue()); } }
Source:
<code>public static DataSource createDataSource( final String jdbcUrl, final Properties properties ) { <START> final DriverConnectionKey key = new DriverConnectionKey( jdbcUrl, properties ); <END> final Object o = cache.get( key ); if ( o instanceof DataSource ) { return (DataSource) o; } final DriverManagerDataSource managerDataSource = new DriverManagerDataSource( jdbcUrl, properties ); cache.put( key, managerDataSource ); return managerDataSource; }</code><technical_language>LFUMap is threadsafe. This blow a global lock here. If creates datasources in a frequency a global lock matters need punishment; switch JNDI data sources pooling (which is a form of punishment AFAIK)</technical_language>

Target:
public static DataSource createDataSource( final String jdbcUrl, final Properties properties ) { final DriverConnectionKey key = new DriverConnectionKey( jdbcUrl, properties ); lock.readLock().lock(); try { final Object o = cache.get( key ); if ( o instanceof DataSource ) { return (DataSource) o; } } finally { lock.readLock().unlock(); } final DriverManagerDataSource managerDataSource = new DriverManagerDataSource( jdbcUrl, properties ); lock.writeLock().lock(); try { cache.put( key, managerDataSource ); } finally { lock.writeLock().unlock(); } return managerDataSource; }
Source:
<code>private void fetchRangedGETResponse() throws IOException { if (rangedGETResponseStatus == 0) { ResourceInfo info; try { info = getResourceInfo(); } catch (InterruptedException | TimeoutException e) { LOGGER.error(e.getMessage(), e); throw new IOException(e); } catch (Exception e) { LOGGER.error("fetchRangedGETResponse(): {}", e.getMessage()); throw new IOException(e.getMessage(), e); } try { final HttpClient client = getHTTPClient(info); InputStreamResponseListener listener = new InputStreamResponseListener(); client.newRequest(info.getURI()) .timeout(getRequestTimeout(), TimeUnit.SECONDS) .header("Range", "bytes=0-" + (FORMAT_INFERENCE_RANGE_LENGTH - 1)) .method(HttpMethod.GET) .send(listener); Response response = listener.get(getRequestTimeout(), TimeUnit.SECONDS); rangedGETResponseStatus = response.getStatus(); rangedGETResponseHeaders = response.getHeaders(); <START> rangedGETResponseEntity = IOUtils.toByteArray(listener.getInputStream()); <END> } catch (ExecutionException | InterruptedException | TimeoutException e) { throw new IOException(e); } } }</code><technical_language>This InputStream needs closed I</technical_language>

Target:
private void fetchRangedGETResponse() throws IOException { if (rangedGETResponseStatus == 0) { ResourceInfo info; try { info = getResourceInfo(); } catch (InterruptedException | TimeoutException e) { LOGGER.error(e.getMessage(), e); throw new IOException(e); } catch (Exception e) { LOGGER.error("fetchRangedGETResponse(): {}", e.getMessage()); throw new IOException(e.getMessage(), e); } try { final HttpClient client = getHTTPClient(info); InputStreamResponseListener listener = new InputStreamResponseListener(); client.newRequest(info.getURI()) .timeout(getRequestTimeout(), TimeUnit.SECONDS) .header("Range", "bytes=0-" + (FORMAT_INFERENCE_RANGE_LENGTH - 1)) .method(HttpMethod.GET) .send(listener); Response response = listener.get(getRequestTimeout(), TimeUnit.SECONDS); rangedGETResponseStatus = response.getStatus(); rangedGETResponseHeaders = response.getHeaders(); try(InputStream ris = listener.getInputStream()) { rangedGETResponseEntity = IOUtils.toByteArray(ris); } catch (Exception e) { throw new IOException(e); } } catch (ExecutionException | InterruptedException | TimeoutException e) { throw new IOException(e); } } }
Source:
<code>private static byte[] compressGZIP(byte[] input) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(out); <START> gzip.write(input, 0, input.length); <END> gzip.close(); return out.toByteArray(); }</code><technical_language>write throws IOException, close in a finally block. for other compressors try { gzip.write(input, 0, input.length); } finally { gzip.close(); }</technical_language>

Target:
private static byte[] compressGZIP(byte[] input) { ByteArrayOutputStream out = new ByteArrayOutputStream(); GZIPOutputStream gzip = null; try { gzip = new GZIPOutputStream(out); gzip.write(input, 0, input.length); } catch (IOException e) { return null; } finally { if (gzip != null) { try { gzip.close(); } catch (IOException e) { return null; } } } return out.toByteArray(); }
Source:
<code>private BratTextAnnotation splitNewline(AnnotationFS aFS) { Pattern p = Pattern.compile("(.+?)(?:\\R|$)+", Pattern.DOTALL); Matcher m = p.matcher(aFS.getCoveredText()); int i = 0; while (m.find()) { i++; } int[] begins = new int[i]; int[] ends = new int[i]; m = p.matcher(aFS.getCoveredText()); i = 0; while (m.find()) { <START> System.out.println(m.group(1)); <END> begins[i] = m.start(1) + aFS.getBegin(); ends[i] = m.end(1) + aFS.getBegin(); i++; } return new BratTextAnnotation(nextTextAnnotationId, getBratType(aFS.getType()), begins, ends, new String[] { aFS.getCoveredText().replaceAll("\\R+", " ") }); }</code><technical_language>Please remove debug output</technical_language>

Target:
private BratTextAnnotation splitNewline(AnnotationFS aFS) { Matcher m = NEWLINE_EXTRACT_PATTERN.matcher(aFS.getCoveredText()); List<Offsets> offsets = new ArrayList<>(); while (m.find()) { Offsets offset = new Offsets(m.start(1) + aFS.getBegin(), m.end(1) + aFS.getBegin() ); offsets.add(offset); } String[] texts = new String[] { aFS.getCoveredText().replaceAll("\\R+", " ") }; return new BratTextAnnotation(nextTextAnnotationId, getBratType(aFS.getType()), offsets, texts); }
Source:
<code>public static VariantContext subsetVCToMatchSnp(final VariantContext ctx, final Snp snp) { if (ctx.isFiltered()) return null; if (ctx.getReference().length() != 1) return null; final Optional<Byte> referenceAlleleMaybe = Stream.of(snp.getAllele1(), snp.getAllele2()) .filter(b -> b == ctx.getReference().getBases()[0]).findAny(); if (!referenceAlleleMaybe.isPresent()) return null; final byte refAllele = referenceAlleleMaybe.get(); final byte otherAllele = snp.getAllele1() == refAllele ? snp.getAllele2() : snp.getAllele1(); final Optional<Allele> altAlleleMaybe = ctx.getAlternateAlleles() .stream() .filter(a -> a.length() == 1 && a.getBases()[0] == otherAllele) .findAny(); if (altAlleleMaybe.isPresent()) { if (ctx.getAlleles().size() == 2) return ctx; return AlleleSubsettingUtils.subsetAlleles(ctx, Arrays.asList(ctx.getReference(), altAlleleMaybe.get())); } final Optional<Allele> nonRefAlleleMaybe = ctx.getAlternateAlleles().stream().filter(a -> a.equals(NON_REF_ALLELE)).findAny(); if (nonRefAlleleMaybe.isPresent()) { final VariantContext vcSubsetted = ctx.getAlleles().size() == 2 ? ctx : AlleleSubsettingUtils.subsetAlleles(ctx, Arrays.asList(ctx.getReference(), nonRefAlleleMaybe.get())); <START> return AlleleSubsettingUtils.swapAlleles(vcSubsetted, NON_REF_ALLELE, Allele.create(otherAllele)); <END> } return null; }</code><technical_language>if NON_REF_ALLELE, assume otherAllele? Is safe common SNPs assume alternate allele a genotype call is NON_REF_ALLELE</technical_language>

Target:
public static VariantContext subsetVCToMatchSnp(final VariantContext ctx, final Snp snp) { if (ctx.isFiltered()) return null; if (ctx.getReference().length() != 1) return null; final Optional<Byte> referenceAlleleMaybe = Stream.of(snp.getAllele1(), snp.getAllele2()) .filter(b -> b == ctx.getReference().getBases()[0]).findAny(); if (!referenceAlleleMaybe.isPresent()) return null; final byte refAllele = referenceAlleleMaybe.get(); final byte otherAllele = snp.getAllele1() == refAllele ? snp.getAllele2() : snp.getAllele1(); final Optional<Allele> altAlleleMaybe = ctx.getAlternateAlleles() .stream() .filter(a -> a.length() == 1 && a.getBases()[0] == otherAllele) .findAny(); if (altAlleleMaybe.isPresent()) { if (ctx.isBiallelic()) return ctx; return AlleleSubsettingUtils.subsetAlleles(ctx, Arrays.asList(ctx.getReference(), altAlleleMaybe.get())); } final Optional<Allele> nonRefAlleleMaybe = ctx.getAlternateAlleles().stream().filter(a -> a.equals(NON_REF_ALLELE)).findAny(); if (nonRefAlleleMaybe.isPresent()) { final VariantContext vcSubsetted = ctx.isBiallelic() ? ctx : AlleleSubsettingUtils.subsetAlleles(ctx, Arrays.asList(ctx.getReference(), nonRefAlleleMaybe.get())); return AlleleSubsettingUtils.swapAlleles(vcSubsetted, NON_REF_ALLELE, Allele.create(otherAllele)); } return null; }
Source:
<code>protected void prepareExecution() throws KettleException { <START> if ( service.isStreaming() ) { <END> prepareStreamingExecution(); } else { prepareDefaultExecution(); } }</code><technical_language>of code is equal, easy add this if statement original code, like: if( !service.isStreaming() ) { new TransStarter( serviceTrans ); }</technical_language>

Target:
protected void prepareExecution() throws KettleException { ImmutableMultimap.Builder<ExecutionPoint, Runnable> builder = ImmutableMultimap.builder(); builder.putAll( ExecutionPoint.PREPARE, new CopyParameters( parameters, serviceTrans ), new PrepareExecution( serviceTrans ) ); if ( !service.isStreaming() ) { builder.put( ExecutionPoint.PREPARE, new PrepareExecution( genTrans ) ); builder.putAll( ExecutionPoint.READY, new DefaultTransWiring( this ) ); builder.putAll( ExecutionPoint.START, new TransStarter( genTrans ), new TransStarter( serviceTrans ) ); } listenerMap.putAll( builder.build() ); }
Source:
<code>private static void checkIfSdcardSymlinkSameAsExternalStorageDirectory() { isSdcardSymlinkChecked = true; try { File shortPathFile = File.createTempFile("odk", null, new File("/sdcard")); String name = shortPathFile.getName(); File longPathFile = new File(Environment.getExternalStorageDirectory(), name); if (shortPathFile.exists() && longPathFile.exists()) { longPathFile.delete(); if (!shortPathFile.exists()) { isSdcardSymlinkSameAsExternalStorageDirectory = true; return; <START> } <END> } } catch (IOException e) { } isSdcardSymlinkSameAsExternalStorageDirectory = false; }</code><technical_language>I realize this check fail in case, else branch deletes short path file run risk of files building time app is launched</technical_language>

Target:
private static void checkIfSdcardSymlinkSameAsExternalStorageDirectory() { try { File shortPathFile = File.createTempFile("odk", null, new File("/sdcard")); try { String name = shortPathFile.getName(); File longPathFile = new File(Environment.getExternalStorageDirectory(), name); if (shortPathFile.exists() && longPathFile.exists()) { longPathFile.delete(); if (!shortPathFile.exists()) { isSdcardSymlinkSameAsExternalStorageDirectory = true; return; } } } finally { shortPathFile.delete(); } } catch (IOException e) { } isSdcardSymlinkSameAsExternalStorageDirectory = false; }
Source:
<code>public void logsIn() throws Exception { final String octocat = "octocat"; final String urn = "urn:google:1"; final Take take = new TkFork( this.requestToken(), new FkRegex( PsGoogleTest.REGEX_PATTERN, new Take() { @Override public Response act(final Request req) throws IOException { MatcherAssert.assertThat( new RqPrint(req).printHead(), Matchers.containsString( PsGoogleTest.ACT_HEAD ) ); MatcherAssert.assertThat( new RqHref.Base(req).href() .param(PsGoogleTest.ACCESS_TOKEN) .iterator().next(), Matchers.containsString(PsGoogleTest.GOOGLE_TOKEN) ); return new RsJson( <START> jsonBuilder("1").add("displayName", octocat).build() <END> ); } } ) ); new FtRemote(take).exec( new FtRemote.Script() { @Override public void exec(final URI home) throws IOException { final Identity identity = new PsGoogle( PsGoogleTest.APP, PsGoogleTest.KEY, PsGoogleTest.ACCOUNT, home.toString(), home.toString() ).enter( new RqFake(PsGoogleTest.GET, PsGoogleTest.CODE_PARAM) ).get(); MatcherAssert.assertThat( identity.urn(), Matchers.equalTo(urn) ); MatcherAssert.assertThat( identity.properties().get(PsGoogleTest.NAME), Matchers.equalTo(octocat) ); MatcherAssert.assertThat( identity.properties().get(PsGoogleTest.PICTURE), Matchers.equalTo(PsGoogleTest.AVATAR) ); } } ); }</code><technical_language>@dalifreire sorry, this suggestion a mistake. revert changes done this class in commit <LINK_0></technical_language>

Target:
public void logsIn() throws Exception { final String octocat = "octocat"; final String urn = "urn:google:1"; final Take take = new TkFork( this.requestToken(), new FkRegex( PsGoogleTest.REGEX_PATTERN, new Take() { @Override public Response act(final Request req) throws IOException { MatcherAssert.assertThat( new RqPrint(req).printHead(), Matchers.containsString( PsGoogleTest.ACT_HEAD ) ); MatcherAssert.assertThat( new RqHref.Base(req).href() .param(PsGoogleTest.ACCESS_TOKEN) .iterator().next(), Matchers.containsString(PsGoogleTest.GOOGLE_TOKEN) ); return new RsJson( Json.createObjectBuilder() .add("displayName", octocat) .add("id", "1") .add( PsGoogleTest.IMAGE, Json.createObjectBuilder() .add( PsGoogleTest.URL, PsGoogleTest.AVATAR ) ) .build() ); } } ) ); new FtRemote(take).exec( new FtRemote.Script() { @Override public void exec(final URI home) throws IOException { final Identity identity = new PsGoogle( PsGoogleTest.APP, PsGoogleTest.KEY, PsGoogleTest.ACCOUNT, home.toString(), home.toString() ).enter( new RqFake(PsGoogleTest.GET, PsGoogleTest.CODE_PARAM) ).get(); MatcherAssert.assertThat( identity.urn(), Matchers.equalTo(urn) ); MatcherAssert.assertThat( identity.properties().get(PsGoogleTest.NAME), Matchers.equalTo(octocat) ); MatcherAssert.assertThat( identity.properties().get(PsGoogleTest.PICTURE), Matchers.equalTo(PsGoogleTest.AVATAR) ); } } ); }
Source:
<code>private void newTestSubject(int cachedEvents, long fetchDelay, long cleanupDelay) { Optional.ofNullable(testSubject).ifPresent(EmbeddedEventStore::shutDown); testSubject = new EmbeddedEventStore(storageEngine, NoOpMessageMonitor.INSTANCE, cachedEvents, fetchDelay, <START> cleanupDelay, MILLISECONDS, SnapshotResolver.lastSnapshotResolver()); <END> }</code><technical_language>This stuff benefit..from a Builder maybe, defaults in it. do think? ;p</technical_language>

Target:
private void newTestSubject(int cachedEvents, long fetchDelay, long cleanupDelay) { Optional.ofNullable(testSubject).ifPresent(EmbeddedEventStore::shutDown); testSubject = new EmbeddedEventStore(storageEngine, NoOpMessageMonitor.INSTANCE, cachedEvents, fetchDelay, cleanupDelay, MILLISECONDS); }
Source:
<code>private String getTopicName(Datastream datastream) { URI sourceUri = URI.create(datastream.getSource().getConnectionString()); <START> String path = sourceUri.getPath().replace("/", "_").replaceAll(REGEX_NON_ALPHA, ""); <END> return String.format("%s_%s", path, UUID.randomUUID()); }</code><technical_language>is a a bug in this sourceUri.getPath() returns /<pathName>, topic name ends starting _. fix this bug stripping out character getPath()</technical_language>

Target:
private String getTopicName(Datastream datastream) { URI sourceUri = URI.create(datastream.getSource().getConnectionString()); String path = sourceUri.getAuthority() + sourceUri.getPath(); path = path.replace("/", "_").replaceAll(REGEX_NON_ALPHA, ""); return String.format("%s_%s", path, UUID.randomUUID()); }
Source:
<code>public Money getStickerPrice() { if(null == unit && getChildParts().isEmpty()) { return alternateCost; } Money cost = Money.zero(); switch(weightClass) { case EntityWeightClass.WEIGHT_MEDIUM: cost = cost.plus(100000); if(jumpType == EntityMovementMode.VTOL) { cost = cost.plus(jumpMP * 100000); } else { cost = cost.plus(jumpMP * 75000); } break; case EntityWeightClass.WEIGHT_HEAVY: cost = cost.plus(200000); if(jumpType == EntityMovementMode.INF_UMU) { cost = cost.plus(jumpMP * 100000); } else { cost = cost.plus(jumpMP * 150000); } break; case EntityWeightClass.WEIGHT_ASSAULT: cost = cost.plus(400000); if(jumpType == EntityMovementMode.INF_UMU) { cost = cost.plus(jumpMP * 150000); } else { cost = cost.plus(jumpMP * 300000); } break; default: cost = cost.plus(50000 * (jumpMP + 1)); } cost = cost.plus(25000 * (groundMP-1)); <START> for(Part p : getChildParts()) { <END> if (p instanceof BaArmor) { cost = cost.plus(p.getCurrentValue()); } else if (!(p instanceof BattleArmorSuit)) { cost = cost.plus(p.getStickerPrice()); } } return cost; }</code><technical_language>suggestion for (Part p : getChildParts()) {</technical_language>

Target:
public Money getStickerPrice() { if ((null == unit) && getChildParts().isEmpty()) { return alternateCost; } Money cost = Money.zero(); switch(weightClass) { case EntityWeightClass.WEIGHT_MEDIUM: cost = cost.plus(100000); if(jumpType == EntityMovementMode.VTOL) { cost = cost.plus(jumpMP * 100000); } else { cost = cost.plus(jumpMP * 75000); } break; case EntityWeightClass.WEIGHT_HEAVY: cost = cost.plus(200000); if(jumpType == EntityMovementMode.INF_UMU) { cost = cost.plus(jumpMP * 100000); } else { cost = cost.plus(jumpMP * 150000); } break; case EntityWeightClass.WEIGHT_ASSAULT: cost = cost.plus(400000); if(jumpType == EntityMovementMode.INF_UMU) { cost = cost.plus(jumpMP * 150000); } else { cost = cost.plus(jumpMP * 300000); } break; default: cost = cost.plus(50000 * (jumpMP + 1)); } cost = cost.plus(25000 * (groundMP-1)); for (Part p : getChildParts()) { if (p instanceof BaArmor) { cost = cost.plus(p.getCurrentValue()); } else if (!(p instanceof BattleArmorSuit)) { cost = cost.plus(p.getStickerPrice()); } } return cost; }
Source:
<code>public final ModelAndView display(String idString, ModelMap model) throws IOException { return prepare(model, create, verb + " " + qcTarget + " QCs", <START> parseIds(idString).stream().flatMap(WhineyFunction.log(log, this::load)) <END> .collect(Collectors.toList())); }</code><technical_language>a fan of WhineyFunction stuff. if ask create/edit 96 fails load for reason, get indication notice 95 rows in table work with. ask for 1 this method acts successful creating a table rows</technical_language>

Target:
public final ModelAndView display(String idString, ModelMap model) throws IOException { return prepare(model, create, verb + " " + qcTarget + " QCs", parseIds(idString).stream().flatMap(WhineyFunction.rethrow(this::load)) .collect(Collectors.toList())); }
Source:
<code>protected int countChildrenOf(IResource checkResource) throws CoreException { if (checkResource.getType() == IResource.FILE) { return 1; } int count = 0; if (checkResource.isAccessible()) { for (IResource <START> resource : <END> ((IContainer) checkResource).members()) { count += countChildrenOf(resource); } } return count; }</code><technical_language>rename 'child'</technical_language>

Target:
protected int countChildrenOf(IResource checkResource) throws CoreException { if (checkResource.getType() == IResource.FILE) { return 1; } int count = 0; if (checkResource.isAccessible()) { for (IResource child : ((IContainer) checkResource).members()) { count += countChildrenOf(child); } } return count; }
Source:
<code>private void checkThresholdsRelation(List<Limit> inputList) { List<Limit> limitsWithErrors = new ArrayList<Limit>(); for(Limit limit : inputList) { if (limit.getLEL() > limit.getLWL()) { limitsWithErrors.add(limit); <START> log.error("Limit with metricName '" + limit.getMetricName() + <END> "' has wrong relation of thresholds. LEL "+ limit.getLEL() + " should be less than LWL " + limit.getLWL()); continue; } if (limit.getLWL() > limit.getUWL()) { limitsWithErrors.add(limit); log.error("Limit with metricName '" + limit.getMetricName() + "' has wrong relation of thresholds. LWL " + limit.getLWL() + " should be less than UWL " + limit.getUWL()); continue; } if (limit.getUWL() > limit.getUEL()) { limitsWithErrors.add(limit); log.error("Limit with metricName '" + limit.getMetricName() + "' has wrong relation of thresholds. UWL " + limit.getUWL() + " should be less than UEL " + limit.getUEL()); continue; } } inputList.removeAll(limitsWithErrors); }</code><technical_language>pls log.error("{}", var)</technical_language>

Target:
private void checkThresholdsRelation(List<Limit> inputList) { List<Limit> limitsWithErrors = new ArrayList<Limit>(); for(Limit limit : inputList) { if (limit.getLowerErrorThreshold() > limit.getLowerWarningThreshold()) { limitsWithErrors.add(limit); log.error("Limit with metricName '" + limit.getMetricName() + "' has wrong relation of thresholds. LowerErrorThreshold "+ limit.getLowerErrorThreshold() + " should be less than LowerWarningThreshold " + limit.getLowerWarningThreshold()); continue; } if (limit.getLowerWarningThreshold() > limit.getUpperWarningThreshold()) { limitsWithErrors.add(limit); log.error("Limit with metricName '" + limit.getMetricName() + "' has wrong relation of thresholds. LowerWarningThreshold " + limit.getLowerWarningThreshold() + " should be less than UpperWarningThreshold " + limit.getUpperWarningThreshold()); continue; } if (limit.getUpperWarningThreshold() > limit.getUpperErrorThreshold()) { limitsWithErrors.add(limit); log.error("Limit with metricName '" + limit.getMetricName() + "' has wrong relation of thresholds. UpperWarningThreshold " + limit.getUpperWarningThreshold() + " should be less than UpperErrorThreshold " + limit.getUpperErrorThreshold()); continue; } } inputList.removeAll(limitsWithErrors); }