auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> public static PushToApplicationSettings getSettings(PushToApplication application) { <END> if (application instanceof PushToEmacs) { return new PushToEmacsSettings(application.getDialogService()); } else if (application instanceof PushToLyx) { return new PushToLyxSettings(application.getDialogService()); } else if (application instanceof PushToVim) { return new PushToVimSettings(application.getDialogService()); } else { return new PushToApplicationSettings(application.getDialogService()); } }</code><technical_language>If convert this instance method define in ExternalTab constructor init dialogService access dialogService method. manager = new PushToApplicationsManager(dialogService); need getDialogService method in AbstractPushToApplication.java</technical_language>

Target:
public PushToApplicationSettings getSettings(PushToApplication application) { if (application instanceof PushToEmacs) { return new PushToEmacsSettings(dialogService); } else if (application instanceof PushToLyx) { return new PushToLyxSettings(dialogService); } else if (application instanceof PushToVim) { return new PushToVimSettings(dialogService); } else { return new PushToApplicationSettings(dialogService); } }
Source:
<code>protected List<String>[] getTemplates(String[] titles, String template, int... ns) throws IOException { List<String>[] ret = new ArrayList[titles.length]; StringBuilder url = new StringBuilder(query); url.append("prop=templates&tllimit=max"); constructNamespaceString(url, "tl", ns); if (template != null) { url.append("&tltemplates="); url.append(encode(template, false)); } url.append("&titles="); <START> String[] titlestrings = constructTitleString(url.length() + "&tlcontinue=".length(), titles, true); <END> for (String temp : titlestrings) { String tempurl = url.toString() + temp; String tlcontinue = null; do { String line; if (tlcontinue == null) line = fetch(tempurl, "getTemplates"); else line = fetch(tempurl + "&tlcontinue=" + encode(tlcontinue, false), "getTemplates"); tlcontinue = parseAttribute(line, "tlcontinue", 0); String[] x = line.split("<page "); for (int i = 1; i < x.length; i++) { int index = -1; String parsedtitle = parseAttribute(x[i], "title", 0); for (int j = 0; j < titles.length; j++) if (normalize(titles[j]).equals(parsedtitle)) index = j; if (ret[index] == null) ret[index] = new ArrayList<>(750); for (int a = x[i].indexOf("<tl "); a > 0; a = x[i].indexOf("<tl ", ++a)) ret[index].add(parseAttribute(x[i], "title", a)); } } while (tlcontinue != null); } log(Level.INFO, "getTemplates", "Successfully retrieved templates used on " + titles.length + " pages."); return ret; }</code><technical_language>length of base URL needs a longer accommodate of tlcontinue</technical_language>

Target:
protected List<String>[] getTemplates(String[] titles, String template, int... ns) throws IOException { List<String>[] ret = new ArrayList[titles.length]; StringBuilder url = new StringBuilder(query); url.append("prop=templates&tllimit=max"); constructNamespaceString(url, "tl", ns); if (template != null) { url.append("&tltemplates="); url.append(encode(template, false)); } url.append("&titles="); String[] titlestrings = constructTitleString(url.length() + "&tlcontinue=".length() + 1000, titles, true); for (String temp : titlestrings) { String tempurl = url.toString() + temp; String tlcontinue = null; do { String line; if (tlcontinue == null) line = fetch(tempurl, "getTemplates"); else line = fetch(tempurl + "&tlcontinue=" + encode(tlcontinue, false), "getTemplates"); tlcontinue = parseAttribute(line, "tlcontinue", 0); String[] x = line.split("<page "); for (int i = 1; i < x.length; i++) { int index = -1; String parsedtitle = parseAttribute(x[i], "title", 0); for (int j = 0; j < titles.length; j++) if (normalize(titles[j]).equals(parsedtitle)) index = j; if (ret[index] == null) ret[index] = new ArrayList<>(750); for (int a = x[i].indexOf("<tl "); a > 0; a = x[i].indexOf("<tl ", ++a)) ret[index].add(parseAttribute(x[i], "title", a)); } } while (tlcontinue != null); } log(Level.INFO, "getTemplates", "Successfully retrieved templates used on " + titles.length + " pages."); return ret; }
Source:
<code>private static File getFileFromClassLoader4Luna(String filename, ClassLoader classLoader) throws AssertionFailedError { try { Object classpathManager = MethodUtils.invokeExactMethod(classLoader, "getClasspathManager", null); if (classpathManager != null) { Object generation = MethodUtils.invokeExactMethod(classpathManager, "getGeneration", null); if (generation != null) { Object bundleFile = MethodUtils.invokeExactMethod(generation, "getBundleFile", null); if (bundleFile != null) { File file = (File) MethodUtils.invokeExactMethod(bundleFile, "getFile", new Object[] { filename, true }, new Class[] { String.class, boolean.class }); if (file != null) { return file; } } } <START> } <END> } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } throw new AssertionFailedError("no file found " + filename); }</code><technical_language>throw exception if of checks fail. easiest Guava for that</technical_language>

Target:
private static File getFileFromClassLoader4Luna(String filename, ClassLoader classLoader) throws AssertionFailedError { String AssertionFailedErrorMessage = "no file found " + filename; try { Object classpathManager = MethodUtils.invokeExactMethod(classLoader, "getClasspathManager", null); if (classpathManager != null) { Object generation = MethodUtils.invokeExactMethod(classpathManager, "getGeneration", null); if (generation != null) { Object bundleFile = MethodUtils.invokeExactMethod(generation, "getBundleFile", null); if (bundleFile != null) { File file = (File) MethodUtils.invokeExactMethod(bundleFile, "getFile", new Object[] { filename, true }, new Class[] { String.class, boolean.class }); if (file != null) { return file; } } } } } catch (NoSuchMethodException e) { AssertionFailedErrorMessage = "got NoSuchMethodException " + e.getMessage(); } catch (IllegalAccessException e) { AssertionFailedErrorMessage = "got IllegalAccessException " + e.getMessage(); } catch (InvocationTargetException e) { AssertionFailedErrorMessage = "got InvocationTargetException " + e.getMessage(); } throw new AssertionFailedError(AssertionFailedErrorMessage); }
Source:
<code>public void should_throw_exception_when_frame_exceeds_configured_max() { org.apache.log4j.Logger connectionLogger = org.apache.log4j.Logger.getLogger(Connection.class); Level originalLevel = connectionLogger.getLevel(); connectionLogger.setLevel(Level.DEBUG); MemoryAppender logs = new MemoryAppender(); connectionLogger.addAppender(logs); try { session().execute(select().from(tableName).where(eq("k", 0))); fail("Exception expected"); } catch (NoHostAvailableException e) { assertThat(e.getErrors()).hasSize(2); } finally { assertThat(logs.get()).contains("io.netty.handler.codec.TooLongFrameException"); connectionLogger.setLevel(originalLevel); connectionLogger.removeAppender(logs); } <START> waitForUp(ipOfNode(1), cluster(), 10); <END> waitForUp(ipOfNode(2), cluster(), 10); ResultSet result = session().execute(select().from(tableName).where(eq("k", 0)).and(eq("c", 0))); assertThat(result.getAvailableWithoutFetching()).isEqualTo(1); }</code><technical_language>Yes, fail request (i.e. rethrow error client) stop retries. fix connection is working, I reason mark defunct</technical_language>

Target:
public void should_throw_exception_when_frame_exceeds_configured_max() { try { session().execute(select().from(tableName).where(eq("k", 0))); fail("Exception expected"); } catch (FrameTooLongException ftle) { } Collection<Host> hosts = session().getState().getConnectedHosts(); assertThat(hosts).hasSize(2).extractingResultOf("isUp").containsOnly(true); for (int i = 0; i < 10; i++) { ResultSet result = session().execute(select().from(tableName).where(eq("k", 0)).and(eq("c", 0))); assertThat(result.getAvailableWithoutFetching()).isEqualTo(1); } }
Source:
<code>public void init() throws IOException { final Properties producerConfig = new Properties(); final Dictionary<String, Object> properties = configAdmin .getConfiguration(OpennmsKafkaProducer.KAFKA_CLIENT_PID).getProperties(); if (properties != null) { final Enumeration<String> keys = properties.keys(); while (keys.hasMoreElements()) { final String key = keys.nextElement(); producerConfig.put(key, properties.get(key)); } } <START> producerConfig.put("key.serializer", StringSerializer.class.getCanonicalName()); <END> producerConfig.put("value.serializer", ByteArraySerializer.class.getCanonicalName()); final ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(null); producer = new KafkaProducer<>(producerConfig); } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); } LOG.info(" kafka producer initialized with ", producerConfig); }</code><technical_language>existing constants for "key.serializer" "value.serializer" here</technical_language>

Target:
public void init() throws IOException { final Properties producerConfig = new Properties(); final Dictionary<String, Object> properties = configAdmin .getConfiguration(OpennmsKafkaProducer.KAFKA_CLIENT_PID).getProperties(); if (properties != null) { final Enumeration<String> keys = properties.keys(); while (keys.hasMoreElements()) { final String key = keys.nextElement(); producerConfig.put(key, properties.get(key)); } } producerConfig.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getCanonicalName()); producerConfig.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getCanonicalName()); final ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(null); producer = new KafkaProducer<>(producerConfig); } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); } LOG.info(" kafka producer initialized with ", producerConfig); }
Source:
<code>public void testStoreNotStarted() throws Exception { CloudBlobStore idleStore = new CloudBlobStore(partitionId, null, dest); List<StoreKey> keys = Collections.singletonList(getUniqueId(refAccountId, refContainerId)); MockMessageWriteSet messageWriteSet = new MockMessageWriteSet(); addBlobToSet(messageWriteSet, 10, Utils.Infinite_Time, refAccountId, refContainerId); try { idleStore.put(messageWriteSet); fail("Store put should have failed."); <START> } catch (StoreException storex) { <END> assertEquals(StoreErrorCodes.Store_Not_Started, storex.getErrorCode()); } try { idleStore.delete(messageWriteSet); fail("Store delete should have failed."); } catch (StoreException storex) { assertEquals(StoreErrorCodes.Store_Not_Started, storex.getErrorCode()); } try { idleStore.findMissingKeys(keys); fail("Store findMissingKeys should have failed."); } catch (StoreException storex) { assertEquals(StoreErrorCodes.Store_Not_Started, storex.getErrorCode()); } }</code><technical_language>Name e? Exception var in code e commonly</technical_language>

Target:
public void testStoreNotStarted() throws Exception { CloudBlobStore idleStore = new CloudBlobStore(partitionId, null, dest); List<StoreKey> keys = Collections.singletonList(getUniqueId(refAccountId, refContainerId)); MockMessageWriteSet messageWriteSet = new MockMessageWriteSet(); addBlobToSet(messageWriteSet, 10, Utils.Infinite_Time, refAccountId, refContainerId); try { idleStore.put(messageWriteSet); fail("Store put should have failed."); } catch (StoreException e) { assertEquals(StoreErrorCodes.Store_Not_Started, e.getErrorCode()); } try { idleStore.delete(messageWriteSet); fail("Store delete should have failed."); } catch (StoreException e) { assertEquals(StoreErrorCodes.Store_Not_Started, e.getErrorCode()); } try { idleStore.findMissingKeys(keys); fail("Store findMissingKeys should have failed."); } catch (StoreException e) { assertEquals(StoreErrorCodes.Store_Not_Started, e.getErrorCode()); } }
Source:
<code>public void testFileForDiffDirectoryMismatch() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); final String[] expected = { "1: " + getCheckMessage(MSG_KEY_MISMATCH), }; <START> verify(checkConfig, <END> getNonCompilablePath("InputPackageDeclarationDiffDirectory.java"), expected); }</code><technical_language>please it. files violations too</technical_language>

Target:
public void testFileForDiffDirectoryMismatch() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); final String[] expected = { "1:1: " + getCheckMessage(MSG_KEY_MISMATCH), }; verify(checkConfig, getNonCompilablePath("InputPackageDeclarationDiffDirectory.java"), expected); }
Source:
<code>public void addUnmatchedTask() { AbstractTask task = spy(new TaskTask("kind", "repoUrl", "id")); lazyList.addTask(task); verify(taskList, never()).addTask(task); verify(taskList, never()).addTask(task, <START> null); <END> lazyList.commit(); verify(taskList, times(1)).addTask(task); lazyList.commit(); verify(taskList, times(1)).addTask(task); }</code><technical_language>container object, including null, null other invocation of this method arguments (a non-null container) skip verification</technical_language>

Target:
public void addUnmatchedTask() { AbstractTask task = spy(new TaskTask("kind", "repoUrl", "id")); lazyList.addTask(task); verify(taskList, never()).addTask(task); verify(taskList, never()).addTask(eq(task), any()); lazyList.commit(); verify(taskList).addTask(task); lazyList.commit(); verifyNoMoreInteractions(taskList); }
Source:
<code>public synchronized V getValue() { if (value == null || isExpired()) { <START> refreshValue(); <END> } return value; }</code><technical_language>return refreshValue();</technical_language>

Target:
public synchronized V getValue() { if (value == null || isExpired()) { return refreshValue(); } return value; }
Source:
<code>private void ensureAllSet(EventTester tester) { String[] unfiredIds = tester.getAttIds(false); if (unfiredIds.length > 0) { <START> StringBuilder msg = new StringBuilder("No event fired:" + unfiredIds); <END> for (int i = 0; i < unfiredIds.length; i++) { msg.append(' ' + unfiredIds[i]); } fail(msg.toString()); } }</code><technical_language>append instead of +</technical_language>

Target:
private void ensureAllSet(EventTester tester) { String[] unfiredIds = tester.getAttIds(false); if (unfiredIds.length > 0) { StringBuilder msg = new StringBuilder("No event fired:").append(unfiredIds); for (int i = 0; i < unfiredIds.length; i++) { msg.append(' ').append(unfiredIds[i]); } fail(msg.toString()); } }
Source:
<code>public static ExecutorApiClient getInstance() { <START> if (null == instance) { <END> synchronized (ExecutorApiClient.class) { if (null == instance) { instance = new ExecutorApiClient(); } } } return instance; }</code><technical_language>constructor do much, another initialize instance of this class w/o synchronization is: private static ExecutorApiClient instance = new ExecutorApiClient();</technical_language>

Target:
public static ExecutorApiClient getInstance() { return instance; }
Source:
<code>public abstract void append(String tag, long timestamp, Map<String, Object> data) throws IOException; public abstract void append(String tag, EventTime timestamp, Map<String, Object> data) throws IOException; public abstract void appendMessagePackMapValue(String tag, long timestamp, byte[] mapValue, int offset, int len) throws IOException; public abstract void appendMessagePackMapValue(String tag, EventTime timestamp, byte[] mapValue, int offset, int len) throws IOException; public abstract void appendMessagePackMapValue(String tag, long timestamp, ByteBuffer mapValue) throws IOException; public abstract void appendMessagePackMapValue(String tag, EventTime timestamp, ByteBuffer mapValue) throws IOException; protected abstract void loadBufferFromFile(List<String> params, FileChannel channel); protected abstract void saveAllBuffersToFile() throws IOException; protected void saveBuffer(List<String> params, ByteBuffer buffer) { if (fileBackup == null) { return; } <START> LOG.debug("Saving buffer: params={}, buffer={}", params, buffer); <END> fileBackup.saveBuffer(params, buffer); }</code><technical_language>This log message is a bit important appears file backup mode is enables, I want leave info</technical_language>

Target:
public abstract void append(String tag, long timestamp, Map<String, Object> data) throws IOException; public abstract void append(String tag, EventTime timestamp, Map<String, Object> data) throws IOException; public abstract void appendMessagePackMapValue(String tag, long timestamp, byte[] mapValue, int offset, int len) throws IOException; public abstract void appendMessagePackMapValue(String tag, EventTime timestamp, byte[] mapValue, int offset, int len) throws IOException; public abstract void appendMessagePackMapValue(String tag, long timestamp, ByteBuffer mapValue) throws IOException; public abstract void appendMessagePackMapValue(String tag, EventTime timestamp, ByteBuffer mapValue) throws IOException; protected abstract void loadBufferFromFile(List<String> params, FileChannel channel); protected abstract void saveAllBuffersToFile() throws IOException; protected void saveBuffer(List<String> params, ByteBuffer buffer) { if (fileBackup == null) { return; } LOG.info("Saving buffer: params={}, buffer={}", params, buffer); fileBackup.saveBuffer(params, buffer); }
Source:
<code>private ValueProcessor getValueProcessor(DatasourceLayer layer) { if(layer.getConfig() == null) { return DEFAULT_PROCESSOR; } String className = layer.getConfig("valueProcessor"); if(className == null) { return DEFAULT_PROCESSOR; } ValueProcessor processor = processors.get(className); if(processor != null) { return processor; } try { final Class clazz = Class.forName(className); <START> processor = (ValueProcessor) clazz.newInstance(); <END> processors.put(className, processor); return processor; } catch (Exception e) { LOG.error(e, "Error creating ValueProcessor for plugin id:", config.getId(), " - class:", className); } return DEFAULT_PROCESSOR; }</code><technical_language>add a ValueProcessor.class.isAssignableFrom(clazz); check here. Class.forName(String) needs try-catch of a difference I guess</technical_language>

Target:
private ValueProcessor getValueProcessor(DatasourceLayer layer) { String className = layer.getConfig("valueProcessor"); if(className == null) { return DEFAULT_PROCESSOR; } ValueProcessor processor = processors.get(className); if(processor != null) { return processor; } try { final Class clazz = Class.forName(className); if(!ValueProcessor.class.isAssignableFrom(clazz)) { LOG.warn("Invalid ValueProcessor configured for datasource id:", config.getId(), " - class:", className); return DEFAULT_PROCESSOR; } processor = (ValueProcessor) clazz.newInstance(); processors.put(className, processor); return processor; } catch (Exception e) { LOG.error(e, "Error creating ValueProcessor for plugin id:", config.getId(), " - class:", className); } return DEFAULT_PROCESSOR; }
Source:
<code>public void testSaveByPressingEnter() { presenter.onKeyPress(12, false, MODIFIED_NAME); verifyNameNotSaved(); <START> presenter.onKeyPress(13, <END> false, MODIFIED_NAME); verifyNameSaved(); }</code><technical_language>KEY_ENTER</technical_language>

Target:
public void testSaveByPressingEnter() { presenter.onKeyPress(12, false, MODIFIED_NAME); verifyNameNotSaved(); presenter.onKeyPress(KeyCodes.KEY_ENTER, false, MODIFIED_NAME); verifyNameSaved(); }
Source:
<code>public String process(String markupContent) { Map<String, String> attributes = new HashMap<String, String>(); StringBuilder processedMarkup = new StringBuilder(markupContent.length()); LocationTrackingReader reader = new LocationTrackingReader(new StringReader(markupContent)); String line; try { line = reader.readLine(); while (line != null) { Matcher matcher = ATTRIBUTE_PATTERN.matcher(line); if (matcher.matches()) { String key = matcher.group(1); String value = matcher.group(2); if (value != null) { value = value.trim(); } attributes.put(key, value); } else { <START> Matcher attrref = ATTRIBUTE_TOKEN_PATTERN.matcher(line); <END> int offset = 0; while (attrref.find()) { String postfix = line.substring(offset, attrref.start()); if (postfix.endsWith("\\")) { processedMarkup.append(postfix.substring(0, postfix.length() - 1)); offset = attrref.start(); } else { processedMarkup.append(postfix); String key = attrref.group(1); String value = attributes.get(key); if (value == null) { value = attrref.group(0); } processedMarkup.append(value); offset = attrref.end(); } } if (offset < line.length()) { processedMarkup.append(line.substring(offset)); } processedMarkup.append("\n"); } line = reader.readLine(); } reader.close(); } catch (IOException e) { throw new IllegalStateException(e); } return processedMarkup.toString(); }</code><technical_language>camel-case? attributeReference</technical_language>

Target:
public String process(String markupContent) { Map<String, String> attributes = new HashMap<String, String>(); StringBuilder processedMarkup = new StringBuilder(markupContent.length()); LocationTrackingReader reader = new LocationTrackingReader(new StringReader(markupContent)); String line; try { line = reader.readLine(); while (line != null) { Matcher matcher = ATTRIBUTE_PATTERN.matcher(line); if (matcher.matches()) { String key = matcher.group(1); String value = matcher.group(2); if (value != null) { value = value.trim(); } attributes.put(key, value); } else { Matcher attributesRef = ATTRIBUTE_TOKEN_PATTERN.matcher(line); int offset = 0; while (attributesRef.find()) { String postfix = line.substring(offset, attributesRef.start()); if (postfix.endsWith("\\")) { processedMarkup.append(postfix.substring(0, postfix.length() - 1)); offset = attributesRef.start(); } else { processedMarkup.append(postfix); String key = attributesRef.group(1); String value = attributes.get(key); if (value == null) { value = attributesRef.group(0); } processedMarkup.append(value); offset = attributesRef.end(); } } if (offset < line.length()) { processedMarkup.append(line.substring(offset)); } processedMarkup.append("\n"); } line = reader.readLine(); } reader.close(); } catch (IOException e) { throw new IllegalStateException(e); } return processedMarkup.toString(); }
Source:
<code>public Builder addFile(String fileUrl) { <START> String id = downloadBatchId.rawId() + fileUrl; <END> DownloadFileId downloadFileId = DownloadFileIdCreator.createFrom(id); fileUrls.put(downloadFileId, fileUrl); return this; }</code><technical_language>change this variable name rawId? creating id a variable called id right now. clearer create id a rawId imo</technical_language>

Target:
public Builder addFile(String fileUrl) { String rawId = downloadBatchId.rawId() + fileUrl; DownloadFileId downloadFileId = DownloadFileIdCreator.createFrom(rawId); fileUrls.put(downloadFileId, fileUrl); return this; }
Source:
<code>public void findChildrenLeaf() { final CategoryTree tree = createAbcCategoryTree(); final Category category = tree.findById("B-1-1").get(); final List<Category> children = tree.findChildren(category); <START> assertThat(children).as("leaf notes produce empty lists").isEmpty(); <END> }</code><technical_language>*nodes</technical_language>

Target:
public void findChildrenLeaf() { final CategoryTree tree = createAbcCategoryTree(); final Category category = tree.findById("B-1-1").get(); final List<Category> children = tree.findChildren(category); assertThat(children).as("leaf nodes produce empty lists").isEmpty(); }
Source:
<code>public void doHashtagsChangedHook(Change change, Account account, Set<String> added, Set<String> removed, Set<String> hashtags, ReviewDb db) throws OrmException { HashtagsChangedEvent event = new HashtagsChangedEvent(); AccountState owner = accountCache.get(change.getOwner()); event.change = eventFactory.asChangeAttribute(change); event.editor = eventFactory.asAccountAttribute(account); <START> if (hashtags.size() > 0) { event.hashtags = new String[hashtags.size()]; int i = 0; for (String hashtag : hashtags) { event.hashtags[i++] = hashtag; } } <END> if (added != null && added.size() > 0) { event.added = new String[added.size()]; int i = 0; for (String hashtag : added) { event.added[i++] = hashtag; } } if (removed != null && removed.size() > 0) { event.removed = new String[removed.size()]; int i = 0; for (String hashtag : removed) { event.removed[i++] = hashtag; } } fireEvent(change, event, db); final List<String> args = new ArrayList<>(); addArg(args, "--change", event.change.id); addArg(args, "--change-owner", getDisplayName(owner.getAccount())); addArg(args, "--project", event.change.project); addArg(args, "--branch", event.change.branch); addArg(args, "--editor", getDisplayName(account)); if (hashtags != null) { for (String hashtag : hashtags) { addArg(args, "--hashtag", hashtag); } } if (added != null) { for (String hashtag : added) { addArg(args, "--added", hashtag); } } if (removed != null) { for (String hashtag : removed) { addArg(args, "--removed", hashtag); } } runHook(change.getProject(), hashtagsChangedHook, args); }</code><technical_language>Guava's Sets.newHashSet(array);</technical_language>

Target:
public void doHashtagsChangedHook(Change change, Account account, Set<String> added, Set<String> removed, Set<String> hashtags, ReviewDb db) throws OrmException { HashtagsChangedEvent event = new HashtagsChangedEvent(); AccountState owner = accountCache.get(change.getOwner()); event.change = eventFactory.asChangeAttribute(change); event.editor = eventFactory.asAccountAttribute(account); event.hashtags = hashtagArray(hashtags); event.added = hashtagArray(added); event.removed = hashtagArray(removed); fireEvent(change, event, db); final List<String> args = new ArrayList<>(); addArg(args, "--change", event.change.id); addArg(args, "--change-owner", getDisplayName(owner.getAccount())); addArg(args, "--project", event.change.project); addArg(args, "--branch", event.change.branch); addArg(args, "--editor", getDisplayName(account)); if (hashtags != null) { for (String hashtag : hashtags) { addArg(args, "--hashtag", hashtag); } } if (added != null) { for (String hashtag : added) { addArg(args, "--added", hashtag); } } if (removed != null) { for (String hashtag : removed) { addArg(args, "--removed", hashtag); } } runHook(change.getProject(), hashtagsChangedHook, args); }
Source:
<code>private String getStringFromResultSet(ResultSet rs) throws SQLException, UnsupportedEncodingException { ResultSetMetaData meta = rs.getMetaData(); StringBuilder sb = new StringBuilder(); int numColumns = meta.getColumnCount(); for (int i = 1; i <= numColumns; i++) { sb.append(meta.getColumnLabel(i)); if (i==numColumns){ sb.append('\n'); } else { sb.append('\t'); } } JMeterVariables jmvars = getThreadContext().getVariables(); String[] varNames = getVariableNames().split(COMMA); String currentResultVariable = getResultVariable().trim(); List<Map<String, Object> > results = null; if(!currentResultVariable.isEmpty()) { results = new ArrayList<>(); jmvars.putObject(currentResultVariable, results); } <START> int j = 0; <END> int k = getIntegerResultSetMaxRows(); if (k < 0) { while (rs.next()) { j = processRow(rs, meta, sb, numColumns, jmvars, varNames, results, j); } } else { while (j < k && rs.next()) { j = processRow(rs, meta, sb, numColumns, jmvars, varNames, results, j); } } for (String varName : varNames) { String name = varName.trim(); if (name.length() > 0 && jmvars != null) { final String varCount = name + "_#"; String prevCount = jmvars.get(varCount); if (prevCount != null) { int prev = Integer.parseInt(prevCount); for (int n = j + 1; n <= prev; n++) { jmvars.remove(name + UNDERSCORE + n); } } jmvars.put(varCount, Integer.toString(j)); } } return sb.toString(); }</code><technical_language>more meaningful names j, k</technical_language>

Target:
private String getStringFromResultSet(ResultSet rs) throws SQLException, UnsupportedEncodingException { ResultSetMetaData meta = rs.getMetaData(); StringBuilder sb = new StringBuilder(); int numColumns = meta.getColumnCount(); for (int i = 1; i <= numColumns; i++) { sb.append(meta.getColumnLabel(i)); if (i==numColumns){ sb.append('\n'); } else { sb.append('\t'); } } JMeterVariables jmvars = getThreadContext().getVariables(); String[] varNames = getVariableNames().split(COMMA); String currentResultVariable = getResultVariable().trim(); List<Map<String, Object> > results = null; if(!currentResultVariable.isEmpty()) { results = new ArrayList<>(); jmvars.putObject(currentResultVariable, results); } int currentIterationIndex = 0; int resultSetMaxRows = getIntegerResultSetMaxRows(); if (resultSetMaxRows < 0) { while (rs.next()) { currentIterationIndex = processRow(rs, meta, sb, numColumns, jmvars, varNames, results, currentIterationIndex); } } else { while (currentIterationIndex < resultSetMaxRows && rs.next()) { currentIterationIndex = processRow(rs, meta, sb, numColumns, jmvars, varNames, results, currentIterationIndex); } } for (String varName : varNames) { String name = varName.trim(); if (name.length() > 0 && jmvars != null) { final String varCount = name + "_#"; String prevCount = jmvars.get(varCount); if (prevCount != null) { int prev = Integer.parseInt(prevCount); for (int n = currentIterationIndex + 1; n <= prev; n++) { jmvars.remove(name + UNDERSCORE + n); } } jmvars.put(varCount, Integer.toString(currentIterationIndex)); } } return sb.toString(); }
Source:
<code>public static Trades adaptTrades(CoinbaseProTrade[] coinbaseExTrades, CurrencyPair currencyPair) { List<Trade> trades = new ArrayList<>(coinbaseExTrades.length); for (int i = 0; i < coinbaseExTrades.length; i++) { CoinbaseProTrade trade = coinbaseExTrades[i]; OrderType type = trade.getSide().equals("sell") ? OrderType.BID : OrderType.ASK; Trade t = new Trade( type, trade.getSize(), currencyPair, trade.getPrice(), parseDate(trade.getTimestamp()), String.valueOf(trade.getTradeId())); <START> t.setMaker_order_id(trade.getMakerOrderId()); <END> t.setTaker_order_id(trade.getTakerOrderId()); trades.add(t); } return new Trades(trades, coinbaseExTrades[0].getTradeId(), TradeSortType.SortByID); }</code><technical_language>this camelCase too: setMaker_order_id</technical_language>

Target:
public static Trades adaptTrades(CoinbaseProTrade[] coinbaseExTrades, CurrencyPair currencyPair) { List<Trade> trades = new ArrayList<>(coinbaseExTrades.length); for (int i = 0; i < coinbaseExTrades.length; i++) { CoinbaseProTrade trade = coinbaseExTrades[i]; OrderType type = trade.getSide().equals("sell") ? OrderType.BID : OrderType.ASK; Trade t = new Trade( type, trade.getSize(), currencyPair, trade.getPrice(), parseDate(trade.getTimestamp()), String.valueOf(trade.getTradeId())); t.setMakerOrderId(trade.getMakerOrderId()); t.setTakerOrderId(trade.getTakerOrderId()); trades.add(t); } return new Trades(trades, coinbaseExTrades[0].getTradeId(), TradeSortType.SortByID); }
Source:
<code>public void setEndDate(Date endDate) { <START> this.endDate = endDate; <END> }</code><technical_language>Date instances mutable, this.endDate a copy of endDate avoid side-effects</technical_language>

Target:
public void setEndDate(Date endDate) { this.endDate = endDate == null ? null : new Date(endDate.getTime()); }
Source:
<code>protected boolean canHandleMetacard(Metacard metacard) { <START> return !StringUtils.isEmpty(metacard.getLocation()); <END> }</code><technical_language>remove negation check for blanks return StringUtils.isNotBlank(metacard.getLocation());</technical_language>

Target:
protected boolean canHandleMetacard(Metacard metacard) { return StringUtils.isNotBlank(metacard.getLocation()); }
Source:
<code>public void validate(PlanNode plan, Session session, Metadata metadata, SqlParser sqlParser, Map<Symbol, Type> types) { plan.accept(new SimplePlanVisitor<Set<Filter>>() { @Override public Void visitJoin(JoinNode node, Set<Filter> expected) { ImmutableSet<Filter> currentJoinDynamicFilters = node.getDynamicFilterAssignments() .entrySet() .stream() .map(assignment -> new Filter(node.getId().toString(), assignment.getKey().getName())) .collect(toImmutableSet()); expected.addAll(currentJoinDynamicFilters); node.getLeft().accept(this, expected); checkState(intersection(currentJoinDynamicFilters, expected).isEmpty()); node.getRight().accept(this, expected); return null; } @Override public Void visitExchange(ExchangeNode node, Set<Filter> expected) { Set<Filter> filtersLeft = null; for (PlanNode source : node.getSources()) { Set<Filter> copy = new HashSet<>(expected); source.accept(this, copy); if (filtersLeft == null) { filtersLeft = copy; } else { <START> checkState(filtersLeft.equals(copy), "filters does not match: %s != %s", filtersLeft, copy); <END> } } if (filtersLeft != null) { expected.clear(); expected.addAll(filtersLeft); } return null; } @Override public Void visitFilter(FilterNode node, Set<Filter> expected) { extractDynamicFilters(node.getPredicate()) .getDynamicFilters() .stream() .map(dynamicFilter -> new Filter(dynamicFilter.getTupleDomainSourceId(), dynamicFilter.getTupleDomainName())) .forEach(expected::remove); return node.getSource().accept(this, expected); } }, new HashSet<>()); }</code><technical_language>filters do match</technical_language>

Target:
public void validate(PlanNode plan, Session session, Metadata metadata, SqlParser sqlParser, Map<Symbol, Type> types) { plan.accept(new SimplePlanVisitor<Set<Filter>>() { @Override public Void visitJoin(JoinNode node, Set<Filter> expected) { ImmutableSet<Filter> currentJoinDynamicFilters = node.getDynamicFilterAssignments() .entrySet() .stream() .map(assignment -> new Filter(node.getId().toString(), assignment.getKey().getName())) .collect(toImmutableSet()); expected.addAll(currentJoinDynamicFilters); node.getLeft().accept(this, expected); checkState(intersection(currentJoinDynamicFilters, expected).isEmpty()); node.getRight().accept(this, expected); return null; } @Override public Void visitExchange(ExchangeNode node, Set<Filter> expected) { Set<Filter> filtersLeft = null; for (PlanNode source : node.getSources()) { Set<Filter> copy = new HashSet<>(expected); source.accept(this, copy); if (filtersLeft == null) { filtersLeft = copy; } else { checkState(filtersLeft.equals(copy), "filters do not match: %s != %s", filtersLeft, copy); } } if (filtersLeft != null) { expected.clear(); expected.addAll(filtersLeft); } return null; } @Override public Void visitFilter(FilterNode node, Set<Filter> expected) { extractDynamicFilters(node.getPredicate()) .getDynamicFilters() .stream() .map(dynamicFilter -> new Filter(dynamicFilter.getTupleDomainSourceId(), dynamicFilter.getTupleDomainName())) .forEach(expected::remove); return node.getSource().accept(this, expected); } }, new HashSet<>()); }
Source:
<code>public void setHitsPerPage(int hitsPerPage) throws IllegalArgumentException { if (hitsPerPage < 0) { throw new IllegalArgumentException( <START> String.format("Invalid value for histPerPage \"%d\"", hitsPerPage)); <END> } this.hitsPerPage = hitsPerPage; }</code><technical_language>this of cases check for negative number de-duped. Share error string, consider new special exception type, etc</technical_language>

Target:
public void setHitsPerPage(int hitsPerPage) throws IllegalArgumentException { if (hitsPerPage < 0) { throw new IllegalArgumentException( String.format(NEGATIVE_NUMBER_ERROR, "hitsPerPage", hitsPerPage)); } this.hitsPerPage = hitsPerPage; }
Source:
<code>public BigtableBufferedMutator( Configuration configuration, TableName tableName, int maxInflightRpcs, long maxHeapSize, BigtableClient client, BigtableOptions options, ExecutorService executorService, BufferedMutator.ExceptionListener listener) { this.sizeManager = new HeapSizeManager(maxHeapSize, maxInflightRpcs); this.configuration = configuration; this.tableName = tableName; this.exceptionListener = listener; InetAddress host = options.getDataHost(); <START> this.host = host == null ? null : host.toString(); <END> DeleteAdapter deleteAdapter = new DeleteAdapter(); PutAdapter putAdapter = new PutAdapter(configuration); ScanAdapter scanAdapter = new ScanAdapter(FilterAdapter.buildAdapter()); GetAdapter getAdapter = new GetAdapter(scanAdapter); RowMutationsAdapter rowMutationsAdapter = new RowMutationsAdapter( new MutationAdapter( deleteAdapter, putAdapter, new UnsupportedOperationAdapter<Increment>("increment"), new UnsupportedOperationAdapter<Append>("append"))); ListeningExecutorService listeningExecutorService = MoreExecutors.listeningDecorator(executorService); batchExecutor = new BatchExecutor( client, options, TableMetadataSetter.from(tableName, options), listeningExecutorService, getAdapter, putAdapter, deleteAdapter, rowMutationsAdapter, new AppendAdapter(), new IncrementAdapter(), new RowAdapter()); }</code><technical_language>host null? this simplified</technical_language>

Target:
public BigtableBufferedMutator( Configuration configuration, TableName tableName, int maxInflightRpcs, long maxHeapSize, BigtableClient client, BigtableOptions options, ExecutorService executorService, BufferedMutator.ExceptionListener listener) { this.sizeManager = new HeapSizeManager(maxHeapSize, maxInflightRpcs); this.configuration = configuration; this.tableName = tableName; this.exceptionListener = listener; this.host = options.getDataHost().toString(); DeleteAdapter deleteAdapter = new DeleteAdapter(); PutAdapter putAdapter = new PutAdapter(configuration); ScanAdapter scanAdapter = new ScanAdapter(FilterAdapter.buildAdapter()); GetAdapter getAdapter = new GetAdapter(scanAdapter); RowMutationsAdapter rowMutationsAdapter = new RowMutationsAdapter( new MutationAdapter( deleteAdapter, putAdapter, new UnsupportedOperationAdapter<Increment>("increment"), new UnsupportedOperationAdapter<Append>("append"))); ListeningExecutorService listeningExecutorService = MoreExecutors.listeningDecorator(executorService); batchExecutor = new BatchExecutor( client, options, TableMetadataSetter.from(tableName, options), listeningExecutorService, getAdapter, putAdapter, deleteAdapter, rowMutationsAdapter, new AppendAdapter(), new IncrementAdapter(), new RowAdapter()); }
Source:
<code>private Flux<Shard> getShards(JsonNode node) { JsonNode status = node.get(STATUS); <START> if (!status.asText().equals(FINALIZED)) { <END> return Flux.empty(); } List<Shard> shards = new ArrayList<>(); boolean validShard = false; for (JsonNode shard : node.withArray(CHUNK_FILE_PATHS)) { String shardPath = shard.asText().substring(BlobChangefeedAsyncClient.CHANGEFEED_CONTAINER_NAME.length() + 1); if (userCursor == null) { validShard = true; } else { if (shardPath.equals(userCursor.getShardPath())) { validShard = true; } } if (validShard) { shards.add(shardFactory.getShard(shardPath, cfCursor.toShardCursor(shardPath), userCursor)); } } return Flux.fromIterable(shards); }</code><technical_language>invert this check FINALIZED.equals(status.asText()). safer NPE</technical_language>

Target:
private Flux<Shard> getShards(JsonNode node) { JsonNode status = node.get(STATUS); if (!FINALIZED.equals(status.asText())) { return Flux.empty(); } List<Shard> shards = new ArrayList<>(); boolean validShard = false; for (JsonNode shard : node.withArray(CHUNK_FILE_PATHS)) { String shardPath = shard.asText().substring(BlobChangefeedClientBuilder.CHANGEFEED_CONTAINER_NAME.length() + 1); if (userCursor == null) { validShard = true; } else { if (shardPath.equals(userCursor.getShardPath())) { validShard = true; } } if (validShard) { shards.add(shardFactory.getShard(shardPath, cfCursor.toShardCursor(shardPath), userCursor)); } } return Flux.fromIterable(shards); }
Source:
<code>public void setUp() throws Exception { super.setUp(); <START> LOG.info("setUp"); <END> zkUtil.createBKEnsemble("/" + runtime.getMethodName()); rm = new ZKRegistrationManager(); }</code><technical_language>remove this</technical_language>

Target:
public void setUp() throws Exception { super.setUp(); zkUtil.createBKEnsemble("/" + runtime.getMethodName()); rm = new ZKRegistrationManager(); }
Source:
<code>protected JsonParser createParser(Object obj) throws IOException { Data data = (Data) obj; <START> return factory.createParser(data.toByteArray(), HEAP_DATA_OVERHEAD + 4, data.dataSize() - 4); <END> }</code><technical_language>this 4 bytes? refer a static field for more explanatory updated if changes</technical_language>

Target:
protected JsonParser createParser(Object obj) throws IOException { Data data = (Data) obj; return factory.createParser(data.toByteArray(), HEAP_DATA_OVERHEAD + UTF_CHARACTER_COUNT_FIELD_SIZE, data.dataSize() - UTF_CHARACTER_COUNT_FIELD_SIZE); }
Source:
<code>private Optional<Map<String, Object>> createAmendment(Site site, Map<String, ?> relatedArticle) { String relationshipType = (String) relatedArticle.get("type"); AmendmentType amendmentType = AmendmentType.BY_RELATIONSHIP_TYPE.get(relationshipType); <START> if (amendmentType == null) return Optional.empty(); END> String doi = (String) relatedArticle.get("doi"); ArticlePointer amendmentId; Map<String, Object> amendment; Map<String, ?> authors; try { amendmentId = factory.articleResolutionService.toIngestion(RequestedDoiVersion.of(doi)); amendment = (Map<String, Object>) factory.articleApi.requestObject(amendmentId.asApiAddress().build(), Map.class); authors = factory.articleApi.requestObject(amendmentId.asApiAddress().addToken("authors").build(), Map.class); } catch (IOException e) { throw new RuntimeException(e); } amendment.putAll(authors); if (amendmentType != AmendmentType.CORRECTION) { RenderContext renderContext = new RenderContext(site, RequestedDoiVersion.ofIngestion(amendmentId.getDoi(), amendmentId.getIngestionNumber())); String body; try { body = getAmendmentBody(renderContext); } catch (IOException e) { throw new RuntimeException("Could not get body for amendment: " + doi, e); } amendment.put("body", body); } amendment.put("type", amendmentType.getLabel()); return Optional.of(amendment); }</code><technical_language>I extending existing method here, Optional a naked NULL, I weird do this instead of erroring out article amendment is fed inappropriately argument. a private method called isAnAmmendment() for example, a filter instead</technical_language>

Target:
private Map<String, Object> createAmendment(Site site, Map<String, ?> relatedArticle) { AmendmentType amendmentType = getAmendmentType(relatedArticle).orElseThrow(IllegalArgumentException::new); String doi = (String) relatedArticle.get("doi"); ArticlePointer amendmentId; Map<String, Object> amendment; Map<String, ?> authors; try { amendmentId = factory.articleResolutionService.toIngestion(RequestedDoiVersion.of(doi)); amendment = (Map<String, Object>) factory.articleApi.requestObject(amendmentId.asApiAddress().build(), Map.class); authors = factory.articleApi.requestObject(amendmentId.asApiAddress().addToken("authors").build(), Map.class); } catch (IOException e) { throw new RuntimeException(e); } amendment.putAll(authors); if (amendmentType != AmendmentType.CORRECTION) { RenderContext renderContext = new RenderContext(site, RequestedDoiVersion.ofIngestion(amendmentId.getDoi(), amendmentId.getIngestionNumber())); String body; try { body = getAmendmentBody(renderContext); } catch (IOException e) { throw new RuntimeException("Could not get body for amendment: " + doi, e); } amendment.put("body", body); } amendment.put("type", amendmentType.getLabel()); return amendment; }
Source:
<code>private Resource makeDepositRecord(Resource deposit, Map<String, String> status) { Model aipModel = ModelFactory.createDefaultModel(); Resource aipObjResc = aipModel.createResource(deposit.getURI()); String filename = status.get(DepositField.fileName.name()); String title = "Deposit record" + (filename == null ? "" : " for " + filename); aipObjResc.addProperty(DcElements.title, title); aipObjResc.addProperty(Rdfs.type, Cdr.DepositRecord); String method = status.get(DepositField.depositMethod.name()); if (method != null) { aipObjResc.addProperty(Cdr.depositMethod, method); } String onBehalfOf = status.get(DepositField.depositorName.name()); if (onBehalfOf != null) { aipObjResc.addProperty(Cdr.depositedOnBehalfOf, onBehalfOf); } <START> String staffOnly = status.get(DepositField.staffOnly.name()); <END> if (staffOnly != null) { aipObjResc.addProperty(Cdr.staffOnly, staffOnly); } String depositPackageType = status.get(DepositField.packagingType.name()); if (depositPackageType != null) { aipObjResc.addProperty(Cdr.depositPackageType, depositPackageType); } String depositPackageProfile = status.get(DepositField.packageProfile.name()); if (depositPackageProfile != null) { aipObjResc.addProperty(Cdr.depositPackageProfile, depositPackageProfile); } return aipObjResc; }</code><technical_language>Remove this, leftover</technical_language>

Target:
private Resource makeDepositRecord(Resource deposit, Map<String, String> status) { Model aipModel = ModelFactory.createDefaultModel(); Resource aipObjResc = aipModel.createResource(deposit.getURI()); String filename = status.get(DepositField.fileName.name()); String title = "Deposit record" + (filename == null ? "" : " for " + filename); aipObjResc.addProperty(DcElements.title, title); aipObjResc.addProperty(Rdfs.type, Cdr.DepositRecord); String method = status.get(DepositField.depositMethod.name()); if (method != null) { aipObjResc.addProperty(Cdr.depositMethod, method); } String onBehalfOf = status.get(DepositField.depositorName.name()); if (onBehalfOf != null) { aipObjResc.addProperty(Cdr.depositedOnBehalfOf, onBehalfOf); } String depositPackageType = status.get(DepositField.packagingType.name()); if (depositPackageType != null) { aipObjResc.addProperty(Cdr.depositPackageType, depositPackageType); } String depositPackageProfile = status.get(DepositField.packageProfile.name()); if (depositPackageProfile != null) { aipObjResc.addProperty(Cdr.depositPackageProfile, depositPackageProfile); } return aipObjResc; }
Source:
<code>private void validateInclude() throws MojoFailureException { ArrayList<String> includeValues; List<String> includeStrings; if (include != null && !include.isEmpty()) { include = include.trim(); includeStrings = Arrays.asList(include.split(",")); includeValues = new ArrayList<String>(includeStrings); for (int i = 0; i < includeValues.size(); i++) { String value = includeValues.get(i); includeValues.set(i, value.trim()); } } else { includeValues = new ArrayList<String>(); } if (packageType.equals("jar")) { if (includeValues.contains("usr") || includeValues.contains("wlp")) { throw new MojoFailureException("Package type jar cannot be used with `usr` or `wlp`."); } if (!includeValues.contains("runnable")) { includeValues.add("runnable"); } } <START> include = String.join(",", includeValues); <END> }</code><technical_language>I this changes include empty String potentially, previously include null. code is affected include null I think. private String getPackageFileType() throws MojoFailureException { if (packageType != null && packageType.equals("jar")) { if (include == null || include.equals("all") || include.equals("minify")) { return ".jar"; } else { throw new MojoFailureException("The jar packageType requires minify in include parameter"); } } else { if (packageType != null && !packageType.equals("zip")) { log.info(packageType + " supported. Defaulting 'zip'"); } packageType = "zip"; return ".zip"; } }</technical_language>

Target:
private void validateInclude() throws MojoFailureException { ArrayList<String> includeValues; List<String> includeStrings; if (include != null && !include.isEmpty()) { include = include.trim(); includeStrings = Arrays.asList(include.split(",")); includeValues = new ArrayList<String>(includeStrings); for (int i = 0; i < includeValues.size(); i++) { String value = includeValues.get(i); includeValues.set(i, value.trim()); } } else { includeValues = new ArrayList<String>(); } if (packageType.equals("jar")) { if (includeValues.contains("usr") || includeValues.contains("wlp")) { throw new MojoFailureException("Package type jar cannot be used with `usr` or `wlp`."); } if (!includeValues.contains("runnable")) { includeValues.add("runnable"); } } if (includeValues.size() > 0) { include = String.join(",", includeValues); } }