auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static Iterable<Object[]> getTracePaths() throws Exception { final List<Object[]> dirs = new LinkedList<>(); addDirsFrom(dirs, CTF_SUITE_BASE_PATH.resolve(Paths.get("regression", "metadata", "pass", "literal-integers")), IStatus.OK, 10, false); String tracePath; try { tracePath = FileLocator.toFileURL(CtfTestTrace.KERNEL.getTraceURL()).getPath(); } catch (IOException e) { <START> throw new IllegalStateException(); <END> } addDirsFrom(dirs, Paths.get(tracePath), IStatus.OK, 10, false); addDirsFrom(dirs, CTF_SUITE_BASE_PATH.resolve(Paths.get("regression", "metadata", "fail", "enum-empty")), IStatus.WARNING, 1, true); addDirsFrom(dirs, CTF_SUITE_BASE_PATH.resolve(Paths.get("regression", "metadata", "fail", "lttng-modules-2.0-pre1")), IStatus.WARNING, 1, true); addDirsFrom(dirs, BASE_PATH.resolve(Paths.get("synctraces.tar.gz")), IStatus.ERROR, 1, false); return dirs; }</code><technical_language>propagate e please</technical_language>

Target:
public static Iterable<Object[]> getTracePaths() throws Exception { final List<Object[]> dirs = new LinkedList<>(); addDirsFrom(dirs, CTF_SUITE_BASE_PATH.resolve(Paths.get("regression", "metadata", "pass", "literal-integers")), IStatus.OK, 10, false); String tracePath = FileLocator.toFileURL(CtfTestTrace.KERNEL.getTraceURL()).getPath(); addDirsFrom(dirs, Paths.get(tracePath), IStatus.OK, 10, false); addDirsFrom(dirs, CTF_SUITE_BASE_PATH.resolve(Paths.get("regression", "metadata", "fail", "enum-empty")), IStatus.WARNING, 1, true); addDirsFrom(dirs, CTF_SUITE_BASE_PATH.resolve(Paths.get("regression", "metadata", "fail", "lttng-modules-2.0-pre1")), IStatus.WARNING, 1, true); addDirsFrom(dirs, BASE_PATH.resolve(Paths.get("synctraces.tar.gz")), IStatus.ERROR, 1, false); return dirs; }
Source:
<code>private String sessionUserNameOr(String nameIfNoUser) { final Subject subject; <START> if ((subject = EnvironmentContext.getCurrent().getSubject()) != Subject.ANONYMOUS) { <END> return subject.getUserName(); } return nameIfNoUser; }</code><technical_language>!EnvironmentContext.getCurrent().getSubject().equals(Subject.ANONYMOUS) instead of != ? (I agree testing for memory pointer side effect in future I tests)</technical_language>

Target:
private String sessionUserNameOr(String nameIfNoUser) { final Subject subject = EnvironmentContext.getCurrent().getSubject(); if (!subject.isAnonymous()) { return subject.getUserName(); } return nameIfNoUser; }
Source:
<code>public void nestedTxTest() throws Exception { FedoraTransaction parentTx = repository.startTransaction(); repository.createFolderObject(pid, model); FedoraTransaction subTx = repository.startTransaction(); PID workPid = repository.mintContentPid(); repository.createWorkObject(workPid); subTx.close(); <START> assertNull(subTx.getTxUri()); <END> assertNotNull((parentTx.getTxUri())); assertTrue(FedoraTransaction.isStillAlive()); parentTx.close(); assertNull(parentTx.getTxUri()); assertFalse(FedoraTransaction.isStillAlive()); }</code><technical_language>verify workpid committed, aka exist of transaction. parent closes check work exist. do folder created verify stuff happened it? Sounds a helper for this other tests a non-tx client fails test if a get returns wrong status code</technical_language>

Target:
public void nestedTxTest() throws Exception { FedoraTransaction parentTx = repository.startTransaction(); repository.createFolderObject(pid, model); FedoraTransaction subTx = repository.startTransaction(); PID workPid = repository.mintContentPid(); repository.createWorkObject(workPid); subTx.close(); assertNull(subTx.getTxUri()); verifyNonTxStatusCode(workPid, 404); assertNotNull((parentTx.getTxUri())); assertTrue(FedoraTransaction.isStillAlive()); parentTx.close(); assertNull(parentTx.getTxUri()); assertFalse(FedoraTransaction.isStillAlive()); verifyNonTxStatusCode(workPid, 200); }
Source:
<code>public T newEntity2(Map flags, Entity owner) { Constructor<T> constructor; <START> try { <END> constructor = clazz.getConstructor(Map.class, Entity.class); } catch (NoSuchMethodException e) { throw Throwables.propagate(e); } try { return constructor.newInstance(flags, owner); } catch (InstantiationException e) { throw Throwables.propagate(e); } catch (IllegalAccessException e) { throw Throwables.propagate(e); } catch (InvocationTargetException e) { throw Throwables.propagate(e); } }</code><technical_language>separate try-catch blocks</technical_language>

Target:
public T newEntity2(Map flags, Entity owner) { try { Constructor<T> constructor = clazz.getConstructor(Map.class, Entity.class); return constructor.newInstance(flags, owner); } catch (InstantiationException e) { throw Throwables.propagate(e); } catch (IllegalAccessException e) { throw Throwables.propagate(e); } catch (InvocationTargetException e) { throw Throwables.propagate(e); } catch (NoSuchMethodException e) { throw Throwables.propagate(e); } }
Source:
<code>private void insertEmptyLines(CodeMirror cm, int line, int cnt) { Element div = DOM.createDiv(); div.setClassName(diffTable.style.padding()); <START> div.setAttribute("style", "height : " + cnt + "em"); <END> Configuration config = Configuration.create() .set("coverGutter", true) .set("above", line == 0); cm.addLineWidget(line == 0 ? 0 : (line - 1), div, config); }</code><technical_language>div.getStyle().setHeight(4, Unit.EM);</technical_language>

Target:
private void insertEmptyLines(CodeMirror cm, int line, int cnt) { Element div = DOM.createDiv(); div.setClassName(diffTable.style.padding()); div.getStyle().setHeight(cnt, Unit.EM); Configuration config = Configuration.create() .set("coverGutter", true) .set("above", line == 0); cm.addLineWidget(line == 0 ? 0 : (line - 1), div, config); }
Source:
<code>private JudgmentSearchResult sortJudges(JudgmentSearchResult judgmentSearchResult) { <START> List<JudgeResult> judges = judgmentSearchResult.getJudges().stream().collect(Collectors.toList()); <END> Collections.sort(judges, new JudgeResultComparator()); judgmentSearchResult.setJudges(judges); return judgmentSearchResult; }</code><technical_language>making stream is unnecessary</technical_language>

Target:
private JudgmentSearchResult sortJudges(JudgmentSearchResult judgmentSearchResult) { List<JudgeResult> judges = judgmentSearchResult.getJudges(); Collections.sort(judges, new JudgeResultComparator()); judgmentSearchResult.setJudges(judges); return judgmentSearchResult; }
Source:
<code>public InputStream getInputStream(RepoObject repoObject) { <START> byte[] content = data.get(repoObject.getBucketName()).get(repoObject.getChecksum()); <END> if (content != null) { return new ByteArrayInputStream(data.get(repoObject.getBucketName()).get(repoObject.getChecksum())); } log.debug("The content for the object was not found. Object --> key , bucket name: , content checksum: , version number: ", repoObject.getKey(), repoObject.getBucketName(), repoObject.getChecksum(), repoObject.getVersionNumber()); return null; }</code><technical_language>NPE if data repoObject.getBucketName(). (Looks a other methods problem too.)</technical_language>

Target:
public InputStream getInputStream(RepoObject repoObject) { Map<String, byte[]> bucket = data.get(repoObject.getBucketName()); if (bucket != null){ byte[] content = bucket.get(repoObject.getChecksum()); if (content != null) { return new ByteArrayInputStream(content); } } log.debug("The content for the object was not found. Object --> key , bucket name: , content checksum: , version number: ", repoObject.getKey(), repoObject.getBucketName(), repoObject.getChecksum(), repoObject.getVersionNumber()); return null; }
Source:
<code>public void filter(ContainerRequestContext containerRequestContext) throws IOException { containerRequestContext.setSecurityContext(new SecurityContext() { @Override public Principal getUserPrincipal() { <START> return new Principal() { @Override public String getName() { return "1"; } }; <END> } @Override public boolean isUserInRole(String s) { return false; } @Override public boolean isSecure() { return false; } @Override public String getAuthenticationScheme() { return null; } }); }</code><technical_language>suggestion return () -> "1";</technical_language>

Target:
public void filter(ContainerRequestContext containerRequestContext) throws IOException { containerRequestContext.setSecurityContext(new SecurityContext() { @Override public Principal getUserPrincipal() { return () -> "1"; } @Override public boolean isUserInRole(String s) { return false; } @Override public boolean isSecure() { return false; } @Override public String getAuthenticationScheme() { return null; } }); }
Source:
<code>public void postBuildIndex() throws IOException, ServiceException { if(optimizeEnabled) { optimizeIndex(solrConfiguration.getReindexCollectionName(), solrConfiguration.getReindexServer()); <START> if (!solrConfiguration.isSingleCoreMode()) { <END> shs.swapActiveCores(solrConfiguration); } } }</code><technical_language>core swap optimizeEnabled block? core swapped if optimize is enabled</technical_language>

Target:
public void postBuildIndex() throws IOException, ServiceException { if(optimizeEnabled) { optimizeIndex(solrConfiguration.getReindexCollectionName(), solrConfiguration.getReindexServer()); } if (!solrConfiguration.isSingleCoreMode()) { shs.swapActiveCores(solrConfiguration); } }
Source:
<code>public <T> ResourceOperations<T> getResourceOperations(Class<T> type) { <START> return (ResourceOperations<T>) (File.class.equals(type) ? DefaultFileOperations.INSTANCE : null); <END> }</code><technical_language>need return DefaultFileOperations.INSTANCE</technical_language>

Target:
public <T> ResourceOperations<T> getResourceOperations(Class<T> type) { return (ResourceOperations<T>) DefaultFileOperations.INSTANCE; }
Source:
<code>public void test_baseName_unknown() throws IOException, SAXException { try { JSONObject response = jenkinsRule.getJSON("i18n/resourceBundle?baseName=com.acme.XyzWhatever").getJSONObject(); } catch (Exception e) { Assert.assertNotNull(e); <START> } <END> }</code><technical_language>Hmmm .... check for more specific</technical_language>

Target:
public void test_baseName_unknown() throws IOException, SAXException { try { JSONObject response = jenkinsRule.getJSON("i18n/resourceBundle?baseName=com.acme.XyzWhatever").getJSONObject(); } catch (FailingHttpStatusCodeException e) { Assert.assertNotNull(e); Assert.assertTrue(e.getMessage().contains("com.acme.XyzWhatever")); } }
Source:
<code>public void calcTime(Date date, HistoryScanHolder holder) { Date now = new Date(); long seconds = TimeUnit.MILLISECONDS.toSeconds(now.getTime() - date.getTime()); long minutes = TimeUnit.MILLISECONDS.toMinutes(now.getTime() - date.getTime()); long hours = TimeUnit.MILLISECONDS.toHours(now.getTime() - date.getTime()); long days = TimeUnit.MILLISECONDS.toDays(now.getTime() - date.getTime()); String secText = String.valueOf(seconds) + " seconds ago"; String minText = String.valueOf(minutes) + " minutes ago"; String OneMinText = String.valueOf(minutes) + " minute ago"; String hourText = String.valueOf(hours) + " hours ago"; String OneHourText = String.valueOf(hours) + " hour ago"; String dayText = String.valueOf(days) + " days ago"; <START> String OneDayText = String.valueOf(days) + " day ago"; <END> if (seconds < 60) { holder.txtDate.setText(secText); } else if(minutes==1){ holder.txtDate.setText(OneMinText); } else if (minutes < 60) { holder.txtDate.setText(minText); } else if(hours==1){ holder.txtDate.setText(OneHourText); } else if (hours < 24) { holder.txtDate.setText(hourText); } else if(days==1){ holder.txtDate.setText(OneDayText); } else { holder.txtDate.setText(dayText); } }</code><technical_language><plural> care of this. This is for localisation. use: - - - - - Other While English easy two, few, other this is case in language</technical_language>

Target:
public void calcTime(Date date, HistoryScanHolder holder) { Date now = new Date(); long seconds = TimeUnit.MILLISECONDS.toSeconds(now.getTime() - date.getTime()); long minutes = TimeUnit.MILLISECONDS.toMinutes(now.getTime() - date.getTime()); long hours = TimeUnit.MILLISECONDS.toHours(now.getTime() - date.getTime()); long days = TimeUnit.MILLISECONDS.toDays(now.getTime() - date.getTime()); String secText = String.valueOf(seconds) + " seconds ago"; String hourText = res.getString(R.string.last_seen_string,hours,res.getQuantityString(R.plurals.hours,(int)hours)); String minText = res.getString(R.string.last_seen_string,minutes,res.getQuantityString(R.plurals.minutes,(int)minutes)); String dayText = res.getString(R.string.last_seen_string,days,res.getQuantityString(R.plurals.days,(int)days)); if (seconds < 60) { holder.txtDate.setText(secText); } else if (minutes < 60) { holder.txtDate.setText(minText); } else if (hours < 24) { holder.txtDate.setText(hourText); } else { holder.txtDate.setText(dayText); } }
Source:
<code>public List<Translation> getI18nTanslation() throws CommandNotFoundException, CommandExecutionException, CommandParameterizationException { List<Translation> items = new ArrayList<>(); <START> String local = getSearchFilters()!=null? getSearchFilters().get("locale"):null; <END> if (local == null) { getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "Request should contains 'locale' parameter."); return null; } Map<String, String> translations = i18n.getLocale(AbstractI18n.stringToLocale(local)); for (final Map.Entry<String, String> entry : translations.entrySet()) { items.add(new Translation(entry.getKey(), entry.getValue())); } return items; }</code><technical_language>IMHO extract this ugly code in a dedicated private method getLocale() local variable named locale</technical_language>

Target:
public List<Translation> getI18nTanslation() throws CommandNotFoundException, CommandExecutionException, CommandParameterizationException { List<Translation> items = new ArrayList<>(); String locale = getLocale(); if (locale == null) { getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "Request should contains 'locale' parameter."); return null; } Map<String, String> translations = i18n.getLocale(AbstractI18n.stringToLocale(locale)); for (final Map.Entry<String, String> entry : translations.entrySet()) { items.add(new Translation(entry.getKey(), entry.getValue())); } return items; }
Source:
<code>public List getWritablePartitions() { <START> List writablePartitions = new ArrayList(); <END> List healthyWritablePartitions = new ArrayList(); for (Partition partition : partitionMap.values()) { if (partition.getPartitionState() == PartitionState.READ_WRITE) { writablePartitions.add(partition); boolean up = true; for (Replica replica : partition.getReplicas()) { if (replica.isDown()) { up = false; break; } } if (up) { healthyWritablePartitions.add(partition); } } } return healthyWritablePartitions.isEmpty() ? writablePartitions : healthyWritablePartitions; }</code><technical_language>List<PartitionId></technical_language>

Target:
public List<PartitionId> getWritablePartitions() { List<PartitionId> writablePartitions = new ArrayList(); List<PartitionId> healthyWritablePartitions = new ArrayList(); for (Partition partition : partitionMap.values()) { if (partition.getPartitionState() == PartitionState.READ_WRITE) { writablePartitions.add(partition); boolean up = true; for (Replica replica : partition.getReplicas()) { if (replica.isDown()) { up = false; break; } } if (up) { healthyWritablePartitions.add(partition); } } } return healthyWritablePartitions.isEmpty() ? writablePartitions : healthyWritablePartitions; }
Source:
<code>public Object toObject(String value) { <START> throw new IllegalDataException("This operation is not suppported"); <END> }</code><technical_language>This is basically a load of a String in CSV format. a CSVLoader for au.com.bytecode.opencsv.CSVReader (an open source CSV reader). This crucial, though, if TODO for now</technical_language>

Target:
public Object toObject(String value) { throw new IllegalArgumentException("This operation is not suppported"); }
Source:
<code>public GeneralQueryResult getBySingleKeyBetweenRangeKeys(final String key, final String rangeKey1, final String rangeKey2, final int limit) { final Map<String, Condition> queryConditions = Maps.newHashMap(); if (rangeKeyColumnName.isPresent()) { final List<AttributeValue> values = Lists.newArrayList(); <START> values.add(new AttributeValue().withS(rangeKey1)); <END> values.add(new AttributeValue().withS(rangeKey2)); final Condition selectRangeKeyCondition = new Condition() .withComparisonOperator(ComparisonOperator.BETWEEN.toString()) .withAttributeValueList(values); queryConditions.put(rangeKeyColumnName.get(), selectRangeKeyCondition); } return getBySingleKey(key, queryConditions, limit); }</code><technical_language>java final List<AttributeValue> values = Lists.newArrayList( new AttributeValue().withS(rangeKey1), new AttributeValue().withS(rangeKey2) );</technical_language>

Target:
public GeneralQueryResult getBySingleKeyBetweenRangeKeys(final String key, final String rangeKey1, final String rangeKey2, final int limit) { final Map<String, Condition> queryConditions = Maps.newHashMap(); if (rangeKeyColumnName.isPresent()) { final List<AttributeValue> values = Lists.newArrayList( new AttributeValue().withS(rangeKey1), new AttributeValue().withS(rangeKey2)); final Condition selectRangeKeyCondition = new Condition() .withComparisonOperator(ComparisonOperator.BETWEEN.toString()) .withAttributeValueList(values); queryConditions.put(rangeKeyColumnName.get(), selectRangeKeyCondition); } return getBySingleKey(key, queryConditions, limit); }
Source:
<code>public ScoreFunction parse(QueryParseContext parseContext, XContentParser parser) throws IOException, QueryParsingException { String currentFieldName = null; String field = null; String text = null; String missing = null; XContentParser.Token token; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { if ("field".equals(currentFieldName)) { field = parser.text(); } else if ("text".equals(currentFieldName)) { text = parser.text(); } else if ("missing".equals(currentFieldName)) { missing = parser.text(); } else { throw new QueryParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]"); } } } if (field == null) { throw new QueryParsingException(parseContext, "[" + NAMES[0] + "] required field 'field' missing"); } if (text == null) { throw new QueryParsingException(parseContext, "[" + NAMES[0] + "] required field 'text' missing"); } SearchContext searchContext = SearchContext.current(); MappedFieldType fieldType = searchContext.smartNameFieldType(field); if (fieldType == null) { <START> throw new ElasticsearchException("Unable to find a field mapper for field [" + field + "]"); <END> } return new LevenshteinDistanceScore(parseContext.lookup(), fieldType, text, missing); }</code><technical_language>i suppose a field mapper anymore? kinda is .. i dunno random thought</technical_language>

Target:
public ScoreFunction parse(QueryParseContext parseContext, XContentParser parser) throws IOException, QueryParsingException { String currentFieldName = null; String field = null; String text = null; String missing = null; XContentParser.Token token; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { if ("field".equals(currentFieldName)) { field = parser.text(); } else if ("text".equals(currentFieldName)) { text = parser.text(); } else if ("missing".equals(currentFieldName)) { missing = parser.text(); } else { throw new QueryParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]"); } } } if (field == null) { throw new QueryParsingException(parseContext, "[" + NAMES[0] + "] required field 'field' missing"); } if (text == null) { throw new QueryParsingException(parseContext, "[" + NAMES[0] + "] required field 'text' missing"); } SearchContext searchContext = SearchContext.current(); MappedFieldType fieldType = searchContext.smartNameFieldType(field); if (fieldType == null) { throw new ElasticsearchException("Unable to load field type for field [" + field + "]"); } return new LevenshteinDistanceScore(parseContext.lookup(), fieldType, text, missing); }
Source:
<code>public void writeSingleResult() throws Exception { Server server = Server.builder().build(); Query query = Query.builder().build(); Result result = new Result(System.currentTimeMillis(), "attributeName", "className", "objDomain", "classNameAlias", "typeName", ImmutableMap.of("key", (Object)1)); ByteArrayOutputStream out = new ByteArrayOutputStream(); OpenTSDBWriter writer = getOpenTSDBWriter(out); writer.doWrite(server, query, of(result)); <START> Assertions.assertThat(out.toString()).startsWith("put classNameAlias.attributeName ") <END> .contains("type=key") .contains("host=") .endsWith("\n"); }</code><technical_language>Static import of Assertions.assertThat() more readable (if is conflict another assertion framework)</technical_language>

Target:
public void writeSingleResult() throws Exception { Server server = Server.builder().build(); Query query = Query.builder().build(); Result result = new Result(System.currentTimeMillis(), "attributeName", "className", "objDomain", "classNameAlias", "typeName", ImmutableMap.of("key", (Object)1)); ByteArrayOutputStream out = new ByteArrayOutputStream(); OpenTSDBWriter writer = getOpenTSDBWriter(out); writer.doWrite(server, query, of(result)); assertThat(out.toString()).startsWith("put classNameAlias.attributeName ") .contains("type=key") .contains("host=") .endsWith("\n"); }
Source:
<code>public void testWriteAdvHandle() throws Exception { Map<String, byte[]> customMetadata = new HashMap<>(); customMetadata.put("test", "test".getBytes(StandardCharsets.UTF_8)); try (WriteAdvHandle writer = result(newCreateLedgerOp() .withAckQuorumSize(1) .withWriteQuorumSize(2) .withEnsembleSize(3) .withDigestType(DigestType.MAC) .withCustomMetadata(customMetadata) .withPassword("password".getBytes(StandardCharsets.UTF_8)) .makeAdv() .execute());) { long entryId = 0; byte[] data = "foo".getBytes(StandardCharsets.UTF_8); <START> writer.write(entryId++, ByteBuffer.wrap(data)).get(); <END> writer.write(entryId++, ByteBuffer.wrap(data)).get(); writer.write(entryId++, Unpooled.wrappedBuffer(data)).get(1, TimeUnit.MINUTES); writer.write(entryId++, ByteBuffer.wrap(data)).get(1, TimeUnit.MINUTES); long expectedEntryId = writer.write(entryId++, ByteBuffer.wrap(data)).get(1, TimeUnit.MINUTES); assertEquals(expectedEntryId, writer.getLastAddConfirmed()); } }</code><technical_language>I line 92 line 96 do. different</technical_language>

Target:
public void testWriteAdvHandle() throws Exception { long ledgerId = 12345; setNewGeneratedLedgerId(ledgerId); try (WriteAdvHandle writer = result(newCreateLedgerOp() .withAckQuorumSize(1) .withWriteQuorumSize(2) .withEnsembleSize(3) .withPassword(password) .makeAdv() .execute());) { assertEquals(ledgerId, writer.getId()); long entryId = 0; result(writer.write(entryId++, ByteBuffer.wrap(data))); result(writer.write(entryId++, Unpooled.wrappedBuffer(data))); long expectedEntryId = result(writer.write(entryId++, ByteBuffer.wrap(data))); assertEquals(expectedEntryId, writer.getLastAddConfirmed()); } }
Source:
<code>public Account getAccountByName(String accountName) { <START> if (!isOpen) { <END> throw new IllegalStateException("AccountService is closed."); } if (accountName == null) { throw new IllegalArgumentException("accountName cannot be null."); } return cache.getAccountByName(accountName); }</code><technical_language>Move this open check a helper method, void checkOpen()</technical_language>

Target:
public Account getAccountByName(String accountName) { checkOpen(); Objects.requireNonNull(accountName, "accountName cannot be null."); return accountInfoMapRef.get().getAccountByName(accountName); }
Source:
<code>public WorkflowAction findAction(final String actionId, final String stepId, final User user) throws DotDataException, DotSecurityException { Logger.debug(this, "Finding the action: " + actionId + " for the step: " + stepId); final WorkflowAction workflowAction = this.workFlowFactory.findAction(actionId, stepId); if (null != workflowAction) { <START> if (!SYSTEM_WORKFLOW_ID.equals(workflowAction.getSchemeId())) { <END> if (!hasValidLicense() && !this.getFriendClass().isFriend()) { throw new DotSecurityException( "You must have a valid license to see any available action."); } } } return workflowAction; }</code><technical_language>This a method, assertValidLicense (final String schemeId) { if (!SYSTEM_WORKFLOW_ID.equals(workflowAction.getSchemeId()) && !hasValidLicense() && !this.getFriendClass().isFriend()) { throw ..</technical_language>

Target:
public WorkflowAction findAction(final String actionId, final String stepId, final User user) throws DotDataException, DotSecurityException { Logger.debug(this, "Finding the action: " + actionId + " for the step: " + stepId); final WorkflowAction workflowAction = this.workFlowFactory.findAction(actionId, stepId); if (null != workflowAction) { if (!SYSTEM_WORKFLOW_ID.equals(workflowAction.getSchemeId())) { if (!hasValidLicense() && !this.getFriendClass().isFriend()) { throw new DotSecurityException("Workflow-Actions-License-required"); } } } return workflowAction; }
Source:
<code>public byte[] getCacheKey() { byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); ByteBuffer buf = ByteBuffer .allocate(1 + fieldNameBytes.length + Floats.BYTES * breaks.length) .put(CACHE_TYPE_ID) .put(fieldNameBytes) <START> .put((byte)0); <END> buf.asFloatBuffer().put(breaks); return buf.array(); }</code><technical_language>0</technical_language>

Target:
public byte[] getCacheKey() { byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); ByteBuffer buf = ByteBuffer .allocate(1 + fieldNameBytes.length + Floats.BYTES * breaks.length) .put(CACHE_TYPE_ID) .put(fieldNameBytes) .put((byte)0xFF); buf.asFloatBuffer().put(breaks); return buf.array(); }
Source:
<code>private <IN, OUT> int addOperatorToStreamGraph( StreamOperatorFactory<OUT> operatorFactory, int inputId, TypeInformation<IN> inTypeInfo, TypeInformation<OUT> outTypInfo, String prefix, int parallelism, int maxParallelism, SinkTransformation<InputT, CommT, WriterStateT, GlobalCommT> sinkTransformation, <START> Context context) { <END> final StreamGraph streamGraph = context.getStreamGraph(); final String slotSharingGroup = context.getSlotSharingGroup(); final int transformationId = Transformation.getNewNodeId(); final ChainingStrategy chainingStrategy = sinkTransformation.getChainingStrategy(); if (chainingStrategy != null) { operatorFactory.setChainingStrategy(chainingStrategy); } streamGraph.addOperator( transformationId, slotSharingGroup, sinkTransformation.getCoLocationGroupKey(), operatorFactory, inTypeInfo, outTypInfo, String.format("%s %s", prefix, sinkTransformation.getName())); streamGraph.setParallelism(transformationId, parallelism); streamGraph.setMaxParallelism(transformationId, maxParallelism); StreamGraphUtils.configureBufferTimeout( streamGraph, transformationId, sinkTransformation, context.getDefaultBufferTimeout()); if (sinkTransformation.getUid() != null) { streamGraph.setTransformationUID( transformationId, String.format("%s %s", prefix, sinkTransformation.getUid())); } streamGraph.addEdge(inputId, transformationId, 0); return transformationId; }</code><technical_language>Do want this setting apply operators Writer? I more relevant for writer is user "sees", I 100% sure</technical_language>

Target:
private <IN, OUT> int addOperatorToStreamGraph( StreamOperatorFactory<OUT> operatorFactory, int inputId, TypeInformation<IN> inTypeInfo, TypeInformation<OUT> outTypInfo, String prefix, int parallelism, int maxParallelism, SinkTransformation<InputT, CommT, WriterStateT, GlobalCommT> sinkTransformation, Context context) { final StreamGraph streamGraph = context.getStreamGraph(); final String slotSharingGroup = context.getSlotSharingGroup(); final int transformationId = Transformation.getNewNodeId(); streamGraph.addOperator( transformationId, slotSharingGroup, sinkTransformation.getCoLocationGroupKey(), operatorFactory, inTypeInfo, outTypInfo, String.format("%s %s", prefix, sinkTransformation.getName())); streamGraph.setParallelism(transformationId, parallelism); streamGraph.setMaxParallelism(transformationId, maxParallelism); StreamGraphUtils.configureBufferTimeout( streamGraph, transformationId, sinkTransformation, context.getDefaultBufferTimeout()); if (sinkTransformation.getUid() != null) { streamGraph.setTransformationUID( transformationId, String.format("%s %s", prefix, sinkTransformation.getUid())); } streamGraph.addEdge(inputId, transformationId, 0); return transformationId; }
Source:
<code>private FastPipedInputStream sink() throws IOException { FastPipedInputStream s = sink.get(); <START> if (s==null) throw (IOException) new IOException("Reader side has already been abandoned", allocatedAt); <END> return s; }</code><technical_language>suggestion if (s==null) throw new IOException("Reader side abandoned", allocatedAt);</technical_language>

Target:
private FastPipedInputStream sink() throws IOException { FastPipedInputStream s = sink.get(); if (s==null) throw new IOException("Reader side has already been abandoned", allocatedAt); return s; }
Source:
<code>private AuthenticationResult tryAcquireTokenSilent(final AuthenticationRequest authenticationRequest) throws AuthenticationException { AuthenticationResult authenticationResult = null; if (shouldTrySilentFlow(authenticationRequest)) { Logger.v(TAG, "Try to acquire token silently, return valid AT or use RT in the cache."); <START> try { <END> authenticationResult = acquireTokenSilentFlow(authenticationRequest); } catch (final AuthenticationException exception) { if (exception.getCode() == ADALError.AUTH_REFRESH_FAILED_PROMPT_NOT_ALLOWED && authenticationRequest.isSilent()) { Logger.e(TAG, exception.getMessage(), authenticationRequest.getLogInfo(), exception.getCode()); throw exception; } else if (exception.getCode() == ADALError.DEVICE_CONNECTION_IS_NOT_AVAILABLE) { Logger.e(TAG, exception.getMessage(), authenticationRequest.getLogInfo(), exception.getCode()); throw exception; } } final boolean isAccessTokenReturned = isAccessTokenReturned(authenticationResult); if (!isAccessTokenReturned && authenticationRequest.isSilent()) { final String errorInfo = authenticationResult == null ? "No result returned from acquireTokenSilent" : authenticationResult.getErrorLogInfo(); Logger.e(TAG, "Prompt is not allowed and failed to get token:", authenticationRequest.getLogInfo() + " " + errorInfo, ADALError.AUTH_REFRESH_FAILED_PROMPT_NOT_ALLOWED); throw new AuthenticationException( ADALError.AUTH_REFRESH_FAILED_PROMPT_NOT_ALLOWED, authenticationRequest.getLogInfo() + " " + errorInfo); } if (isAccessTokenReturned) { Logger.v(TAG, "Token is successfully returned from silent flow. "); } } return authenticationResult; }</code><technical_language>a bit confused, here</technical_language>

Target:
private AuthenticationResult tryAcquireTokenSilent(final AuthenticationRequest authenticationRequest) throws AuthenticationException { AuthenticationResult authenticationResult = null; if (shouldTrySilentFlow(authenticationRequest)) { Logger.v(TAG, "Try to acquire token silently, return valid AT or use RT in the cache."); authenticationResult = acquireTokenSilentFlow(authenticationRequest); final boolean isAccessTokenReturned = isAccessTokenReturned(authenticationResult); if (!isAccessTokenReturned && authenticationRequest.isSilent()) { final String errorInfo = authenticationResult == null ? "No result returned from acquireTokenSilent" : authenticationResult.getErrorLogInfo(); Logger.e(TAG, "Prompt is not allowed and failed to get token:", authenticationRequest.getLogInfo() + " " + errorInfo, ADALError.AUTH_REFRESH_FAILED_PROMPT_NOT_ALLOWED); throw new AuthenticationException( ADALError.AUTH_REFRESH_FAILED_PROMPT_NOT_ALLOWED, authenticationRequest.getLogInfo() + " " + errorInfo); } if (isAccessTokenReturned) { Logger.v(TAG, "Token is successfully returned from silent flow. "); } } return authenticationResult; }
Source:
<code>public void onResume() { super.onResume(); <START> final String totalCards = ((CardDataAdapter) mListAdapter).getTotalCards() + " "; <END> mDeckCards.setText(totalCards); mPriceSetting = Integer.parseInt(getFamiliarActivity().mPreferenceAdapter.getTradePrice()); mShowTotalDecklistPrice = getFamiliarActivity().mPreferenceAdapter .getShowtotalDecklistPrice(); mCompressedDecklist.clear(); readAndCompressDecklist(null, mCurrentDeck); mListAdapter.notifyDataSetChanged(); }</code><technical_language>Integer.toString() instead of + " "</technical_language>

Target:
public void onResume() { super.onResume(); final String totalCards = Integer.toString(((CardDataAdapter) mListAdapter).getTotalCards()) + " "; mDeckCards.setText(totalCards); mPriceSetting = Integer.parseInt(getFamiliarActivity().mPreferenceAdapter.getTradePrice()); mShowTotalDecklistPrice = getFamiliarActivity().mPreferenceAdapter .getShowTotalDecklistPrice(); mCompressedDecklist.clear(); readAndCompressDecklist(null, mCurrentDeck); mListAdapter.notifyDataSetChanged(); }
Source:
<code><START> static public void write(Reader in, OutputStream out) throws IOException { <END> try { char[] charArray = new char[BUFFER_SIZE * 2]; byte[] byteArray; while (in.read(charArray) != -1) { byteArray = new String(charArray).getBytes(StandardCharsets.UTF_8); out.write(byteArray); } } finally { in.close(); } }</code><technical_language>work OutputStreamWriter? is, body of this method consist of: write(in, new OutputStreamWriter(out));</technical_language>

Target:
static public void write(Reader in, OutputStream out) throws IOException { write(in, new OutputStreamWriter(out)); }
Source:
<code>private static boolean definesSimilarMethod(IType type, IMethod method) { String methodName= method.getElementName(); String[] parameterTypes= method.getParameterTypes(); IMethod methodOfType= <START> type.getMethod(methodName, <END> parameterTypes); return methodOfType.exists(); }</code><technical_language>close() parameters ..</technical_language>

Target:
private static boolean definesSimilarMethod(IType type, IMethod method) throws JavaModelException { String methodName= method.getElementName(); IMethod[] typeMethods= type.getMethods(); return Arrays.asList(typeMethods).stream().anyMatch(typeMethod -> methodName.equals(typeMethod.getElementName())); }
Source:
<code>public boolean processEntryCommands(List<String> args, String activeCommand) throws IOException, ApiException { if (null != activeCommand) { boolean processed = processEntrySpecificCommands(args, activeCommand); if (processed) { return true; } switch (activeCommand) { case "info": info(args); break; case "list": list(args); break; case "search": search(args); break; case "publish": publish(args); break; case "star": star(args); break; case WDL_STRING: descriptor(args, WDL_STRING); break; case CWL_STRING: descriptor(args, CWL_STRING); break; case "refresh": refresh(args); break; case "label": label(args); break; case "manual_publish": manualPublish(args); break; case "convert": convert(args); break; case LAUNCH: launch(args); break; case DOWNLOAD: download(args); break; case "verify": verify(args); break; case "test_parameter": testParameter(args); break; <START> case "wes": <END> isWesCommand = true; if (getEntryType().toLowerCase().equals(WORKFLOW)) { processWesCommands(args); } else { errorMessage("WES API calls are only valid for workflows not tools.", CLIENT_ERROR); } break; default: return false; } return true; } return false; }</code><technical_language>Is plan merge this develop in a separate branch ready? If merged develop, command line options available, be. If works today, mind</technical_language>

Target:
public boolean processEntryCommands(List<String> args, String activeCommand) throws IOException, ApiException { if (null != activeCommand) { boolean processed = processEntrySpecificCommands(args, activeCommand); if (processed) { return true; } switch (activeCommand) { case "info": info(args); break; case "list": list(args); break; case "search": search(args); break; case "publish": publish(args); break; case "star": star(args); break; case WDL_STRING: descriptor(args, WDL_STRING); break; case CWL_STRING: descriptor(args, CWL_STRING); break; case "refresh": refresh(args); break; case "label": label(args); break; case "manual_publish": manualPublish(args); break; case "convert": convert(args); break; case LAUNCH: launch(args); break; case DOWNLOAD: download(args); break; case "verify": verify(args); break; case "test_parameter": testParameter(args); break; case "wes": isWesCommand = true; if (WORKFLOW.equalsIgnoreCase(getEntryType())) { processWesCommands(args); } else { errorMessage("WES API calls are only valid for workflows not tools.", CLIENT_ERROR); } break; default: return false; } return true; } return false; }
Source:
<code>public void testDefault() { assertRecordedDefaults(recordDefaults(BenchmarkSuiteConfig.class) <START> .setDatabase(null) .setSuitesTableName("benchmark_suites") .setQueriesTableName("benchmark_queries") .setSuite(null)); <END> }</code><technical_language>in order of definition in BenchmarkSuiteConfig</technical_language>

Target:
public void testDefault() { assertRecordedDefaults(recordDefaults(BenchmarkSuiteConfig.class) .setSuite(null) .setSuitesTableName("benchmark_suites") .setQueriesTableName("benchmark_queries")); }
Source:
<code>public SerializedPage serialize(Page page) { SliceOutput serializationBuffer = new DynamicSliceOutput(toIntExact(page.getSizeInBytes() + Integer.BYTES)); writeRawPage(page, serializationBuffer, blockEncodingSerde); Slice slice = serializationBuffer.slice(); <START> return serialize(slice, page.getPositionCount()); <END> }</code><technical_language>inline slice variable: return serialize(serializationBuffer.slice(), page.getPositionCount());</technical_language>

Target:
public SerializedPage serialize(Page page) { SliceOutput serializationBuffer = new DynamicSliceOutput(toIntExact(page.getSizeInBytes() + Integer.BYTES)); writeRawPage(page, serializationBuffer, blockEncodingSerde); Slice slice = serializationBuffer.slice(); int uncompressedSize = serializationBuffer.size(); byte markers = PageCodecMarker.none(); if (compressor.isPresent()) { ByteBuffer compressionBuffer = ByteBuffer.allocate(compressor.get().maxCompressedLength(uncompressedSize)); compressor.get().compress(slice.toByteBuffer(), compressionBuffer); compressionBuffer.flip(); if ((((double) compressionBuffer.remaining()) / uncompressedSize) <= MINIMUM_COMPRESSION_RATIO) { slice = Slices.wrappedBuffer(compressionBuffer); markers = COMPRESSED.set(markers); } } if (spillCipher.isPresent()) { slice = Slices.wrappedBuffer(spillCipher.get().encrypt(slice.toByteBuffer())); markers = ENCRYPTED.set(markers); } else { slice = Slices.copyOf(slice); } return new SerializedPage(slice, markers, page.getPositionCount(), uncompressedSize); }
Source:
<code><START> long query(CorfuStoreMetadata.Timestamp timestamp, LogReplicationMetadataType key) { <END> long val = -1; String str = queryString(timestamp, key); if (str != null) { val = Long.parseLong(str); } return val; }</code><technical_language>Lets add public/private accessor. private right. wrappers for metadata type</technical_language>

Target:
public long query(CorfuStoreMetadata.Timestamp timestamp, LogReplicationMetadataType key) { long val = -1; String str = queryString(timestamp, key); if (str != null) { val = Long.parseLong(str); } return val; }
Source:
<code>public void testIsVariant() { <START> assertTrue(VariantUtils.isVariant(DataUtils.makeVariant("chr7", 200000, 200001, "A", <END> newArrayList("C"), (Call[]) null))); assertFalse(VariantUtils.isVariant(DataUtils.makeVariant("chr7", 200000, 200001, "A", emptyAlt, (Call[]) null))); assertFalse(VariantUtils.isVariant(DataUtils.makeVariant("chr7", 200000, 200001, "A", null, (Call[]) null))); }</code><technical_language>I consider making a helper method simply statements occupy a single line</technical_language>

Target:
public void testIsVariant() { assertTrue(VariantUtils.isVariant(DataUtils.makeVariant("chr7", 200000, 200001, "A", Arrays.asList("C"), (Call[]) null))); assertFalse(VariantUtils.isVariant(DataUtils.makeVariant("chr7", 200000, 200001, "A", emptyAlt, (Call[]) null))); assertFalse(VariantUtils.isVariant(DataUtils.makeVariant("chr7", 200000, 200001, "A", null, (Call[]) null))); }
Source:
<code>public RevCommit parseCommit(final AnyObjectId id) throws MissingObjectException, IncorrectObjectTypeException, IOException { <START> initializeShallowCommits(); <END> RevObject c = peel(parseAny(id)); if (!(c instanceof RevCommit)) throw new IncorrectObjectTypeException(id.toObjectId(), Constants.TYPE_COMMIT); return (RevCommit) c; }</code><technical_language>necessary here. handled parseAny</technical_language>

Target:
public RevCommit parseCommit(final AnyObjectId id) throws MissingObjectException, IncorrectObjectTypeException, IOException { RevObject c = peel(parseAny(id)); if (!(c instanceof RevCommit)) throw new IncorrectObjectTypeException(id.toObjectId(), Constants.TYPE_COMMIT); return (RevCommit) c; }
Source:
<code>private Template getTemplateFromElement(NodeList templateNodes) { ArrayList<Element> templateElements = new ArrayList<Element>(4); <START> for (int i = 0; i < templateNodes.getLength(); i++) { <END> Node node = templateNodes.item(i); if (node instanceof Element) { templateElements.add((Element) node); } } Text name = (Text) templateElements.get(0).getFirstChild(); Text filename = (Text) templateElements.get(1).getFirstChild(); Text description = (Text) templateElements.get(2).getFirstChild(); Text source = (Text) templateElements.get(3).getFirstChild(); return new Template(name.getData(), getFullPathToTemplate(filename.getData()), description.getData(), source.getData()); }</code><technical_language>foreach</technical_language>

Target:
private Template getTemplateFromElement(NodeList templateNodes) { ArrayList<Element> templateElements = new ArrayList<Element>(4); for (int i = 0; i < templateNodes.getLength(); i++) { Node node = templateNodes.item(i); if (node instanceof Element) { templateElements.add((Element) node); } } Template template = new Template(); for (Element templateElement : templateElements) { Text elementText = (Text) templateElement.getFirstChild(); String elementString = elementText.getData(); switch (templateElement.getTagName()) { case "name": template.setName(elementString); break; case "filename": template.setPath(getFullPathToTemplate(elementString)); break; case "description": template.setDescription(elementString); break; case "source": template.setSource(elementString); break; } } return template; }
Source:
<code><START> public ATCommandPacket(int frameID, String command, byte[] parameter) { <END> super(XBeeAPIType.AT_COMMAND); this.frameID = frameID; this.command = command; this.parameter = parameter; }</code><technical_language>Throw proper exception if is supported: - NullPointerException if command == null. - IllegalArgumentException if frameID < 0 if frameID > 255</technical_language>

Target:
public ATCommandPacket(int frameID, String command, byte[] parameter) { super(APIFrameType.AT_COMMAND); if (command == null) throw new NullPointerException("Command cannot be null."); if (frameID < 0 || frameID > 255) throw new IllegalArgumentException("Frame ID must be between 0 and 255."); this.frameID = frameID; this.command = command; this.parameter = parameter; }
Source:
<code>public void canSearchForRepos() throws Exception { <START> final String coords = "test/test"; <END> final Search search = new RtGithub( new FakeRequest().withBody( Json.createObjectBuilder() .add("total_count", 1) .add( "items", Json.createArrayBuilder().add( Json.createObjectBuilder().add("full_name", coords) ) ).build().toString() ) ).search(); MatcherAssert.assertThat( search.repos("test", "stars", "desc").iterator().next() .coordinates().toString(), Matchers.equalTo(coords) ); }</code><technical_language>names for user repo ... confusing</technical_language>

Target:
public void canSearchForRepos() throws Exception { final String coords = "test-user1/test-repo1"; final Search search = new RtGithub( new FakeRequest().withBody( Json.createObjectBuilder() .add("total_count", 1) .add( "items", Json.createArrayBuilder().add( Json.createObjectBuilder().add("full_name", coords) ) ).build().toString() ) ).search(); MatcherAssert.assertThat( search.repos("test", "stars", "desc").iterator().next() .coordinates().toString(), Matchers.equalTo(coords) ); }
Source:
<code>public void isSameAllergen_shouldBeCaseInsensitiveForNonCodedAllergen() { <START> Concept concept = Context.getConceptService().getConceptByUuid(otherNonCodedConceptUuid); <END> Assert.assertTrue(new Allergen(null, concept, "other value").isSameAllergen(new Allergen(null, concept, "OTHER VALUE"))); }</code><technical_language>for otherNonCodedConceptUuid</technical_language>

Target:
public void isSameAllergen_shouldBeCaseInsensitiveForNonCodedAllergen() { Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Assert.assertTrue(new Allergen(null, concept, "other value").isSameAllergen(new Allergen(null, concept, "OTHER VALUE"))); }
Source:
<code>public void tearDown() throws Exception { for (MachineLocation machineLocation: machinesToTearDown) { try { location.release(machineLocation); <START> } catch (Exception e) { <END> } } if (managementContext != null) managementContext.terminate(); }</code><technical_language>catch ignore - mask problems. do a log.error. in try-catch collect exceptions end of method throw a CompoundRuntimeException test fails</technical_language>

Target:
public void tearDown() throws Exception { Set<Exception> exceptions = Collections.EMPTY_SET; for (MachineLocation machineLocation: machinesToTearDown) { try { location.release(machineLocation); } catch (Exception e) { exceptions.add(e); } } if (managementContext != null) managementContext.terminate(); if (exceptions.size() > 0) { throw new CompoundRuntimeException("Exception during tear down", exceptions); } }
Source:
<code>public static IdentityProviderSyncMode combineIdpAndMapperSyncMode(IdentityProviderSyncMode syncMode, IdentityProviderMapperSyncMode mapperSyncMode) { <START> switch (mapperSyncMode) { <END> case INHERIT: return syncMode; case IMPORT: return IdentityProviderSyncMode.IMPORT; case LEGACY: return IdentityProviderSyncMode.LEGACY; case FORCE: return IdentityProviderSyncMode.FORCE; default: throw new IllegalArgumentException("Should not happen"); } }</code><technical_language>This changed a single line: return IdentityProviderSyncMode.INHERIT.equals(mapperSyncMode) ? syncMode : mapperSyncMode</technical_language>

Target:
public static IdentityProviderSyncMode combineIdpAndMapperSyncMode(IdentityProviderSyncMode syncMode, IdentityProviderMapperSyncMode mapperSyncMode) { return IdentityProviderMapperSyncMode.INHERIT.equals(mapperSyncMode) ? syncMode : IdentityProviderSyncMode.valueOf(mapperSyncMode.toString()); }
Source:
<code>public String getImplementedCapability() { <START> return "Optaplanner"; <END> }</code><technical_language>=> OptaPlanner optaplanner</technical_language>

Target:
public String getImplementedCapability() { return "OptaPlanner"; }
Source:
<code>public CatalogProtos.PartitionDescProto getPartition(String databaseName, String tableName, String partitionName) throws CatalogException { <START> throw new RuntimeException("not supported!"); <END> }</code><technical_language>MemStore is for tests, need implement this function</technical_language>

Target:
public CatalogProtos.PartitionDescProto getPartition(String databaseName, String tableName, String partitionName) throws CatalogException { if (partitions.containsKey(tableName) && partitions.get(tableName).containsKey(partitionName)) { return partitions.get(tableName).get(partitionName); } else { throw new NoSuchPartitionException(partitionName); } }