auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private String[] getItemStrings(List<TmfEventTableColumn> columns, ITmfEvent event) { if (event == null) { return EMPTY_STRING_ARRAY; } synchronized (columns) { List<String> itemStrings = new ArrayList<>(columns.size()); int columnIndex = 0; for (TmfEventTableColumn column : columns) { ITmfEvent passedEvent = event; if (!(column instanceof TmfMarginColumn) && (event instanceof CachedEvent)) { passedEvent = ((CachedEvent) event).event; } TableColumn viewColumn = <START> fTable.getColumns()[columnIndex]; <END> if (passedEvent == null || (!viewColumn.getResizable() && viewColumn.getWidth() == 0)) { itemStrings.add(EMPTY_STRING); } else { itemStrings.add(column.getItemString(passedEvent)); } columnIndex++; } return itemStrings.toArray(new String[0]); } }</code><technical_language>This is wrong index if method parameter 'columns' is in table's creation order. a returned string blank for a column is visible, if this method is called getItemStrings(ITmfEvent)</technical_language>

Target:
private String[] getItemStrings(List<TmfEventTableColumn> columns, ITmfEvent event) { if (event == null) { return EMPTY_STRING_ARRAY; } synchronized (columns) { List<String> itemStrings = new ArrayList<>(columns.size()); int columnIndex = 0; for (TmfEventTableColumn column : columns) { ITmfEvent passedEvent = event; if (!(column instanceof TmfMarginColumn) && (event instanceof CachedEvent)) { passedEvent = ((CachedEvent) event).event; } TableColumn viewColumn = fTable.getColumns()[fColumnOrder[columnIndex]]; if (passedEvent == null || (!viewColumn.getResizable() && viewColumn.getWidth() == 0)) { itemStrings.add(EMPTY_STRING); } else { itemStrings.add(column.getItemString(passedEvent)); } columnIndex++; } return itemStrings.toArray(new String[0]); } }
Source:
<code>protected void onReceiveResult(int resultCode, Bundle resultData) { super.onReceiveResult(resultCode, resultData); if (resultCode == DownloadService.DOWNLOAD_COMPLETE) { Word word; try { word = getWordFromFilePath(mTempFilePath); <START> } catch (JSONException | IOException e) { <END> mListener.OnError(e); return; } if (mAutoInsert) { insertWordToLocal(word); } if (mListener != null) { mListener.OnWordReceived(word); } } if (resultCode == DownloadService.HTTP_ERROR && mListener != null) { mListener.OnHttpFailed( resultData.getInt(DownloadService.PARAM_STATUS), resultData.getString(DownloadService.PARAM_MESSAGE)); return; } }</code><technical_language>This is java 7's feature. convention users upgraded jdk7. So, please change try { ... } catch (JSONException e) { mListener.OnError(e); } catch (IOException e) { mListener.OnError(e); }</technical_language>

Target:
protected void onReceiveResult(int resultCode, Bundle resultData) { super.onReceiveResult(resultCode, resultData); switch (resultCode) { case DownloadService.DOWNLOAD_COMPLETE: Word word = getWordFromFilePath(mTempFilePath); if (mAutoInsert && word != null) { insertWordToLocal(word); } if (mListener != null && word != null) { mListener.onWordReceived(word); } break; case DownloadService.HTTP_ERROR: if (mListener != null) { mListener.onError(DownloadWordListener.HTTP_ERROR, (Exception) resultData .getSerializable(DownloadService.PARAM_EXCEPTION)); } break; case DownloadService.INTERNAL_ERROR: if (mListener != null) { mListener.onError(DownloadWordListener.INTERNAL_ERROR, (Exception) resultData .getSerializable(DownloadService.PARAM_EXCEPTION)); } break; } }
Source:
<code>private static boolean validateName(String value) throws WSSecurityException { Name name; try { name = new LdapName(value); } catch (Exception e) { LOG.info("Validation of X509 Subject Name failed: {}", e.getLocalizedMessage(), e); throw new WSSecurityException(ErrorCode.FAILURE, "Not a valid X509 Subject Name."); } <START> return name != null; <END> }</code><technical_language>return is used</technical_language>

Target:
private static void validateName(String value) throws WSSecurityException { Name name; try { name = new LdapName(value); } catch (Exception e) { LOG.info("Validation of X509 Subject Name failed: {}", e.getLocalizedMessage(), e); throw new WSSecurityException(ErrorCode.FAILURE, "Not a valid X509 Subject Name."); } }
Source:
<code>private void broadcastClusterEvent(ClusterEvent event, InterpreterSetting intpSetting) { if (!conf.isClusterMode()) { return; } List<Dependency> dependencies = intpSetting.getDependencies(); Map<String, InterpreterProperty> properties = (Map<String, InterpreterProperty>) intpSetting.getProperties(); InterpreterOption intpOption = intpSetting.getOption(); HashMap<String, String> params = new HashMap<>(); String jsonDep = gson.toJson(dependencies, new TypeToken<List<Dependency>>() { }.getType()); String jsonProps = gson.toJson(properties, new TypeToken<Map<String, InterpreterProperty>>() { }.getType()); <START> params.put("id", intpSetting.getId()); <END> params.put("name", intpSetting.getName()); params.put("group", intpSetting.getGroup()); params.put("dependencies", jsonDep); params.put("option", intpOption.toJson()); params.put("properties", jsonProps); ClusterMessage message = new ClusterMessage(event); message.put(params); String msg = ClusterMessage.serializeMessage(message); ClusterManagerServer.getInstance().broadcastClusterEvent( CLUSTER_INTP_SETTING_EVENT_TOPIC, msg); }</code><technical_language>create toJson in InterpreterSetting.java, create toJson in Dependency InterpreterOption ? I need serialization interpreter setting elsewhere, do InterpreterSettingInfoSaving, this is due legacy reason. unify serialization of InterpreterSetting</technical_language>

Target:
private void broadcastClusterEvent(ClusterEvent event, InterpreterSetting intpSetting) { if (!conf.isClusterMode()) { return; } String jsonIntpSetting = InterpreterSetting.toJson(intpSetting); ClusterMessage message = new ClusterMessage(event); message.put("intpSetting", jsonIntpSetting); String msg = ClusterMessage.serializeMessage(message); ClusterManagerServer.getInstance().broadcastClusterEvent( CLUSTER_INTP_SETTING_EVENT_TOPIC, msg); }
Source:
<code>public Object[][] fofnData() throws IOException { Path fofnPath1 = inMemoryfileSystem.getPath("Level1.fofn"); Files.copy(TEST_DATA_DIR.resolve("Level1.fofn"), fofnPath1); Path fofnPath2 = inMemoryfileSystem.getPath("Level2.fofn"); <START> Files.copy(TEST_DATA_DIR.resolve("Level2.fofn"), fofnPath2); <END> return new Object[][]{ {TEST_DATA_DIR + "/Level1.fofn", new String[]{".vcf", ".vcf.gz"}, 2}, {TEST_DATA_DIR + "/Level2.fofn", new String[]{".vcf", ".vcf.gz"}, 4}, {fofnPath1.toUri().toString(), new String[]{".vcf", ".vcf.gz"}, 2}, {fofnPath2.toUri().toString(), new String[]{".vcf", ".vcf.gz"}, 4} }; }</code><technical_language>Strings "Level1.fofn" "Level2.fofn" factor out (static test) re-use in returned array</technical_language>

Target:
public Object[][] fofnData() throws IOException { Path fofnPath1 = inMemoryfileSystem.getPath(level1); Files.copy(TEST_DATA_DIR.resolve(level1), fofnPath1); Path fofnPath2 = inMemoryfileSystem.getPath(level2); Files.copy(TEST_DATA_DIR.resolve(level2), fofnPath2); return new Object[][]{ {TEST_DATA_DIR + "/" + level1, new String[]{".vcf", ".vcf.gz"}, 2}, {TEST_DATA_DIR + "/" + level2, new String[]{".vcf", ".vcf.gz"}, 4}, {fofnPath1.toUri().toString(), new String[]{".vcf", ".vcf.gz"}, 2}, {fofnPath2.toUri().toString(), new String[]{".vcf", ".vcf.gz"}, 4} }; }
Source:
<code>public void eval( @Nonnull final ReadableTable tb, final int rowIdx, @Nullable final WritableColumn count, @Nonnull final WritableColumn result, @Nullable final ReadableTable state) throws InvocationTargetException, DbException, IOException { <START> Preconditions.checkArgument( <END> evaluator != null, "Call compile first or copy the data if it is the same in the input."); Preconditions.checkArgument( getExpression().isMultivalued() != (count == null), "count must be null for a single-valued expression and non-null for a multivalued expression."); try { evaluator.evaluate(tb, rowIdx, count, result, state); } catch (Exception e) { LOGGER.error(getJavaExpressionWithAppend(), e); throw e; } }</code><technical_language>throw exceptions</technical_language>

Target:
public void eval( @Nonnull final ReadableTable tb, final int rowIdx, @Nullable final WritableColumn count, @Nonnull final WritableColumn result, @Nullable final ReadableTable state) throws InvocationTargetException, DbException { Preconditions.checkArgument( evaluator != null, "Call compile first or copy the data if it is the same in the input."); Preconditions.checkArgument( getExpression().isMultiValued() != (count == null), "count must be null for a single-valued expression and non-null for a multivalued expression."); try { evaluator.evaluate(tb, rowIdx, count, result, state); } catch (Exception e) { LOGGER.error(getJavaExpressionWithAppend(), e); throw e; } }
Source:
<code>public void testCollectionsWithoutValue() { SettableConfig config = new DefaultSettableConfig(); PropertyFactory factory = DefaultPropertyFactory.from(config); ConfigProxyFactory proxy = new ConfigProxyFactory(config, config.getDecoder(), factory); ConfigWithCollections withCollections = proxy.newProxy(ConfigWithCollections.class); <START> Assert.assertNull(withCollections.getLinkedList()); <END> Assert.assertNull(withCollections.getList()); Assert.assertNull(withCollections.getSet()); Assert.assertNull(withCollections.getSortedSet()); }</code><technical_language>afaik practice for apis return collections is return empty list / map / set null; do here</technical_language>

Target:
public void testCollectionsWithoutValue() { SettableConfig config = new DefaultSettableConfig(); PropertyFactory factory = DefaultPropertyFactory.from(config); ConfigProxyFactory proxy = new ConfigProxyFactory(config, config.getDecoder(), factory); ConfigWithCollections withCollections = proxy.newProxy(ConfigWithCollections.class); Assert.assertTrue(withCollections.getLinkedList().isEmpty()); Assert.assertTrue(withCollections.getList().isEmpty()); Assert.assertTrue(withCollections.getSet().isEmpty()); Assert.assertTrue(withCollections.getSortedSet().isEmpty()); }
Source:
<code>public void initializeHandlers() { super.initializeHandlers(); registerHandler(getView().getTotalSecurity().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { getView().getTotalSecurity().getCommand().execute(); } })); registerHandler(getView().getTotalBugFix().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { getView().getTotalBugFix().getCommand().execute(); } })); registerHandler(getView().getTotalEnhancement().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { getView().getTotalEnhancement().getCommand().execute(); } })); <START> logger.info("subscribing to HostErrataCountModel changes"); END> currentErrataModel.addErrataCountsChangeListener(new IEventListener<EventArgs>() { @Override public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { logger.info("bus published message that the counts changed. update view."); ErrataCounts counts = currentErrataModel.getErrataCounts(); getView().showCounts(counts); } }); currentErrataModel.addErrorMessageChangeListener(new IEventListener<PropertyChangedEventArgs>() { @Override public void eventRaised(Event<? extends PropertyChangedEventArgs> ev, Object sender, PropertyChangedEventArgs args) { if (currentErrataModel.getMessage() != null && !currentErrataModel.getMessage().isEmpty()) { logger.info("bus published message that there was a query error. update view."); getView().showErrorMessage(SafeHtmlUtils.fromString(currentErrataModel.getMessage())); } } }); }</code><technical_language>debug/trace/remove</technical_language>

Target:
public void initializeHandlers() { super.initializeHandlers(); registerHandler(getView().getTotalSecurity().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { getView().getTotalSecurity().getCommand().execute(); } })); registerHandler(getView().getTotalBugFix().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { getView().getTotalBugFix().getCommand().execute(); } })); registerHandler(getView().getTotalEnhancement().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { getView().getTotalEnhancement().getCommand().execute(); } })); currentErrataModel.addErrataCountsChangeListener(new IEventListener<EventArgs>() { @Override public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { ErrataCounts counts = currentErrataModel.getErrataCounts(); getView().showCounts(counts); } }); currentErrataModel.addErrorMessageChangeListener(new IEventListener<PropertyChangedEventArgs>() { @Override public void eventRaised(Event<? extends PropertyChangedEventArgs> ev, Object sender, PropertyChangedEventArgs args) { if (currentErrataModel.getMessage() != null && !currentErrataModel.getMessage().isEmpty()) { getView().showErrorMessage(SafeHtmlUtils.fromString(currentErrataModel.getMessage())); } } }); }
Source:
<code>public void testLogoDetectGcs() throws Exception { LogoDetectionGcs.detectLogoGcs("gs://cloud-samples-data/video/googlework_tiny.mp4"); String got = bout.toString(); <START> assertThat(got).contains("Description : Google Maps"); <END> assertThat(got).contains("Confidence"); assertThat(got).contains("Start Time Offset"); assertThat(got).contains("End Time Offset"); }</code><technical_language>suggestion assertThat(got).contains("Description");</technical_language>

Target:
public void testLogoDetectGcs() throws IOException, ExecutionException, InterruptedException, TimeoutException { LogoDetectionGcs.detectLogoGcs("gs://cloud-samples-data/video/googlework_tiny.mp4"); String got = bout.toString(); assertThat(got).contains("Description"); assertThat(got).contains("Confidence"); assertThat(got).contains("Start Time Offset"); assertThat(got).contains("End Time Offset"); }
Source:
<code>public final CompletableFuture<Void> closeAsync() { if (isHandlerClosed.compareAndSet(false, true)) { return FutureUtils.composeAfterwards(closeHandlerAsync(), inFlightRequestTracker::awaitAsync); } else { <START> log.warn("Handler instance had already been closed, not allowed to close it again.", this); <END> return CompletableFuture.completedFuture(null); } }</code><technical_language>a toString() implementation reference handler user-friendly; I instead suggest untypedResponseMessageHeaders.getTargetRestEndpointURL. lines of handler for url ({}) closed, another attempt closing made</technical_language>

Target:
public final CompletableFuture<Void> closeAsync() { synchronized (lock) { if (terminationFuture == null) { this.terminationFuture = FutureUtils.composeAfterwards(closeHandlerAsync(), inFlightRequestTracker::awaitAsync); } else { log.warn("The handler instance for had already been closed, but another attempt at closing it was made.", untypedResponseMessageHeaders.getTargetRestEndpointURL()); } return this.terminationFuture; } }
Source:
<code>public void zeroMissingIndexes() { List<Map<String, Object>> result = jdbcTemplate.queryForList(missingIndexesQuery); String statements = result.stream() .flatMap(m -> m.entrySet() .stream() .filter(e -> e.getKey().equals("ddl")) .map(e -> e.getValue().toString())) .collect(Collectors.joining(";\n")); assertThat(result.size()) <START> .withFailMessage("Found missing indexes. Crete them using these statements:\n\n%s", statements) <END> .isZero(); }</code><technical_language>typo => create</technical_language>

Target:
public void zeroMissingIndexes() { List<Map<String, Object>> result = jdbcTemplate.queryForList(missingIndexesQuery); String statements = result.stream() .flatMap(m -> m.entrySet() .stream() .filter(e -> e.getKey().equals("ddl")) .map(e -> e.getValue().toString())) .collect(Collectors.joining(";\n")); assertThat(result.size()) .withFailMessage("Found missing indexes. Create them using these statements:\n\n%s", statements) .isZero(); }
Source:
<code>public void validatesXmlForSchemaValidity() throws Exception { <START> final int zero = 0; <END> final int ten = 10; final int hundred = 100; final int fifty = 50; final Random rand = new SecureRandom(); final XSD xsd = new XSDDocument( StringUtils.join( "<xs:schema xmlns:xs ='<LINK_0>' >", "<xs:element name='r'><xs:complexType>", "<xs:sequence>", "<xs:element name='x' type='xs:integer'", " minOccurs='0' maxOccurs='unbounded'/>", "</xs:sequence></xs:complexType></xs:element>", "</xs:schema>" ) ); final Callable<Void> callable = new Callable<Void>() { @Override public Void call() throws Exception { final int cnt = rand.nextInt(hundred); MatcherAssert.assertThat( xsd.validate( new DOMSource( new XMLDocument( StringUtils.join( "<r>", StringUtils.repeat("<x>hey</x>", cnt), "</r>" ) ).node() ) ), Matchers.hasSize(cnt << 1) ); return null; } }; final ExecutorService executorService = Executors.newFixedThreadPool(5); for (int count = zero; count < fifty; count = count + 1) { executorService.submit(callable); } executorService.awaitTermination(ten, TimeUnit.SECONDS); executorService.shutdown(); }</code><technical_language>@tmjee is a big sense declaring one-time variable (especially names). inline put checkstyle suppression</technical_language>

Target:
public void validatesXmlForSchemaValidity() throws Exception { final int timeout = 10; final int random = 100; final int loop = 50; final Random rand = new SecureRandom(); final XSD xsd = new XSDDocument( StringUtils.join( "<xs:schema xmlns:xs ='<LINK_0>' >", "<xs:element name='r'><xs:complexType>", "<xs:sequence>", "<xs:element name='x' type='xs:integer'", " minOccurs='0' maxOccurs='unbounded'/>", "</xs:sequence></xs:complexType></xs:element>", "</xs:schema>" ) ); final Callable<Void> callable = new Callable<Void>() { @Override public Void call() throws Exception { final int cnt = rand.nextInt(random); MatcherAssert.assertThat( xsd.validate( new DOMSource( new XMLDocument( StringUtils.join( "<r>", StringUtils.repeat("<x>hey</x>", cnt), "</r>" ) ).node() ) ), Matchers.hasSize(cnt << 1) ); return null; } }; final ExecutorService executorService = Executors.newFixedThreadPool(5); for (int count = 0; count < loop; count = count + 1) { executorService.submit(callable); } executorService.shutdown(); MatcherAssert.assertThat( executorService.awaitTermination(timeout, TimeUnit.SECONDS), Matchers.is(true) ); executorService.shutdownNow(); }
Source:
<code>private static void createFile(List<String> args) { if (isHelp(args, true)) { out(""); out("Usage: seqware create file [--help]"); out(" seqware create file --interactive"); out(" seqware create file <fields>"); out(""); out("Required fields:"); out(" --file <val>"); out(" --meta-type <val>"); out(" --parent-accession <val>"); out(""); out("Optional fields:"); out(" --description <val>"); out(""); } else { String file = reqVal(args, "--file"); String meta = reqVal(args, "--meta-type"); String parentId = reqVal(args, "--parent-accession"); String description = optVal(args, "--description", ""); extras(args, "create file"); String concat = String.format("%s::%s::%s::%s", "ManualProvisionFile", meta, file, description); <START> run("--plugin", "net.sourceforge.seqware.pipeline.plugins.Metadata", "--", "--parent-accession", <END> parentId, "--create", "--table", "file", "--file", concat); } }</code><technical_language>"type" is a valid field files</technical_language>

Target:
private static void createFile(List<String> args) { if (isHelp(args, true)) { out(""); out("Usage: seqware create file [--help]"); out(" seqware create file --interactive"); out(" seqware create file <fields>"); out(""); out("Required fields:"); out(" --file <val>"); out(" --meta-type <val>"); out(" --parent-accession <val>"); out(""); out("Optional fields:"); out(" --description <val>"); out(""); } else { String file = reqVal(args, "--file"); String meta = reqVal(args, "--meta-type"); String parentId = reqVal(args, "--parent-accession"); String type = optVal(args, "--type", ""); String description = optVal(args, "--description", ""); extras(args, "create file"); String concat = String.format("%s::%s::%s::%s", type, meta, file, description); run("--plugin", "net.sourceforge.seqware.pipeline.plugins.Metadata", "--", "--parent-accession", parentId, "--create", "--table", "file", "--field","algorithm::ManualProvisionFile", "--file", concat); } }
Source:
<code><START> public void testFindAllUsers() <END> { List<User> findAllUsers = userRepository.findAllUsers(); assertNotNull(findAllUsers); assertEquals(2, findAllUsers.size()); assertEquals(2, findAllUsers.iterator().next().getRoles().size()); assertEquals(2, findAllUsers.iterator().next().getRoles().size()); }</code><technical_language>@anki2189 pls add a @Transactional annotation well</technical_language>

Target:
public void testFindAllUsers() { List<User> findAllUsers = userRepository.findAllUsers(); assertNotNull(findAllUsers); assertEquals(2, findAllUsers.size()); assertEquals(3, findAllUsers.iterator().next().getRoles().size()); assertEquals(3, findAllUsers.iterator().next().getRoles().size()); }
Source:
<code>private String evaluateXPath(String metadata, XPathExpression xPathExpression) { <START> StringReader metadataReader = new StringReader(metadata); <END> InputSource inputXml = new InputSource(metadataReader); String text = null; try { Node result = (Node) xPathExpression.evaluate(inputXml, XPathConstants.NODE); if (result != null && result.getTextContent() != null) { text = result.getTextContent().trim(); } } catch (XPathExpressionException e) { LOGGER.error("Error evaluating xpath"); } return text; }</code><technical_language>pencil2: Inline metadataReader</technical_language>

Target:
private String evaluateXPath(String metadata, XPathExpression xPathExpression) { InputSource inputXml = new InputSource(new StringReader(metadata)); String text = null; try { Node result = (Node) xPathExpression.evaluate(inputXml, XPathConstants.NODE); if (result != null && result.getTextContent() != null) { text = result.getTextContent().trim(); } } catch (XPathExpressionException e) { LOGGER.warn("Could not evaluate xpath"); } return text; }
Source:
<code>private void formFieldsShouldNotBeGeneratedForPersistenceId(List<FieldDefinition> formModelFields) { <START> assertTrue(dataObject.getProperty("id") != null); <END> int EXPECTED_FORM_FIELD_COUNT = finderService.getDataObjectProperties(formModel.getClassName(), path).size() - 1; assertEquals("Form field should be generated for every data field except of persistence id", EXPECTED_FORM_FIELD_COUNT, formModelFields.size()); }</code><technical_language>@jsoltes Assert#assertNotNull(java.lang.Object) method here</technical_language>

Target:
private void formFieldsShouldNotBeGeneratedForPersistenceId(List<FieldDefinition> formModelFields) { assertNotNull(dataObject.getProperty("id")); int EXPECTED_FORM_FIELD_COUNT = finderService.getDataObjectProperties(formModel.getClassName(), path).size() - 1; assertEquals("Form field should be generated for every data field except of persistence id", EXPECTED_FORM_FIELD_COUNT, formModelFields.size()); }
Source:
<code>public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable { <START> this.methodName = method.getName(); <END> return null; }</code><technical_language>save arguments need configure arguments call</technical_language>

Target:
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable { this.methodName = method.getName(); if (objects != null && objects.length > 1) { arguments = new ArrayList<>(Arrays.asList(objects)); arguments.remove(objects.length - 1); } return null; }
Source:
<code>public Tuple getNext() throws IOException { if (reader == null) { return null; } if ("true".equals(jobConf.get("jsonLoader.nestedLoad.disabled"))) <START> isNestedLoadDisabled = true; <END> try { while (reader.nextKeyValue()) { Text value = (Text) reader.getCurrentValue(); incrCounter(JsonLoaderCounters.LinesRead, 1L); Tuple t = parseStringToTuple(value.toString()); if (t != null) { incrCounter(JsonLoaderCounters.LinesJsonDecoded, 1L); return t; } } return null; } catch (InterruptedException e) { int errCode = 6018; String errMsg = "Error while reading input"; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT, e); } }</code><technical_language>positive test is (isNestedLoadEnabled). I default disabled (for now). Another alternative is 'NestedJsonLoader()' extends JsonLoader. working pig properties is convenient for users</technical_language>

Target:
public Tuple getNext() throws IOException { if (reader == null) { return null; } if ("true".equals(jobConf.get(NESTED_LOAD_KEY))) isNestedLoadEnabled = true; try { while (reader.nextKeyValue()) { Text value = (Text) reader.getCurrentValue(); incrCounter(JsonLoaderCounters.LinesRead, 1L); Tuple t = parseStringToTuple(value.toString()); if (t != null) { incrCounter(JsonLoaderCounters.LinesJsonDecoded, 1L); return t; } } return null; } catch (InterruptedException e) { int errCode = 6018; String errMsg = "Error while reading input"; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT, e); } }
Source:
<code>public void setVolume(String sinkId, float volume) { AudioSink sink = null; if (sinkId == null) { sink = getSink(); } else { sink = audioSinks.get(sinkId); <START> } <END> if (sink != null) { try { sink.setVolume(volume); } catch (IOException e) { logger.error("An exception occured while setting the volume of sink : '{}'", sink.getId(), e.getMessage()); } } }</code><technical_language>This logic in methods of this file. create a private method, handles logic</technical_language>

Target:
public void setVolume(String sinkId, float volume) { AudioSink sink = getSink(sinkId); if (sink != null) { try { sink.setVolume(volume); } catch (IOException e) { logger.error("An exception occured while setting the volume of sink : '{}'", sink.getId(), e.getMessage()); } } }
Source:
<code>private static boolean isVarArg(HaxeParameterModel model) { if (model.getType().getType() instanceof SpecificHaxeClassReference) { SpecificHaxeClassReference classType = (SpecificHaxeClassReference)model.getType().getType(); if(classType != null && classType.getHaxeClass() != null) { String typeName = classType.getHaxeClass().getQualifiedName(); ResultHolder[] specifics = classType.getSpecifics(); if (specifics.length == 1) { <START> SpecificHaxeClassReference specificType = (SpecificHaxeClassReference)specifics[0].getType(); if (specificType != null && specificType.getHaxeClass() != null) { if (typeName.equals("Array") && specificType.getHaxeClass().getQualifiedName().equals("haxe.macro.Expr")) { return true; } if (typeName.equals("haxe.extern.Rest")) { return true; } } <END> } } } return false; }</code><technical_language>specificType.isArray()? add a SpecificTypeReference.isExpr() isRest()? end checking type name well, a bit clearer in code, centralizes access</technical_language>

Target:
private static boolean isVarArg(HaxeParameterModel model) { if (model.getType().getType() instanceof SpecificHaxeClassReference) { SpecificHaxeClassReference classType = (SpecificHaxeClassReference)model.getType().getType(); if(classType.getHaxeClass() != null) { ResultHolder[] specifics = classType.getSpecifics(); if (specifics.length == 1) { SpecificHaxeClassReference specificType = (SpecificHaxeClassReference)specifics[0].getType(); if (specificType.getHaxeClass() != null) { if (classType.isArray() && specificType.isExpr() ) { return true; } if (classType.isRest()) { return true; } } } } } return false; }
Source:
<code>public String toString() { <START> String res = new String(); <END> res += responseString + ","; res += responseUUID + ","; res += responseBoolean + ","; res += responseInteger + ","; res += responseManaType + ","; res += responseManaTypePlayerId; return res; }</code><technical_language>a new String() here</technical_language>

Target:
public String toString() { return new StringBuilder(responseString) .append(',') .append(responseUUID) .append(',') .append(responseBoolean) .append(',') .append(responseInteger) .append(',') .append(responseManaType) .append(',') .append(responseManaTypePlayerId).toString(); }
Source:
<code><START> DruidBrokerPageSource( <END> GeneratedDql brokerDql, List<ColumnHandle> columnHandles, DruidClient druidClient) { requireNonNull(brokerDql, "broker is null"); this.columnHandles = ImmutableList.copyOf(requireNonNull(columnHandles, "columnHandles is null")); requireNonNull(druidClient, "druid client is null"); this.responseStream = new BufferedReader(new InputStreamReader(druidClient.getData(brokerDql.getDql()))); List<DruidColumnHandle> handles = columnHandles.stream() .map(column -> (DruidColumnHandle) column) .collect(toImmutableList()); this.columnTypes = handles.stream() .map(DruidColumnHandle::getColumnType) .collect(toImmutableList()); this.pageBuilder = new PageBuilder(this.columnTypes); }</code><technical_language>need public, right</technical_language>

Target:
public DruidBrokerPageSource( GeneratedDql brokerDql, List<ColumnHandle> columnHandles, DruidClient druidClient) { requireNonNull(brokerDql, "broker is null"); this.columnHandles = ImmutableList.copyOf(requireNonNull(columnHandles, "columnHandles is null")); requireNonNull(druidClient, "druid client is null"); this.responseStream = new BufferedReader(new InputStreamReader(druidClient.getData(brokerDql.getDql()))); List<DruidColumnHandle> handles = columnHandles.stream() .map(column -> (DruidColumnHandle) column) .collect(toImmutableList()); this.columnTypes = handles.stream() .map(DruidColumnHandle::getColumnType) .collect(toImmutableList()); this.pageBuilder = new PageBuilder(this.columnTypes); }
Source:
<code><START> public void print(final OutputStream output) throws IOException { <END> try { output.write(this.bytes.value()); } finally { output.flush(); } }</code><technical_language>@fabriciofx This method is defined in interface, I need it: cactoos' TeeInput write Output source. safely remove this guy</technical_language>

Target:
public void print(final OutputStream output) throws IOException { final byte[] buf = new byte[4096]; final InputStream body = this.response.body(); try { while (true) { final int bts = body.read(buf); if (bts < 0) { break; } output.write(buf, 0, bts); } } finally { output.flush(); } }
Source:
<code>public void addAndRemoveLabelTest() { ListPanelCell listPanelCell = find("#dummy/dummy_col0_9"); assertEquals(1, listPanelCell.getIssueLabels().size()); Platform.runLater(stage::hide); UI.events.triggerEvent(new ShowLabelPickerEvent(listPanelCell.getIssue())); sleep(EVENT_DELAY); TextField labelPickerTextField = find("#labelPickerTextField"); click(labelPickerTextField); type("2 "); push(KeyCode.ENTER); sleep(EVENT_DELAY); assertEquals(0, listPanelCell.getIssueLabels().size()); <START> sleep(Notification.DEFAULT_NOTIFICATION_PANE_VISIBLE_PERIOD * 1000); <END> Platform.runLater(stage::hide); UI.events.triggerEvent(new ShowLabelPickerEvent(listPanelCell.getIssue())); sleep(EVENT_DELAY); labelPickerTextField = find("#labelPickerTextField"); click(labelPickerTextField); type("2 "); push(KeyCode.ENTER); sleep(EVENT_DELAY); assertEquals(1, listPanelCell.getIssueLabels().size()); }</code><technical_language>this synchronised UITest.waitUntilNodeDisappears? in waiting for notification UI away. Also, if tests work waitOnFxThread</technical_language>

Target:
public void addAndRemoveLabelTest() { ListPanelCell listPanelCell = find("#dummy/dummy_col0_9"); assertEquals(1, listPanelCell.getIssueLabels().size()); Platform.runLater(stage::hide); UI.events.triggerEvent(new ShowLabelPickerEvent(listPanelCell.getIssue())); waitUntilNodeAppears("#labelPickerTextField"); TextField labelPickerTextField = find("#labelPickerTextField"); click(labelPickerTextField); type("2 "); push(KeyCode.ENTER); waitUntilNodeDisappears("#labelPickerTextField"); assertEquals(0, listPanelCell.getIssueLabels().size()); NotificationPane notificationPane = find("#notificationPane"); while (notificationPane.isShowing()) { PlatformEx.waitOnFxThread(); sleep(100); } Platform.runLater(stage::hide); UI.events.triggerEvent(new ShowLabelPickerEvent(listPanelCell.getIssue())); waitUntilNodeAppears("#labelPickerTextField"); labelPickerTextField = find("#labelPickerTextField"); click(labelPickerTextField); type("2 "); push(KeyCode.ENTER); waitUntilNodeDisappears("#labelPickerTextField"); assertEquals(1, listPanelCell.getIssueLabels().size()); }
Source:
<code>public Set<String> findSagas(Class<?> sagaType, AssociationValue associationValue) { return managedSagas.entrySet() .stream() <START> .filter(avEntry -> sagaType.isAssignableFrom(avEntry.getValue().saga().getClass())) <END> .filter(avEntry -> avEntry.getValue().associationValues().contains(associationValue)) .map(Map.Entry::getKey) .collect(Collectors.toSet()); }</code><technical_language>sagaType.isInstance(...) instead</technical_language>

Target:
public Set<String> findSagas(Class<?> sagaType, AssociationValue associationValue) { return managedSagas.entrySet() .stream() .filter(avEntry -> sagaType.isInstance(avEntry.getValue().saga())) .filter(avEntry -> avEntry.getValue().associationValues().contains(associationValue)) .map(Map.Entry::getKey) .collect(Collectors.toSet()); }
Source:
<code>public void testGetUserSelectResolverNotSet() { MockEnabledModelResolver resolver1 = new MockEnabledModelResolver(); manager.add(resolver1, resolver1.getClass().getName() + "1", "", ""); MockEnabledModelResolver resolver2 = new MockEnabledModelResolver(); manager.add(resolver2, resolver2.getClass().getName() + "2", "", ""); MockEnabledModelResolver resolver3 = new MockEnabledModelResolver(); String resolver3Id = resolver3.getClass().getName() + "3"; manager.add(resolver3, resolver3Id, "", ""); <START> assertEquals(manager.getUserSelectedResolver(), null); <END> }</code><technical_language>Please assertNull instead</technical_language>

Target:
public void testGetUserSelectResolverNotSet() { MockEnabledModelResolver resolver1 = new MockEnabledModelResolver(); manager.add(resolver1, resolver1.getClass().getName() + "1", "", ""); MockEnabledModelResolver resolver2 = new MockEnabledModelResolver(); manager.add(resolver2, resolver2.getClass().getName() + "2", "", ""); MockEnabledModelResolver resolver3 = new MockEnabledModelResolver(); String resolver3Id = resolver3.getClass().getName() + "3"; manager.add(resolver3, resolver3Id, "", ""); assertNull(manager.getUserSelectedResolver()); }
Source:
<code>private ITmfTrace put(String path, String name, String typeID) throws TmfTraceException, TmfTraceImportException, InstantiationException, IllegalAccessException, CoreException { List<TraceTypeHelper> traceTypes = TmfTraceType.selectTraceType(path, typeID); if (traceTypes.isEmpty()) { return null; } IResource resource = getResource(path); if <START> (resource == null) { return null; } <END> TraceTypeHelper helper = traceTypes.get(0); ITmfTrace trace = helper.getTraceClass().newInstance(); trace.initTrace(resource, path, ITmfEvent.class, name, typeID); trace.indexTrace(false); TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, trace, null)); return trace; }</code><technical_language>true. remove it</technical_language>

Target:
private ITmfTrace put(String path, String name, String typeID) throws TmfTraceException, TmfTraceImportException, InstantiationException, IllegalAccessException, CoreException { List<TraceTypeHelper> traceTypes = TmfTraceType.selectTraceType(path, typeID); if (traceTypes.isEmpty()) { return null; } IResource resource = getResource(path); TraceTypeHelper helper = traceTypes.get(0); ITmfTrace trace = helper.getTraceClass().newInstance(); trace.initTrace(resource, path, ITmfEvent.class, name, typeID); trace.indexTrace(false); TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, trace, null)); return trace; }
Source:
<code>private void storeChildTuple(final int childIndex, final TupleBatch tb) { List<Column<?>> inputColumns = tb.getDataColumns(); for (int row = 0; row < tb.numTuples(); ++row) { for (int column = 0; column < tb.numColumns(); column++) { tables[childIndex].put(column, inputColumns.get(column), row); if (isIndexed(new JoinField(childIndex, column))) { int thisRow = tables[childIndex].numTuples(); if (column == tb.numColumns() - 1) { <START> thisRow = tables[childIndex].numTuples() - 1; <END> } int lastRow = thisRow - 1; if (lastRow == -1 || TupleUtils.cellCompare(tables[childIndex], column, lastRow, tb, column, row) != 0) { firstVarIndices[childIndex].add(thisRow); } } } } }</code><technical_language>thisRow-- instead? Clearer subtracting 1</technical_language>

Target:
private void storeChildTuple(final int childIndex, final TupleBatch tb) { List<Column<?>> inputColumns = tb.getDataColumns(); for (int row = 0; row < tb.numTuples(); ++row) { for (int column = 0; column < tb.numColumns(); column++) { tables[childIndex].put(column, inputColumns.get(column), row); if (isIndexed(new JoinField(childIndex, column))) { int thisRow = tables[childIndex].numTuples(); if (column == tb.numColumns() - 1) { thisRow--; } int lastRow = thisRow - 1; if (lastRow == -1 || TupleUtils.cellCompare(tables[childIndex], column, lastRow, tb, column, row) != 0) { firstVarIndices[childIndex].add(thisRow); } } } } }
Source:
<code>public static AEColor getColor( ItemStack item ) { final NBTTagCompound c = item.getTagCompound(); if( c != null && c.hasKey( "color" ) ) { String color = c.getString( "color" ); if( color != null ) { try { return AEColor.valueOf( color ); } <START> catch( final Exception e ) <END> { } } } return null; }</code><technical_language>![CRITICAL](<LINK_0> log rethrow this exception. [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
public static AEColor getColor( ItemStack item ) { final NBTTagCompound c = item.getTagCompound(); if( c != null && c.hasKey( "color" ) ) { final String color = c.getString( "color" ); if( color != null ) { try { return AEColor.valueOf( color ); } catch( final Exception e ) { } } } return null; }
Source:
<code>private void initProfiles(Injector injector) { LOGGER.info("Initializing Profiles"); ServiceProfileManager profileManager = injector.getInstance(ServiceProfileManager.class); Map<String, Map<String, String>> profiles = injector.getInstance(MyriadConfiguration.class).getProfiles(); TaskUtils taskUtils = injector.getInstance(TaskUtils.class); OfferUtils.setVcoreRatio(taskUtils.getNodeManagerVcoreRatio()); if (MapUtils.isNotEmpty(profiles)) { for (Map.Entry<String, Map<String, String>> profile : profiles.entrySet()) { Map<String, String> profileResourceMap = profile.getValue(); if (MapUtils.isNotEmpty(profiles) && (profileResourceMap.containsKey("vcore") || profileResourceMap.containsKey("cpu")) && profileResourceMap.containsKey("mem")) { Long vcore = profileResourceMap.containsKey("vcore") ? Long.parseLong(profileResourceMap.get("vcore")) : <START> Long.parseLong(profileResourceMap.get("cpu")); <END> Long mem = Long.parseLong(profileResourceMap.get("mem")); ServiceResourceProfile serviceProfile = new ExtendedResourceProfile(new NMProfile(profile.getKey(), vcore, mem, taskUtils.getNodeManagerVcoreRatio()), taskUtils.getNodeManagerCpus(), taskUtils.getNodeManagerMemory(), taskUtils.getNodeManagerPorts()); profileManager.add(serviceProfile); } else { LOGGER.error("Invalid definition for profile: " + profile.getKey()); } } } }</code><technical_language>Worth a warning Incase CPU vcore set</technical_language>

Target:
private void initProfiles(Injector injector) { LOGGER.info("Initializing Profiles"); ServiceProfileManager profileManager = injector.getInstance(ServiceProfileManager.class); Map<String, Map<String, String>> profiles = injector.getInstance(MyriadConfiguration.class).getProfiles(); TaskUtils taskUtils = injector.getInstance(TaskUtils.class); OfferUtils.setVcoreRatio(taskUtils.getNodeManagerVcoreRatio()); if (MapUtils.isNotEmpty(profiles)) { for (Map.Entry<String, Map<String, String>> profile : profiles.entrySet()) { Map<String, String> profileResourceMap = profile.getValue(); if (MapUtils.isNotEmpty(profiles) && (profileResourceMap.containsKey("vcore") || profileResourceMap.containsKey("cpu")) && profileResourceMap.containsKey("mem")) { Long vcore = profileResourceMap.containsKey("vcore") ? Long.parseLong(profileResourceMap.get("vcore")) : Long.parseLong(profileResourceMap.get("cpu")); if (profileResourceMap.containsKey("cpu")) { LOGGER.warn("Deprecated parameter 'cpu' in profiles, please use 'vcore' instead!"); } Long mem = Long.parseLong(profileResourceMap.get("mem")); ServiceResourceProfile serviceProfile = new ExtendedResourceProfile(new NMProfile(profile.getKey(), vcore, mem, taskUtils.getNodeManagerVcoreRatio()), taskUtils.getNodeManagerCpus(), taskUtils.getNodeManagerMemory(), taskUtils.getNodeManagerPorts()); profileManager.add(serviceProfile); } else { LOGGER.error("Invalid definition for profile: " + profile.getKey()); } } } }
Source:
<code>protected void testExecute_notEnoughParameters_shouldFail() { loginAsStudent(student1InCourse1.getGoogleId()); <START> ______TS("Not enough parameters"); <END> verifyHttpParameterFailure(); verifyHttpParameterFailure(Const.ParamsNames.FEEDBACK_QUESTION_ID, qn1InSession1InCourse1.getId()); verifyHttpParameterFailure(Const.ParamsNames.INTENT, Intent.STUDENT_SUBMISSION.toString()); }</code><technical_language>need put __TS if is case in method method name describe case. Check other methods remove them</technical_language>

Target:
protected void testExecute_notEnoughParameters_shouldFail() { loginAsStudent(student1InCourse1.getGoogleId()); verifyHttpParameterFailure(); verifyHttpParameterFailure(Const.ParamsNames.FEEDBACK_QUESTION_ID, qn1InSession1InCourse1.getId()); verifyHttpParameterFailure(Const.ParamsNames.INTENT, Intent.STUDENT_SUBMISSION.toString()); }
Source:
<code>public TranscriptConsequence resolve(VariantAnnotation variantAnnotation) { List<TranscriptConsequence> transcripts = new ArrayList<>(); <START> if (variantAnnotation.getTranscriptConsequences() != null) { <END> for (TranscriptConsequence transcript : variantAnnotation.getTranscriptConsequences()) { if (transcript.getTranscriptId() != null && transcript.getCanonical() != null && transcript.getCanonical().equals("1")) { transcripts.add(transcript); } } } if (transcripts.size() == 1) { return transcripts.iterator().next(); } else if (transcripts.size() > 1) { return this.consequencePrioritizer.transcriptWithMostSevereConsequence( transcripts, variantAnnotation.getMostSevereConsequence()); } else { return this.consequencePrioritizer.transcriptWithMostSevereConsequence( variantAnnotation.getTranscriptConsequences(), variantAnnotation.getMostSevereConsequence()); } }</code><technical_language>@leexgh personally find easier read getTranscriptConsequences() is assigned a variable in this null check subsequently iterate instead of calling method</technical_language>

Target:
public TranscriptConsequence resolve(VariantAnnotation variantAnnotation) { List<TranscriptConsequence> transcripts = new ArrayList<>(); List<TranscriptConsequence> transcriptConsequences = variantAnnotation.getTranscriptConsequences(); if (transcriptConsequences != null) { for (TranscriptConsequence transcript : transcriptConsequences) { if (transcript.getTranscriptId() != null && transcript.getCanonical() != null && transcript.getCanonical().equals("1")) { transcripts.add(transcript); } } } if (transcripts.size() == 1) { return transcripts.iterator().next(); } else if (transcripts.size() > 1) { return this.consequencePrioritizer.transcriptWithMostSevereConsequence( transcripts, variantAnnotation.getMostSevereConsequence()); } else { return this.consequencePrioritizer.transcriptWithMostSevereConsequence( variantAnnotation.getTranscriptConsequences(), variantAnnotation.getMostSevereConsequence()); } }
Source:
<code>public PatchSet getBasePatchSet(ChangeEdit edit, RevCommit commit) throws IOException, InvalidChangeOperationException { if (commit.getParentCount() != 1) { throw new InvalidChangeOperationException( "change edit commit <START> hase multiple <END> parents"); } RevCommit parentCommit = commit.getParent(0); ObjectId rev = parentCommit.getId(); RevId parentRev = new RevId(ObjectId.toString(rev)); try { List<PatchSet> r = db.get().patchSets().byRevision(parentRev).toList(); if (r.isEmpty()) { throw new InvalidChangeOperationException(String.format( "patch set %s change edit is based on doesn't exist", rev.abbreviate(8))); } if (r.size() > 1) { throw new InvalidChangeOperationException(String.format( "multiple parents patch sets %s exist for change edit", rev.abbreviate(8))); } PatchSet parentPatchSet = Iterables.getOnlyElement(r); if (!edit.getChange().getId().equals( parentPatchSet.getId().getParentKey())) { throw new InvalidChangeOperationException(String.format( "different change edit ID %d and its parent patch set %d", edit.getChange().getId().get(), parentPatchSet.getId().getParentKey().get())); } return parentPatchSet; } catch (OrmException e) { throw new IOException(e); } }</code><technical_language>Typo:</technical_language>

Target:
public PatchSet getBasePatchSet(ChangeEdit edit, RevCommit commit) throws IOException, InvalidChangeOperationException { if (commit.getParentCount() != 1) { throw new InvalidChangeOperationException( "change edit commit has multiple parents"); } RevCommit parentCommit = commit.getParent(0); ObjectId rev = parentCommit.getId(); RevId parentRev = new RevId(ObjectId.toString(rev)); try { List<PatchSet> r = db.get().patchSets().byRevision(parentRev).toList(); if (r.isEmpty()) { throw new InvalidChangeOperationException(String.format( "patch set %s change edit is based on doesn't exist", rev.abbreviate(8))); } if (r.size() > 1) { throw new InvalidChangeOperationException(String.format( "multiple patch sets for change edit parent %s", rev.abbreviate(8))); } PatchSet parentPatchSet = Iterables.getOnlyElement(r); if (!edit.getChange().getId().equals( parentPatchSet.getId().getParentKey())) { throw new InvalidChangeOperationException(String.format( "different change edit ID %d and its parent patch set %d", edit.getChange().getId().get(), parentPatchSet.getId().getParentKey().get())); } return parentPatchSet; } catch (OrmException e) { throw new IOException(e); } }
Source:
<code>public void migrateEntitlementQuantityFail() { ConsumerType ct = TestUtil.createConsumerType(); ct.setManifest(true); Entitlement e = TestUtil.createEntitlement(); Consumer sourceConsumer = new Consumer("source-consumer", "bill", owner, ct); Consumer destConsumer = new Consumer("destination-consumer", "bill", owner, ct); e.setConsumer(sourceConsumer); e.setQuantity(25); when(entitlementCurator.find(eq(e.getId()))).thenReturn(e); when(consumerCurator.verifyAndLookupConsumer(eq(sourceConsumer.getUuid()))) .thenReturn(sourceConsumer); when(consumerCurator.verifyAndLookupConsumer(eq(destConsumer.getUuid()))) .thenReturn(destConsumer); try { Response response = entResource.migrateEntitlement(e.getId(), destConsumer.getUuid(), 30); } catch (BadRequestException bre) { assertEquals(bre.getMessage(), i18n.tr("The quantity specified must be greater than zero " + <START> "and less than or equal to the total for this entitlement")); <END> throw bre; } }</code><technical_language>asserts right, a translation flag in a test string, copies of long verbose strings need in sync tests fail. find another here</technical_language>

Target:
public void migrateEntitlementQuantityFail() { ConsumerType ct = TestUtil.createConsumerType(); ct.setManifest(true); Entitlement e = TestUtil.createEntitlement(); Consumer sourceConsumer = new Consumer("source-consumer", "bill", owner, ct); Consumer destConsumer = new Consumer("destination-consumer", "bill", owner, ct); e.setConsumer(sourceConsumer); e.setQuantity(25); when(entitlementCurator.find(eq(e.getId()))).thenReturn(e); when(consumerCurator.verifyAndLookupConsumer(eq(destConsumer.getUuid()))) .thenReturn(destConsumer); try { entResource.migrateEntitlement(e.getId(), destConsumer.getUuid(), 30); fail("Should have thrown BadRequestException"); } catch (BadRequestException bre) { assertEquals(bre.headers().get(BadRequestException.ROOTCAUSE), CauseEnum.QUANTITY.toString()); } }