auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Object[] getElements(Object inputElement) { List<RepositoryTreeNode> nodes = new ArrayList<RepositoryTreeNode>(); List<String> directories = new ArrayList<String>(); RepositoryUtil repositoryUtil = Activator.getDefault().getRepositoryUtil(); if (inputElement instanceof Collection) { for (Iterator it = ((Collection) inputElement).iterator(); it .hasNext();) { Object next = it.next(); if (next instanceof RepositoryTreeNode) nodes.add((RepositoryTreeNode) next); else if (next instanceof String) directories.add((String) next); } } else if (inputElement instanceof IWorkspaceRoot) { directories.addAll(repositoryUtil.getConfiguredRepositories()); } for (String directory : directories) { try { File gitDir = new File(directory); if (gitDir.exists()) { RepositoryNode rNode = new RepositoryNode(null, repositoryCache .lookupRepository(gitDir)); nodes.add(rNode); <START> } else { <END> repositoryUtil.removeDir(gitDir); } } catch (IOException e) { } } Collections.sort(nodes); return nodes.toArray(); }</code><technical_language>Style: brackets single lines</technical_language>

Target:
public Object[] getElements(Object inputElement) { List<RepositoryTreeNode> nodes = new ArrayList<RepositoryTreeNode>(); List<String> directories = new ArrayList<String>(); RepositoryUtil repositoryUtil = Activator.getDefault().getRepositoryUtil(); if (inputElement instanceof Collection) { for (Iterator it = ((Collection) inputElement).iterator(); it .hasNext();) { Object next = it.next(); if (next instanceof RepositoryTreeNode) nodes.add((RepositoryTreeNode) next); else if (next instanceof String) directories.add((String) next); } } else if (inputElement instanceof IWorkspaceRoot) { directories.addAll(repositoryUtil.getConfiguredRepositories()); } for (String directory : directories) { try { File gitDir = new File(directory); if (gitDir.exists()) { RepositoryNode rNode = new RepositoryNode(null, repositoryCache .lookupRepository(gitDir)); nodes.add(rNode); } else repositoryUtil.removeDir(gitDir); } catch (IOException e) { } } Collections.sort(nodes); return nodes.toArray(); }
Source:
<code>public <U> OptimizeStatement<U> map(Function<? super T, ? extends U> mapper) { return new OptimizeStatement( <START> tables.stream().map(t -> t.map(mapper)).collect(toList()), <END> properties.map(mapper) ); }</code><technical_language>Lists2.map() instead</technical_language>

Target:
public <U> OptimizeStatement<U> map(Function<? super T, ? extends U> mapper) { return new OptimizeStatement( Lists2.map(tables, x -> x.map(mapper)), properties.map(mapper) ); }
Source:
<code>public T messageType(String messageType) { this.messageType = messageType; getAction().setMessageType(messageType); <START> if (MessageType.BINARY.name().equals(messageType)) { <END> getMessageContentBuilder().add(binaryMessageConstructionInterceptor); } if (MessageType.GZIP.name().equals(messageType)) { getMessageContentBuilder().add(gzipMessageConstructionInterceptor); } return self; }</code><technical_language>I binaryMessageConstructionInterceptor.supportsMessageType() source of truth for decision, interceptor handle message type</technical_language>

Target:
public T messageType(String messageType) { this.messageType = messageType; getAction().setMessageType(messageType); if (binaryMessageConstructionInterceptor.supportsMessageType(messageType)) { getMessageContentBuilder().add(binaryMessageConstructionInterceptor); } if (gzipMessageConstructionInterceptor.supportsMessageType(messageType)) { getMessageContentBuilder().add(gzipMessageConstructionInterceptor); } return self; }
Source:
<code>public static void initializeDefaultPreferences(IEclipsePreferences defaultPreferences) { Preferences prefs= defaultPreferences.node(INDEXER_NODE); prefs.put(KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER); prefs.putBoolean(KEY_INDEX_ALL_FILES, true); prefs.putBoolean(KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, true); prefs.putBoolean(KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG, false); prefs.putBoolean(KEY_INDEX_ON_OPEN, false); prefs.putBoolean(KEY_INCLUDE_HEURISTICS, true); prefs.putInt(KEY_SKIP_FILES_LARGER_THAN_MB, DEFAULT_FILE_SIZE_LIMIT); prefs.putBoolean(KEY_SKIP_ALL_REFERENCES, false); prefs.putBoolean(KEY_SKIP_IMPLICIT_REFERENCES, false); prefs.putBoolean(KEY_SKIP_TYPE_REFERENCES, false); prefs.putBoolean(KEY_SKIP_MACRO_REFERENCES, false); prefs.put(KEY_INDEX_IMPORT_LOCATION, DEFAULT_INDEX_IMPORT_LOCATION); prefs.putBoolean(KEY_INDEX_ALL_HEADER_VERSIONS, false); <START> prefs.put(KEY_INDEX_ALL_VERSIONS_SPECIFIC_HEADERS, DEFAULT_INDEX_ALL_VERSIONS_SPECIFIC_HEADERS); <END> }</code><technical_language>Initialization empty string is necessary. consuming code gracefully handle unset preference</technical_language>

Target:
public static void initializeDefaultPreferences(IEclipsePreferences defaultPreferences) { Preferences prefs= defaultPreferences.node(INDEXER_NODE); prefs.put(KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER); prefs.putBoolean(KEY_INDEX_ALL_FILES, true); prefs.putBoolean(KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, true); prefs.putBoolean(KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG, false); prefs.putBoolean(KEY_INDEX_ON_OPEN, false); prefs.putBoolean(KEY_INCLUDE_HEURISTICS, true); prefs.putInt(KEY_SKIP_FILES_LARGER_THAN_MB, DEFAULT_FILE_SIZE_LIMIT); prefs.putBoolean(KEY_SKIP_ALL_REFERENCES, false); prefs.putBoolean(KEY_SKIP_IMPLICIT_REFERENCES, false); prefs.putBoolean(KEY_SKIP_TYPE_REFERENCES, false); prefs.putBoolean(KEY_SKIP_MACRO_REFERENCES, false); prefs.put(KEY_INDEX_IMPORT_LOCATION, DEFAULT_INDEX_IMPORT_LOCATION); prefs.putBoolean(KEY_INDEX_ALL_HEADER_VERSIONS, false); }
Source:
<code>public TmfStatisticsTreeNode getTop() { if (fTopNode == null) { fTopNode = this; while (fTopNode.getParent() != null && fTopNode.getParent().getParent() != null) { fTopNode = fTopNode.getParent(); <START> } <END> } return fTopNode; }</code><technical_language>do this in constructor, field fTopNode final</technical_language>

Target:
public TmfStatisticsTreeNode getTop() { return fTopNode; }
Source:
<code>public CPPStreamConnectionProvider() throws UnsupportedOperationException { List<String> commands = new ArrayList<>(); <START> if (store.getString(PreferenceConstants.P_SERVER_CHOICE).equals("cquery")) { END> languageServer = new CqueryLanguageServer(); } else if (store.getString(PreferenceConstants.P_SERVER_CHOICE).equals("clangd")) { languageServer = new ClangdLanguageServer(); } else { throw new UnsupportedOperationException("Unsupported Language Server"); } File defaultLSLocation = getDefaultLSLocation(store.getString(PreferenceConstants.P_SERVER_CHOICE)); if(defaultLSLocation != null) { store.setDefault(PreferenceConstants.P_SERVER_PATH, defaultLSLocation.getAbsolutePath()); } File languageServerLocation = getLanguageServerLocation(); String parent = ""; String flags = store.getString(PreferenceConstants.P_SERVER_OPTIONS); if (languageServerLocation != null) { commands.add(languageServerLocation.getAbsolutePath()); if (!flags.isEmpty()) { commands.add(flags); } parent = languageServerLocation.getParent(); } setWorkingDirectory(parent); setCommands(commands); }</code><technical_language>other I thought of: factor strings out variables CQUERY_ID CLANGD_ID, reuse in CPPLanguageServerPreferencePage</technical_language>

Target:
public CPPStreamConnectionProvider() throws UnsupportedOperationException { List<String> commands = new ArrayList<>(); if (store.getString(PreferenceConstants.P_SERVER_CHOICE).equals(CQUERY_ID)) { languageServer = new CqueryLanguageServer(); } else if (store.getString(PreferenceConstants.P_SERVER_CHOICE).equals(CLANGD_ID)) { languageServer = new ClangdLanguageServer(); } else { throw new UnsupportedOperationException("Unsupported Language Server"); } File defaultLSLocation = getDefaultLSLocation(store.getString(PreferenceConstants.P_SERVER_CHOICE)); if(defaultLSLocation != null) { store.setDefault(PreferenceConstants.P_SERVER_PATH, defaultLSLocation.getAbsolutePath()); } File languageServerLocation = getLanguageServerLocation(); String parent = ""; String flags = store.getString(PreferenceConstants.P_SERVER_OPTIONS); if (languageServerLocation != null) { commands.add(languageServerLocation.getAbsolutePath()); if (!flags.isEmpty()) { commands.add(flags); } parent = languageServerLocation.getParent(); } setWorkingDirectory(parent); setCommands(commands); }
Source:
<code>static String saveGetLocation(WebDriver driver) { logger.entering(driver); String location = "n/a"; try { if (driver != null) { location = driver.getCurrentUrl(); } } catch (Exception exception) { <START> logger.log(Level.FINEST, "Current location couldn't be retrieved by getCurrentUrl().", exception); <END> } logger.exiting(location); return location; }</code><technical_language>@ILikeToNguyen change FINEST here</technical_language>

Target:
static String saveGetLocation(WebDriver driver) { logger.entering(driver); String location = "n/a"; try { if (driver != null) { location = driver.getCurrentUrl(); } } catch (Exception exception) { logger.log( Level.WARNING, "Current location couldn't be retrieved by getCurrentUrl(). This can be SAFELY IGNORED if testing a non-web mobile application. Reason: " + exception.getClass().getName() + ": " + exception.getMessage()); } logger.exiting(location); return location; }
Source:
<code>private static void printJobs() { Job[] jobs = Job.getJobManager().find(null); for (Job job : jobs) { System.err.println(job.toString() + " state: " + jobStateToString(job.getState())); for (StackTraceElement stractTraceElement : <START> job.getThread().getStackTrace()) <END> { System.err.println(" " + stractTraceElement); } System.err.println(); } }</code><technical_language>running Eclipse I noticed job.getThread() return null. a null check for that</technical_language>

Target:
private static void printJobs() { Job[] jobs = Job.getJobManager().find(null); for (Job job : jobs) { System.err.println(job.toString() + " state: " + jobStateToString(job.getState())); Thread thread = job.getThread(); if (thread != null) { for (StackTraceElement stractTraceElement : thread.getStackTrace()) { System.err.println(" " + stractTraceElement); } } System.err.println(); } }
Source:
<code>public void update() { if (!getWorldIn().isRemote && getParts().isEmpty()) { getWorldIn().setBlockToAir(getPosIn()); return; } for (IMultipart part : getParts()) { <START> if (part instanceof ITickable) <END> { ((ITickable) part).update(); } } }</code><technical_language>this baked instead of tick..</technical_language>

Target:
public void update() { for (IMultipart part : container.getTickingParts()) { if (part instanceof ITickable) { ((ITickable) part).update(); } } }
Source:
<code>protected <T extends Message, C extends MessageCodec<T>> C bind(Class<C> clazz) throws InstantiationException, IllegalAccessException, InvocationTargetException { boolean dynamicId = false; Constructor<C> constructor; try { constructor = clazz.getConstructor(); } catch (NoSuchMethodException e) { try { constructor = clazz.getConstructor(int.class); dynamicId = true; } catch (NoSuchMethodException e1) { throw (InstantiationException) new InstantiationException().initCause(e1); } } C codec; if (dynamicId) { int id; if (dynamicPacketMap.getKeys().contains(clazz.getName())) { id = dynamicPacketMap.register(clazz.getName()); } else { id = nextId.getAndIncrement(); } codec = constructor.newInstance(id); codec.setDynamic(true); } else { codec = constructor.newInstance(); <START> codec.setOpcode(nextId.getAndIncrement()); <END> } register(codec); dynamicPacketMap.register(clazz.getName(), codec.getOpcode()); return codec; }</code><technical_language>removing this check? This issues read packet id's</technical_language>

Target:
protected <T extends Message, C extends MessageCodec<T>> C bind(Class<C> clazz) throws InstantiationException, IllegalAccessException, InvocationTargetException { boolean dynamicId = false; Constructor<C> constructor; try { constructor = clazz.getConstructor(); } catch (NoSuchMethodException e) { try { constructor = clazz.getConstructor(int.class); dynamicId = true; } catch (NoSuchMethodException e1) { throw (InstantiationException) new InstantiationException().initCause(e1); } } if (dynamicPacketMap.getKeys().contains(clazz.getName())) { return (C) find(dynamicPacketMap.register(clazz.getName())); } final C codec; if (dynamicId) { int id; do { id = nextId.getAndIncrement(); } while (find(id) != null); codec = constructor.newInstance(id); codec.setDynamic(true); } else { codec = constructor.newInstance(); final MessageCodec<?> prevCodec = find(codec.getOpcode()); if (prevCodec != null) { throw new IllegalStateException("Trying to bind a static opcode where one already exists. Static: " + clazz.getSimpleName() + " Other: " + prevCodec.getClass().getSimpleName()); } } register(codec); dynamicPacketMap.register(clazz.getName(), codec.getOpcode()); return codec; }
Source:
<code>public Response addMetadataStoreRealm(@PathParam("realm") String realm) { try { <START> LOG.error("updating {}", _namespace, realm); <END> _metadataStoreDirectory.addMetadataStoreRealm(_namespace, realm); } catch (IllegalArgumentException ex) { return notFound(ex.getMessage()); } return OK(); }</code><technical_language>is this error? this info log? "updating {}" is detailed enough. "Successfully added metadata store realm namespace {}!"... put call succeeded</technical_language>

Target:
public Response addMetadataStoreRealm(@PathParam("realm") String realm) { try { _metadataStoreDirectory.addMetadataStoreRealm(_namespace, realm); } catch (IllegalArgumentException ex) { return notFound(ex.getMessage()); } return created(); }
Source:
<code>@Override public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { switch (call.getKind()) { case FLOOR: if (call.operandCount() != 2) { super.unparseCall(writer, call, leftPrec, rightPrec); return; } unparseFloor(writer, call); break; default: <START> if (call.getOperator() == SqlStdOperatorTable.CONCAT) { <END> unparseConcat(writer, call); break; } super.unparseCall(writer, call, leftPrec, rightPrec); } }</code><technical_language>Please move this piece of code switch-case block, refer style in OracleSqlDialect</technical_language>

Target:
@Override public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { switch (call.getKind()) { case FLOOR: if (call.operandCount() != 2) { super.unparseCall(writer, call, leftPrec, rightPrec); return; } unparseFloor(writer, call); break; default: super.unparseCall(writer, call, leftPrec, rightPrec); } }
Source:
<code>private static File moveToFinalLocation(File tmpFile) throws Exception { String pluginName; try (JarFile jf = new JarFile(tmpFile)) { pluginName = jf.getManifest().getMainAttributes().getValue("Short-Name"); } if (pluginName == null) { <START> throw new IllegalArgumentException("JAR does not look like a plugin"); <END> } File target = new File(Jenkins.get().getPluginManager().rootDir, pluginName + ".jpi"); Files.move(tmpFile.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); return target; }</code><technical_language>suggestion throw new IllegalArgumentException("JAR a plugin, is Short-Name manifest attribute");</technical_language>

Target:
private static File moveToFinalLocation(File tmpFile) throws Exception { String pluginName; try (JarFile jf = new JarFile(tmpFile)) { Manifest mf = jf.getManifest(); if (mf == null) { throw new IllegalArgumentException("JAR lacks a manifest"); } pluginName = mf.getMainAttributes().getValue("Short-Name"); } if (pluginName == null) { throw new IllegalArgumentException("JAR manifest lacks a Short-Name attribute and so does not look like a plugin"); } File target = new File(Jenkins.get().getPluginManager().rootDir, pluginName + ".jpi"); Files.move(tmpFile.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); return target; }
Source:
<code>private boolean isEnabled(HazelcastInstance client) { HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client); ClientListenerService listenerService = clientInstanceImpl.getListenerService(); Collection<EventHandler> values = ((SmartClientListenerService) listenerService).getEventHandlers().values(); boolean found = false; for (EventHandler value : values) { if (value instanceof SmartClientInvocationService.BackupEventHandler) { <START> found = true; <END> } } return found; }</code><technical_language>return here</technical_language>

Target:
private boolean isEnabled(HazelcastInstance client) { HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client); ClientListenerService listenerService = clientInstanceImpl.getListenerService(); Collection<EventHandler> values = ((SmartClientListenerService) listenerService).getEventHandlers().values(); for (EventHandler value : values) { if (value instanceof SmartClientInvocationService.BackupEventHandler) { return true; } } return false; }
Source:
<code>private String i18n(String key) { <START> String result = GanttLanguage.getInstance().getText(key); <END> if (result== null){ result = key; } return result; }</code><technical_language>I suggest InternationalizationKt.getRootLocalizer().formatText(key) instead. returns key if translation</technical_language>

Target:
private String i18n(String key) { return InternationalizationKt.getRootLocalizer().formatText(key); }
Source:
<code>public TumorType(TumorType otherTumorType) { this.id = otherTumorType.id; this.code = otherTumorType.code; this.color = otherTumorType.color; this.name = otherTumorType.name; if (otherTumorType.mainType != null) { this.mainType = new MainType(otherTumorType.mainType); } this.NCI = new ArrayList<String>(otherTumorType.NCI); this.UMLS = new ArrayList<String>(otherTumorType.UMLS); this.tissue = otherTumorType.tissue; this.children = new HashMap<String, TumorType>(otherTumorType.children.size()); for (Map.Entry<String, TumorType> entry : otherTumorType.children.entrySet()) { <START> this.children.put(entry.getKey(), new TumorType(entry.getValue())); <END> } this.parent = otherTumorType.parent; this.deprecated = otherTumorType.deprecated; this.history = new ArrayList<String>(otherTumorType.history); if (otherTumorType.links != null) { this.links = new Links(otherTumorType.links); } this.level = otherTumorType.level; }</code><technical_language>This is a recursive call .. is a scary in a constructor. If copy a node is a descendent of in way, headed for a stack overflow. If want safety this possibility, do a cycle dependency check/detection ... searching if descendant paths current object, if so, refusing copy children a special represents a logical failure. Another issue is node in cache multiple copies --- for itself, for ancestor node. a maximum tree depth of 10 is 10 times memory usage necessary. (or this constructor function is for return values passed out of services? (rather cache initialization code) If is case, this function a constructor a "cloneTumorTypeValue()" function. constructor do shallow copy (re-using children). addChild member function, I suggest cycle detection for deep cloning. (This done in future PR)</technical_language>

Target:
public TumorType(TumorType otherTumorType) { this.id = otherTumorType.id; this.code = otherTumorType.code; this.color = otherTumorType.color; this.name = otherTumorType.name; if (otherTumorType.mainType != null) { this.mainType = new MainType(otherTumorType.mainType); } this.NCI = new ArrayList<String>(otherTumorType.NCI); this.UMLS = new ArrayList<String>(otherTumorType.UMLS); this.tissue = otherTumorType.tissue; this.children = new HashMap<String, TumorType>(otherTumorType.children); this.parent = otherTumorType.parent; this.deprecated = otherTumorType.deprecated; this.history = new ArrayList<String>(otherTumorType.history); if (otherTumorType.links != null) { this.links = new Links(otherTumorType.links); } this.level = otherTumorType.level; }
Source:
<code>public boolean handleClear() { <START> selectedVersions.clear(); <END> IAtsChangeSet changes = AtsClientService.get().createChangeSet("Update Found-In-Location"); changes.unrelateAll(getArtifact(), getRelation()); changes.executeIfNeeded(); notifyXModifiedListeners(); return true; }</code><technical_language>change Location Version</technical_language>

Target:
public boolean handleClear() { selectedVersions.clear(); IAtsChangeSet changes = AtsClientService.get().createChangeSet("Update Found-In-Version"); changes.unrelateAll(getArtifact(), getRelation()); changes.executeIfNeeded(); notifyXModifiedListeners(); return true; }
Source:
<code>private KafkaStreamImporterConfig(URI uri, List<HostAndPort> brokers, String topic, int partition, HostAndPort partitionLeader, String groupId, int fetchSize, int soTimeout, String procedure, String commitPolicy, FormatterBuilder formatterBuilder) { m_uri = uri; m_brokers = brokers; m_topic = topic; m_partition = partition; m_partitionLeader = partitionLeader; m_groupId = groupId; m_fetchSize = fetchSize; m_soTimeout = soTimeout; m_procedure = procedure; KafkaImporterCommitPolicy cp; long triggerValue; try { cp = KafkaImporterCommitPolicy.fromString(commitPolicy); triggerValue = KafkaImporterCommitPolicy.fromStringTriggerValue(commitPolicy, cp); <START> } catch (Exception ex) { <END> m_logger.warn("Failed to configure commit policy: " + commitPolicy); cp = KafkaImporterCommitPolicy.COMMIT_POLICY_NONE; triggerValue = 0; } m_commitPolicy = cp; m_triggerValue = triggerValue; m_formatterBuilder = formatterBuilder; }</code><technical_language>catch a more descriptive IllegalArgumentException</technical_language>

Target:
private KafkaStreamImporterConfig(URI uri, List<HostAndPort> brokers, String topic, int partition, HostAndPort partitionLeader, String groupId, int fetchSize, int soTimeout, String procedure, String commitPolicy, FormatterBuilder formatterBuilder) { m_uri = uri; m_brokers = brokers; m_topic = topic; m_partition = partition; m_partitionLeader = partitionLeader; m_groupId = groupId; m_fetchSize = fetchSize; m_soTimeout = soTimeout; m_procedure = procedure; KafkaImporterCommitPolicy cp; m_commitPolicy = KafkaImporterCommitPolicy.fromString(commitPolicy); m_triggerValue = KafkaImporterCommitPolicy.fromStringTriggerValue(commitPolicy, m_commitPolicy); m_formatterBuilder = formatterBuilder; }
Source:
<code>public void info() throws Exception { String json = "{\"app.time.timestamp.format\":\"YYYY\"}"; this.mockMvc.perform( get("/streams/deployments/{timelog}?reuse-deployment-properties=true", "timelog") .contentType(MediaType.APPLICATION_JSON) .content(json)) <START> .andDo(print()) <END> .andExpect(status().isOk()) .andDo(this.documentationHandler.document( pathParameters(parameterWithName("timelog") .description("The name of an existing stream definition (required)")), requestParameters(parameterWithName("reuse-deployment-properties") .description(parameterWithName("The name of the flag to reuse the deployment properties"))) )); }</code><technical_language>remove print() clean logs testing</technical_language>

Target:
public void info() throws Exception { String json = "{\"app.time.timestamp.format\":\"YYYY\"}"; this.mockMvc.perform( get("/streams/deployments/{timelog}?reuse-deployment-properties=true", "timelog") .contentType(MediaType.APPLICATION_JSON) .content(json)) .andExpect(status().isOk()) .andDo(this.documentationHandler.document( pathParameters(parameterWithName("timelog") .description("The name of an existing stream definition (required)")), requestParameters(parameterWithName("reuse-deployment-properties") .description(parameterWithName("The name of the flag to reuse the deployment properties"))) )); }
Source:
<code>public static Expression color(Object value, Factory factory) { Color color = null; if (value instanceof String) { Matcher m = HEX_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsHex(m); } if (color == null) { m = RGB_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsRGB(m); } } if (color == null) { color = Colors.get((String) value); } } else if (value instanceof Integer) { color = new Color((int) value); } if (value != null) value = value.toString(); String hex = null; if (color != null) { hex = String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()); hex = hex.toUpperCase(); <START> } <END> return color != null ? factory.filter.literal(hex) : expression((String) value, factory); }</code><technical_language>is this logic do? Is a bug report? is a bunch of color converters cover cases, good avoid duplication. updated description details #1648</technical_language>

Target:
public static Expression color(Object value, Factory factory) { Color color = null; if (value instanceof String) { Matcher m = HEX_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsHex(m); } if (color == null) { m = RGB_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsRGB(m); } } if (color == null) { color = Colors.get((String) value); } } else if (value instanceof Integer) { color = new Color((int) value); } if (value != null) value = value.toString(); return color != null ? factory.filter.literal(color) : expression((String) value, factory); }
Source:
<code>public void testCheckForSchemeFailWithException() throws KettleFileException { <START> String invalidVfsFilename = "{\"sport_hitting_tm\":{\"copyRight\":\" Copyright 2019 MLB Advanced Media, L.P. Use of any" <END> + " content on this page acknowledges agreement to the terms posted here <LINK_0>" + ".com/components/copyright.txt \",\"queryResults\":{\"created\":\"2019-07-19T20:57:27\",\"totalSize\":\"1\"," + "\"row\":{\"gidp\":\"5\",\"sac\":\"0\",\"np\":\"1681\",\"sport_code\":\"mlb\",\"hgnd\":\"14\",\"tb\":\"209\"," + "\"gidp_opp\":\"55\",\"sport_id\":\"1\",\"bb\":\"77\",\"avg\":\".305\",\"slg\":\".663\",\"team_full\":\"Los " + "Angeles Angels\",\"ops\":\"1.117\",\"hbp\":\"11\",\"league_full\":\"American League\"," + "\"team_abbrev\":\"LAA\",\"so\":\"70\",\"hfly\":\"33\",\"wo\":\"0\",\"league_id\":\"103\",\"sf\":\"3\"," + "\"team_seq\":\"1\",\"league\":\"AL\",\"hpop\":\"0\",\"cs\":\"2\",\"season\":\"2019\",\"sb\":\"8\"," + "\"go_ao\":\"0.55\",\"ppa\":\"4.14\",\"player_id\":\"545361\",\"ibb\":\"11\",\"team_id\":\"108\"," + "\"roe\":\"2\",\"go\":\"54\",\"hr\":\"30\",\"rbi\":\"75\",\"babip\":\".303\",\"lob\":\"121\"," + "\"end_date\":\"2019-07-19T00:00:00\",\"xbh\":\"52\",\"league_short\":\"American\",\"g\":\"91\",\"d\":\"21\"," + "\"sport\":\"MLB\",\"team_short\":\"LA Angels\",\"tpa\":\"406\",\"h\":\"96\",\"obp\":\".453\"," + "\"hldr\":\"49\",\"t\":\"1\",\"ao\":\"98\",\"r\":\"75\",\"ab\":\"315\"}}}}"; KettleVFS.getScheme( invalidVfsFilename ); }</code><technical_language>this JSON string is copyrighted, in a public test case in code? avoid copyright issues mock a JSON string instead..</technical_language>

Target:
public void testCheckForSchemeFailWithException() throws KettleFileException { String invalidVfsFilename = "{\"textMessage\":{\"textMessage\":\" textMessage" + "textMessage \",\"textMessage\":{textMessage}}}"; KettleVFS.getScheme( invalidVfsFilename ); }
Source:
<code>public void supplyVanillaManipulators(List<DataManipulator<?, ?>> manipulators) { super.supplyVanillaManipulators(manipulators); <START> manipulators.add(new SpongeTargetedEntityData()); <END> }</code><technical_language>This is wrong. returning empty target</technical_language>

Target:
public void supplyVanillaManipulators(List<DataManipulator<?, ?>> manipulators) { super.supplyVanillaManipulators(manipulators); manipulators.add(getTargetData()); manipulators.add(getDirectionalData()); }
Source:
<code>final void continuouslyRestart(long interval) throws IOException, InterruptedException { <START> LOGGER.entering(new Object[] { interval }); <END> while (true) { if (!isInitialized()) { FileDownloader.checkForDownloads(getType(), getLauncherOptions() .isFileDownloadCheckTimeStampOnInvocation(), getLauncherOptions() .isFileDownloadCleanupOnInvocation()); } startProcess(false); while (!handler.hasResult()) { LOGGER.fine("Child process still running. Going back to sleep."); Thread.sleep(interval); } if (handler.hasResult()) { ExecuteException e = handler.getException(); if (e != null) { LOGGER.log(Level.SEVERE, handler.getException().getMessage(), handler.getException()); } } LOGGER.info("Child process quit. Restarting it."); setInitialized(false); } }</code><technical_language>minor array is necessary here</technical_language>

Target:
final void continuouslyRestart(long interval) throws IOException, InterruptedException { LOGGER.entering(interval); while (true) { if (!isInitialized()) { FileDownloader.checkForDownloads(getType(), getLauncherOptions() .isFileDownloadCheckTimeStampOnInvocation(), getLauncherOptions() .isFileDownloadCleanupOnInvocation()); } startProcess(false); while (!handler.hasResult()) { LOGGER.fine("Child process still running. Going back to sleep."); Thread.sleep(interval); } if (handler.hasResult()) { ExecuteException e = handler.getException(); if (e != null) { LOGGER.log(Level.SEVERE, handler.getException().getMessage(), handler.getException()); } } LOGGER.info("Child process quit. Restarting it."); setInitialized(false); } }
Source:
<code>public boolean handle(CorfuMsg message, ChannelHandlerContext ctx) { if (handlerMap.containsKey(message.getMsgType())) { try { Object ret = handlerMap.get(message.getMsgType()) .handle(message, ctx, client.getRouter()); if (ret != null) { client.getRouter().completeRequest(message.getRequestID(), ret); } <START> } catch (Exception | Error e) { <END> client.getRouter().completeExceptionally(message.getRequestID(), e); } return true; } return false; }</code><technical_language>do want Throwables this is wide enough</technical_language>

Target:
public boolean handle(CorfuMsg message, ChannelHandlerContext ctx) { if (handlerMap.containsKey(message.getMsgType())) { try { Object ret = handlerMap.get(message.getMsgType()) .handle(message, ctx, client.getRouter()); if (ret != null) { client.getRouter().completeRequest(message.getRequestID(), ret); } } catch (Throwable e) { client.getRouter().completeExceptionally(message.getRequestID(), e); } return true; } return false; }
Source:
<code><START> public View onCreateActionView() { <END> View chooserView = super.onCreateActionView(); Drawable icon = mContext.getResources().getDrawable(R.drawable.ic_share_24dp); Class clazz = chooserView.getClass(); try { Method method = clazz.getMethod("setExpandActivityOverflowButtonDrawable", Drawable.class); method.invoke(chooserView, icon); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return chooserView; }</code><technical_language>I a bit of hunting Stack Overflow I surprised work customize icon, this suggestion: <LINK_0> (just read "UPDATE" line top, rest of post). I confirmed locally his/her suggestion works; do opposition switching that</technical_language>

Target:
public View onCreateActionView() { return null; }
Source:
<code>public List<UserExtSource> getActiveUserExtSources(PerunSession sess, User user) throws InternalErrorException { LocalDate date = LocalDate.now(); date = date.minusMonths(MAX_OLD_OF_ACTIVE_USER_EXTSOURCE); try { String query = "select " + userExtSourceMappingSelectQuery + ", " + ExtSourcesManagerImpl.extSourceMappingSelectQuery + " from user_ext_sources left join ext_sources on user_ext_sources.ext_sources_id=ext_sources.id where " + " user_ext_sources.user_id=? and " + <START> " user_ext_sources.last_access > " + Compatibility.toDate("'" + date.toString() + "'", "'YYYY-MM-DD'"); <END> return jdbc.query(query, USEREXTSOURCE_MAPPER, user.getId()); } catch(EmptyResultDataAccessException ex) { return new ArrayList<>(); } catch (RuntimeException ex) { throw new InternalErrorException(ex); } }</code><technical_language>I do need explicitly call toString method</technical_language>

Target:
public List<UserExtSource> getActiveUserExtSources(PerunSession sess, User user) throws InternalErrorException { LocalDate date = LocalDate.now(); date = date.minusMonths(MAX_OLD_OF_ACTIVE_USER_EXTSOURCE); try { String query = "select " + userExtSourceMappingSelectQuery + ", " + ExtSourcesManagerImpl.extSourceMappingSelectQuery + " from user_ext_sources left join ext_sources on user_ext_sources.ext_sources_id=ext_sources.id where " + " user_ext_sources.user_id=? and " + " user_ext_sources.last_access > " + Compatibility.toDate("'" + date + "'", "'YYYY-MM-DD'"); return jdbc.query(query, USEREXTSOURCE_MAPPER, user.getId()); } catch(EmptyResultDataAccessException ex) { return new ArrayList<>(); } catch (RuntimeException ex) { throw new InternalErrorException(ex); } }
Source:
<code>private static Error error() { return Error.newBuilder() <START> .setMessage("Task can not be created done.") <END> .build(); }</code><technical_language>"The task created in a 'done' state."</technical_language>

Target:
private static Error error() { return Error.newBuilder() .setMessage("The task cannot be created in a 'completed' state.") .build(); }
Source:
<code>public void testSimpleBatch() { Batch batch = handle.createBatch(); batch.add("INSERT INTO fruit VALUES(0, 'apple')"); batch.add("INSERT INTO fruit VALUES(1, 'banana')"); int[] rowsModified = batch.execute(); <START> assertThat(rowsModified).hasSize(2).containsOnly(1); <END> assertThat(handle.createQuery("SELECT count(1) FROM fruit") .mapTo(int.class) .findOnly() .intValue()) .isEqualTo(2); }</code><technical_language>this containsExactly(1, 1)</technical_language>

Target:
public void testSimpleBatch() { Batch batch = handle.createBatch(); batch.add("INSERT INTO fruit VALUES(0, 'apple')"); batch.add("INSERT INTO fruit VALUES(1, 'banana')"); int[] rowsModified = batch.execute(); assertThat(rowsModified).containsExactly(1, 1); assertThat(handle.createQuery("SELECT count(1) FROM fruit") .mapTo(int.class) .findOnly() .intValue()) .isEqualTo(2); }
Source:
<code>public boolean block() { if (yielder.isDone()) { return true; } if (resultBatch == null || resultBatch.isDrained()) { <START> final Yielder<ResultBatch<E>> nextYielder = yielder.next(resultBatch); <END> yielder = nextYielder; } return true; }</code><technical_language>resultBatch is reused here. I causing problem for now, wondering if create a new instance instead for readability code maintenance. Like, I a couple of classes values queue in ResultBatch is fully consumed adding new elements is chance increase capacity. is a good reason reuse queue</technical_language>

Target:
public boolean block() { if (yielder.isDone()) { return true; } if (resultBatch == null || resultBatch.isDrained()) { resultBatch = new ResultBatch<>(batcher.batchSize); final Yielder<ResultBatch<E>> nextYielder = yielder.next(resultBatch); yielder = nextYielder; } return true; }
Source:
<code>public Treatment(String name, String description) { <START> this.validateName(name); <END> this.name = name; this.description = description; }</code><technical_language>experiment names, override names, etc. well</technical_language>

Target:
public Treatment(String name, String description) throws ValidationException { this.name = name; this.description = description; validateName(); }
Source:
<code>public Map<String, URL> getLocalArtifactUrls(RobolectricTestRunner robolectricTestRunner, Dependency... dependencies) { String cacheName = cacheNamingStrategy.getName(dependencies); <START> Hashtable<String, URL> urlsFromCache = cache.load(cacheName, Hashtable.class); <END> if(urlsFromCache != null) { return new HashMap<String, URL>(urlsFromCache); } Map<String, URL> urls = mavenCentral.getLocalArtifactUrls(robolectricTestRunner, dependencies); cache.write(cacheName, new Hashtable<String, URL>(urls)); return urls; }</code><technical_language>Hashtable HashMap</technical_language>

Target:
public URL[] getLocalArtifactUrls(RobolectricTestRunner robolectricTestRunner, Dependency... dependencies) { String cacheName = cacheNamingStrategy.getName(CACHE_PREFIX_1, dependencies); URL[] urlsFromCache = cache.load(cacheName, URL[].class); if(urlsFromCache != null) { return urlsFromCache; } URL[] urls = mavenCentral.getLocalArtifactUrls(robolectricTestRunner, dependencies); cache.write(cacheName, urls); return urls; }
Source:
<code>private void subscribeToAlternate() { <START> add(alternate.unsafeSubscribe(new Subscriber<T>() { <END> @Override public void onStart() { final long capacity = consumerCapacity.get(); if (capacity > 0) { request(capacity); } } @Override public void onCompleted() { child.onCompleted(); } @Override public void onError(Throwable e) { child.onError(e); } @Override public void onNext(T t) { child.onNext(t); } })); }</code><technical_language>child.add(...)</technical_language>

Target:
private void subscribeToAlternate() { child.add(alternate.unsafeSubscribe(new Subscriber<T>() { @Override public void setProducer(final Producer producer) { child.setProducer(new Producer() { @Override public void request(long n) { producer.request(n); } }); } @Override public void onStart() { final long capacity = consumerCapacity.get(); if (capacity > 0) { request(capacity); } } @Override public void onCompleted() { child.onCompleted(); } @Override public void onError(Throwable e) { child.onError(e); } @Override public void onNext(T t) { child.onNext(t); } })); }
Source:
<code>public void visitUseStatement(UseStatementTree tree) { useNodes.add(tree); if (nextStatement != null && !nextStatement.is(USE_KINDS)) { <START> checkUsesAreBeforeNamespace(); <END> checkBlankLineAfterUses(tree); useNodes.clear(); } }</code><technical_language>![MAJOR](<LINK_1> this line start column 7. [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
public void visitUseStatement(UseStatementTree tree) { useStatements.add(tree); if (nextStatement != null && !nextStatement.is(USE_KINDS)) { checkUsesAreBeforeNamespace(); checkBlankLineAfterUses(tree); useStatements.clear(); } }
Source:
<code>public void setupDataCall(int radioTechnology, DataProfile dataProfile, boolean isRoaming, boolean allowRoaming, Message result) { IRadio radioProxy = getRadioProxy(result); if (radioProxy != null) { RILRequest rr = obtainRequest(RIL_REQUEST_SETUP_DATA_CALL, result, mRILDefaultWorkSource); DataProfileInfo dpi = convertToHalDataProfile(dataProfile); if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + ",radioTechnology=" + radioTechnology + ",isRoaming=" + isRoaming + ",allowRoaming=" + allowRoaming + "," <START> + ("user".equals(Build.TYPE) ? "***" : dataProfile.toString())); <END> } try { radioProxy.setupDataCall(rr.mSerial, radioTechnology, dpi, dataProfile.modemCognitive, allowRoaming, isRoaming); mMetrics.writeRilSetupDataCall(mPhoneId, rr.mSerial, radioTechnology, dpi.profileId, dpi.apn, dpi.authType, dpi.protocol); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setupDataCall", e); } } }</code><technical_language>carrier want hide *all* APN fields, user password? If user password, a change in DataProfile obscure fields. of other fields useful for debugging, user builds</technical_language>

Target:
public void setupDataCall(int radioTechnology, DataProfile dataProfile, boolean isRoaming, boolean allowRoaming, Message result) { IRadio radioProxy = getRadioProxy(result); if (radioProxy != null) { RILRequest rr = obtainRequest(RIL_REQUEST_SETUP_DATA_CALL, result, mRILDefaultWorkSource); DataProfileInfo dpi = convertToHalDataProfile(dataProfile); if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + ",radioTechnology=" + radioTechnology + ",isRoaming=" + isRoaming + ",allowRoaming=" + allowRoaming + "," + dataProfile); } try { radioProxy.setupDataCall(rr.mSerial, radioTechnology, dpi, dataProfile.modemCognitive, allowRoaming, isRoaming); mMetrics.writeRilSetupDataCall(mPhoneId, rr.mSerial, radioTechnology, dpi.profileId, dpi.apn, dpi.authType, dpi.protocol); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setupDataCall", e); } } }
Source:
<code>public void testClientResponseStatsUpdate() throws IOException, InterruptedException, KeeperException { try (ZooKeeper zk = createClient()) { ProposalStats stats = serverFactory.getZooKeeperServer().serverStats().getClientResponseStats(); assertEquals("", -1, stats.getLast()); zk.create("/a", "test".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); <START> assertThat(stats.getLast(), greaterThan(0)); <END> } }</code><technical_language>0, magic number. possibility give a non-zero value, matching closer expected ? Also, please add error message - assertThat("error message", stats.getLast(), greaterThan(0));</technical_language>

Target:
public void testClientResponseStatsUpdate() throws IOException, InterruptedException, KeeperException { try (ZooKeeper zk = createClient()) { BufferStats clientResponseStats = serverFactory.getZooKeeperServer().serverStats().getClientResponseStats(); assertThat("Last client response size should be initialized with INIT_VALUE", clientResponseStats.getLastBufferSize(), equalTo(BufferStats.INIT_VALUE)); zk.create("/a", "test".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); assertThat("Last client response size should be greater then zero after client request was performed", clientResponseStats.getLastBufferSize(), greaterThan(0)); } }
Source:
<code>private Map<Integer, List<Pair<Long, Long>>> splitIntoSubKeyRanges(final List<Pair<Long, Long>> dataKeyRanges) { final Map<Integer, List<Pair<Long, Long>>> blockToSubKeyRangesMap = new HashMap<>(); for (final Pair<Long, Long> keyRange : dataKeyRanges) { final Map<Integer, Pair<Long, Long>> blockToSubKeyRangeMap = blockResolver.resolveBlocksForOrderedKeys(keyRange.getFirst(), keyRange.getSecond()); for (final Map.Entry<Integer, Pair<Long, Long>> blockToSubKeyRange : blockToSubKeyRangeMap.entrySet()) { final int blockId = blockToSubKeyRange.getKey(); final Pair<Long, Long> subKeyRange = blockToSubKeyRange.getValue(); if (!blockToSubKeyRangesMap.containsKey(blockId)) { <START> blockToSubKeyRangesMap.put(blockId, new LinkedList<>()); <END> } final List<Pair<Long, Long>> subKeyRangeList = blockToSubKeyRangesMap.get(blockId); subKeyRangeList.add(subKeyRange); } } return blockToSubKeyRangesMap; }</code><technical_language>For information, if (!blockToSubKeyRangesMap.containsKey(blockId)) { blockToSubKeyRangesMap.put(blockId, new LinkedList<>()); } written equivalently as: blockToSubKeyRangesMap.putIfAbsent(blockId, new LinkedList<>()); is me</technical_language>

Target:
private Map<Integer, List<Pair<Long, Long>>> splitIntoSubKeyRanges(final List<Pair<Long, Long>> dataKeyRanges) { final Map<Integer, List<Pair<Long, Long>>> blockToSubKeyRangesMap = new HashMap<>(); for (final Pair<Long, Long> keyRange : dataKeyRanges) { final Map<Integer, Pair<Long, Long>> blockToSubKeyRangeMap = blockResolver.resolveBlocksForOrderedKeys(keyRange.getFirst(), keyRange.getSecond()); for (final Map.Entry<Integer, Pair<Long, Long>> blockToSubKeyRange : blockToSubKeyRangeMap.entrySet()) { final int blockId = blockToSubKeyRange.getKey(); final Pair<Long, Long> subKeyRange = blockToSubKeyRange.getValue(); blockToSubKeyRangesMap.computeIfAbsent(blockId, integer -> new LinkedList<>()); final List<Pair<Long, Long>> subKeyRangeList = blockToSubKeyRangesMap.get(blockId); subKeyRangeList.add(subKeyRange); } } return blockToSubKeyRangesMap; }
Source:
<code>private void updateCounter(ISegment segment) { ITmfStateSystemBuilder ss = getStateSystemBuilder(); assertNotNull(ss); try { <START> int quark = ss.getQuarkAbsoluteAndAdd(TmfPatternSegmentManagerTest.COUNTER_STRING, ((TmfXmlPatternSegment) segment).getName().substring(4)); <END> ss.incrementAttribute(segment.getStart(), quark); } catch (StateValueTypeException | AttributeNotFoundException e) { e.printStackTrace(); } }</code><technical_language>This class is this constant instead test class refer it. in state provider, in analysis</technical_language>

Target:
private void updateCounter(ISegment segment) { ITmfStateSystemBuilder ss = getStateSystemBuilder(); assertNotNull(ss); try { int quark = ss.getQuarkAbsoluteAndAdd(TmfXmlPatternSegmentBaseAnalysisForTest.COUNTER_STRING, ((TmfXmlPatternSegment) segment).getName().substring(4)); ss.incrementAttribute(segment.getStart(), quark); } catch (StateValueTypeException | AttributeNotFoundException e) { fail("Failed to update the counter for segment " + ((TmfXmlPatternSegment)segment).getName()); } }
Source:
<code>public static boolean verifyTokenSignature(SignedJWT jwt, String alias) throws APIManagementException { Certificate publicCert = null; try { publicCert = APIUtil.getCertificateFromTrustStore(alias); } catch (APIManagementException e) { throw new APIManagementException("Error retrieving certificate from truststore ",e); } if (publicCert != null) { JWSAlgorithm algorithm = jwt.getHeader().getAlgorithm(); if ((JWSAlgorithm.RS256.equals(algorithm) || JWSAlgorithm.RS512.equals(algorithm) || JWSAlgorithm.RS384.equals(algorithm))) { return verifyTokenSignature(jwt, (RSAPublicKey) publicCert.getPublicKey()); } else { <START> log.error("Public key is not a RSA"); <END> throw new APIManagementException("Public key is not a RSA"); } } else { log.error("Couldn't find a public certificate to verify signature with alias " + alias); throw new APIManagementException("Couldn't find a public certificate to verify signature with alias "); } }</code><technical_language>suggestion log.error("Public key is RSA");</technical_language>

Target:
public static boolean verifyTokenSignature(SignedJWT jwt, String alias) throws APIManagementException { Certificate publicCert = null; try { publicCert = APIUtil.getCertificateFromTrustStore(alias); } catch (APIManagementException e) { throw new APIManagementException("Error retrieving certificate from truststore ",e); } if (publicCert != null) { JWSAlgorithm algorithm = jwt.getHeader().getAlgorithm(); if ((JWSAlgorithm.RS256.equals(algorithm) || JWSAlgorithm.RS512.equals(algorithm) || JWSAlgorithm.RS384.equals(algorithm))) { return verifyTokenSignature(jwt, (RSAPublicKey) publicCert.getPublicKey()); } else { log.error("Public key is not RSA"); throw new APIManagementException("Public key is not RSA"); } } else { log.error("Couldn't find a public certificate with alias " + alias + " to verify the signature"); throw new APIManagementException( "Couldn't find a public certificate with alias " + alias + " to verify the signature"); } }
Source:
<code>public int add(InputRow row, Supplier<Committer> committerSupplier) throws IndexSizeExceededException { final Sink sink = getSink(row.getTimestampFromEpoch()); <START> metrics.reportMessageMaxTimestamp(rejectionPolicy.getCurrMaxTime().getMillis()); <END> if (sink == null) { return -1; } final int numRows = sink.add(row); if (!sink.canAppendRow() || System.currentTimeMillis() > nextFlush) { persist(committerSupplier.get()); } return numRows; }</code><technical_language>timestamp is row instead. is meaningful for message-time rejection policy in this case</technical_language>

Target:
public int add(InputRow row, Supplier<Committer> committerSupplier) throws IndexSizeExceededException { long messageTimestamp = row.getTimestampFromEpoch(); final Sink sink = getSink(messageTimestamp); metrics.reportMessageMaxTimestamp(messageTimestamp); if (sink == null) { return -1; } final int numRows = sink.add(row); if (!sink.canAppendRow() || System.currentTimeMillis() > nextFlush) { persist(committerSupplier.get()); } return numRows; }