auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void changeOpacity(String selector, int value, WebDriver driver) { <START> PageObjectLogging.log("Css selector",selector, true, driver); <END> ((JavascriptExecutor) driver).executeScript( "$(arguments[0]).css('opacity', arguments[1]);", selector, Integer.toString(value) ); }</code><technical_language>s/Css/CSS space comma</technical_language>

Target:
private void changeOpacity(String selector, int value, WebDriver driver) { PageObjectLogging.log("CSS selector", selector, true, driver); ((JavascriptExecutor) driver).executeScript( "$(arguments[0]).css('opacity', arguments[1]);", selector, Integer.toString(value) ); }
Source:
<code>public static ExecutionReport makeReport(String xmlString) throws InvalidReportException { Document xmlDocument = null; try { xmlDocument = XmlUtil.newDocument(xmlString); } catch (IOException | SAXException e) { <START> throw new InvalidReportException("%s is not a valid execution report", e); <END> } Element documentElement = xmlDocument.getDocumentElement(); String documentNodeName = documentElement.getNodeName(); switch (documentNodeName) { case "testResults": return new TestExecutionReport(xmlDocument); case "suiteResults": return new SuiteExecutionReport(xmlDocument); default: throw new InvalidReportException(String.format("%s is not a valid document element tag for an Execution Report.", documentNodeName)); } }</code><technical_language>%s replaced (the xmlString for instance)</technical_language>

Target:
public static ExecutionReport makeReport(String xmlString) throws InvalidReportException { Document xmlDocument = null; try { xmlDocument = XmlUtil.newDocument(xmlString); } catch (IOException | SAXException e) { throw new InvalidReportException(format("%s is not a valid execution report", xmlString), e); } Element documentElement = xmlDocument.getDocumentElement(); String documentNodeName = documentElement.getNodeName(); switch (documentNodeName) { case "testResults": return new TestExecutionReport(xmlDocument); case "suiteResults": return new SuiteExecutionReport(xmlDocument); default: throw new InvalidReportException(format("%s is not a valid document element tag for an Execution Report.", documentNodeName)); } }
Source:
<code>public void testTopologyLevelClassCastException() { final Properties props = new Properties(); props.put(StreamsConfig.APPLICATION_ID_CONFIG, "test"); props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "dummy:1234"); final StreamsBuilder builder = new StreamsBuilder(); builder.<String, String>stream("streams-plaintext-input") .flatMapValues(value -> { return Arrays.asList(""); }); final Topology topology = builder.build(); final TopologyTestDriver testDriver = new TopologyTestDriver(topology, props); <START> final ConsumerRecordFactory<String, String> factory = new ConsumerRecordFactory<>(new StringSerializer(), new StringSerializer()); <END> final ConsumerRecord<byte[], byte[]> consumerRecord = factory.create("streams-plaintext-input", "a-key", "a value"); try { testDriver.pipeInput(consumerRecord); } catch (final StreamsException s) { final String msg = s.getMessage(); assertTrue("Error about class cast with serdes", msg.contains("ClassCastException")); assertTrue("Error about class cast with serdes", msg.contains("serdes")); throw s; } }</code><technical_language>ConsumerRecordFactory is deprecated KIP-470 (merge recently) -- please update code TestInputTopic -- merge as-is, build fail if deprecated classes</technical_language>

Target:
public void testTopologyLevelClassCastException() { final Properties props = new Properties(); props.put(StreamsConfig.APPLICATION_ID_CONFIG, "test"); props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "dummy:1234"); final StreamsBuilder builder = new StreamsBuilder(); builder.<String, String>stream("streams-plaintext-input") .flatMapValues(value -> { return Arrays.asList(""); }); final Topology topology = builder.build(); final TopologyTestDriver testDriver = new TopologyTestDriver(topology, props); final TestInputTopic<String, String> topic = testDriver.createInputTopic("streams-plaintext-input", new StringSerializer(), new StringSerializer()); final StreamsException se = assertThrows(StreamsException.class, () -> topic.pipeInput("a-key", "a value")); final String msg = se.getMessage(); assertTrue("Error about class cast with serdes", msg.contains("ClassCastException")); assertTrue("Error about class cast with serdes", msg.contains("Serdes")); }
Source:
<code>public void testCompareTo() { final MockNode node1 = new MockNode(10, 1); final MockNode node2 = new MockNode(8, 1); <START> assertEquals(2, node1.compareOrder(node2), "Invalid comparison result"); <END> assertEquals(-2, node2.compareOrder(node1), "Invalid comparison result"); }</code><technical_language>Please assertWithMessage Truth instead. is a [bug](<LINK_0> in PMD. is fixed, released</technical_language>

Target:
public void testCompareTo() { final MockNode node1 = new MockNode(10, 1); final MockNode node2 = new MockNode(8, 1); assertWithMessage("Invalid comparison result") .that(node1.compareOrder(node2)) .isEqualTo(2); assertWithMessage("Invalid comparison result") .that(node2.compareOrder(node1)) .isEqualTo(-2); }
Source:
<code><START> public void setUp() throws Exception { <END> cli=HCatUtil.getHCatClient(servers.get(0)); }</code><technical_language>throw explicit exception generic</technical_language>

Target:
public void setUp() throws HCatException { cli=HCatUtil.getHCatClient(servers.get(0)); }
Source:
<code>public CalDavConfig() { <START> super(); <END> }</code><technical_language>CalDavConfig super class (except of java.lang.Object). Do need a super() here</technical_language>

Target:
public CalDavConfig() { }
Source:
<code>SFTPInputStream(ChannelSftp channel, Path path, FileSystem.Statistics stats) { try { this.channel = channel; this.path = path; this.stats = stats; this.wrappedStream = channel.get(path.toUri().getPath()); SftpATTRS stat = channel.lstat(path.toString()); this.contentLength = stat.getSize(); } catch (SftpException e) { <START> throw new UncheckedIOException(new IOException(e)); <END> } }</code><technical_language>double wrap</technical_language>

Target:
SFTPInputStream(ChannelSftp channel, Path path, FileSystem.Statistics stats) throws IOException { try { this.channel = channel; this.path = path; this.stats = stats; this.wrappedStream = channel.get(path.toUri().getPath()); SftpATTRS stat = channel.lstat(path.toString()); this.contentLength = stat.getSize(); } catch (SftpException e) { throw new IOException(e); } }
Source:
<code>public void testLimit() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); EnvironmentSettings envSettings = EnvironmentSettings.newInstance() .useBlinkPlanner() .inStreamingMode() .build(); StreamTableEnvironment tEnv = StreamTableEnvironment.create(env, envSettings); tEnv.executeSql( "CREATE TABLE " + INPUT_TABLE + "(" + "id BIGINT," + "timestamp6_col TIMESTAMP(6)," + "timestamp9_col TIMESTAMP(9)," + "time_col TIME," + "real_col FLOAT," + "double_col DOUBLE," + "decimal_col DECIMAL(10, 4)" + ") WITH (" + " 'connector'='jdbc'," + " 'url'='" + DB_URL + "'," + " 'table-name'='" + INPUT_TABLE + "'" + ")" ); <START> Iterator<Row> collected = tEnv.executeSql("SELECT id FROM " + INPUT_TABLE + " LIMIT 1").collect(); <END> List<String> result = CollectionUtil.iteratorToList(collected).stream() .map(Row::toString) .sorted() .collect(Collectors.toList()); List<String> expected = Collections.singletonList("1"); assertEquals(expected, result); }</code><technical_language>Please select fields</technical_language>

Target:
public void testLimit() throws Exception { tEnv.executeSql( "CREATE TABLE " + INPUT_TABLE + "(\n" + "id BIGINT,\n" + "timestamp6_col TIMESTAMP(6),\n" + "timestamp9_col TIMESTAMP(9),\n" + "time_col TIME,\n" + "real_col FLOAT,\n" + "double_col DOUBLE,\n" + "decimal_col DECIMAL(10, 4)\n" + ") WITH (\n" + " 'connector'='jdbc',\n" + " 'url'='" + DB_URL + "',\n" + " 'table-name'='" + INPUT_TABLE + "',\n" + " 'scan.partition.column'='id',\n" + " 'scan.partition.num'='2',\n" + " 'scan.partition.lower-bound'='1',\n" + " 'scan.partition.upper-bound'='2'\n" + ")" ); Iterator<Row> collected = tEnv.executeSql("SELECT * FROM " + INPUT_TABLE + " LIMIT 1").collect(); List<String> result = CollectionUtil.iteratorToList(collected).stream() .map(Row::toString) .sorted() .collect(Collectors.toList()); Set<String> expected = new HashSet<>(); expected.add("1,2020-01-01T15:35:00.123456,2020-01-01T15:35:00.123456789,15:35,1.175E-37,1.79769E308,100.1234"); expected.add("2,2020-01-01T15:36:01.123456,2020-01-01T15:36:01.123456789,15:36:01,-1.175E-37,-1.79769E308,101.1234"); assertEquals(1, result.size()); assertTrue("The actual output is not a subset of the expected set.", expected.containsAll(result)); }
Source:
<code>public MotorControl(Motor motor, Controller controller, int axis, double scale) { <START> super("motorControl", motor); <END> this.motor = motor; this.controller = controller; this.axis = axis; this.scale = scale; LogKitten.d("MotorControl created."); }</code><technical_language>in a name call setName(name)</technical_language>

Target:
public MotorControl(Motor motor, Controller controller, int axis, double scale) { this("Motor Control", motor, controller, axis, scale); }
Source:
<code>void doHandle(String newName, String profileKey) { checkRequest(StringUtils.isNotBlank(newName), "Name must be set"); checkRequest(newName.length() <= MAXIMUM_NAME_LENGTH, String.format("Name is too long (>%d characters)", MAXIMUM_NAME_LENGTH)); <START> userSession.checkLoggedIn(); <END> try (DbSession dbSession = dbClient.openSession(false)) { QualityProfileDto qualityProfile = ofNullable(dbClient.qualityProfileDao().selectByKey(dbSession, profileKey)) .orElseThrow(() -> new NotFoundException("Quality profile not found: " + profileKey)); String organizationUuid = qualityProfile.getOrganizationUuid(); userSession.checkPermission(ADMINISTER_QUALITY_PROFILES, organizationUuid); if (!StringUtils.equals(newName, qualityProfile.getName())) { OrganizationDto organization = dbClient.organizationDao().selectByUuid(dbSession, organizationUuid) .orElseThrow(() -> new IllegalStateException("No organization found for uuid "+organizationUuid)); String language = qualityProfile.getLanguage(); ofNullable(dbClient.qualityProfileDao().selectByNameAndLanguage(organization, newName, language, dbSession)) .ifPresent(found -> {throw BadRequestException.create(format("Quality profile already exists: %s", newName));}); qualityProfile.setName(newName); dbClient.qualityProfileDao().update(dbSession, qualityProfile); } dbSession.commit(); } }</code><technical_language>do this check right in handle method need process parameters if user is logged in</technical_language>

Target:
void doHandle(String newName, String profileKey) { checkRequest(StringUtils.isNotBlank(newName), "Name must be set"); checkRequest(newName.length() <= MAXIMUM_NAME_LENGTH, String.format("Name is too long (>%d characters)", MAXIMUM_NAME_LENGTH)); userSession.checkLoggedIn(); try (DbSession dbSession = dbClient.openSession(false)) { QualityProfileDto qualityProfile = ofNullable(dbClient.qualityProfileDao().selectByKey(dbSession, profileKey)) .orElseThrow(() -> new NotFoundException("Quality profile not found: " + profileKey)); String organizationUuid = qualityProfile.getOrganizationUuid(); userSession.checkPermission(ADMINISTER_QUALITY_PROFILES, organizationUuid); if (!Objects.equals(newName, qualityProfile.getName())) { OrganizationDto organization = dbClient.organizationDao().selectByUuid(dbSession, organizationUuid) .orElseThrow(() -> new IllegalStateException("No organization found for uuid " + organizationUuid)); String language = qualityProfile.getLanguage(); ofNullable(dbClient.qualityProfileDao().selectByNameAndLanguage(organization, newName, language, dbSession)) .ifPresent(found -> { throw BadRequestException.create(format("Quality profile already exists: %s", newName)); }); qualityProfile.setName(newName); dbClient.qualityProfileDao().update(dbSession, qualityProfile); dbSession.commit(); } } }
Source:
<code>public Optional<String> namespace() { <START> return getSid(); <END> }</code><technical_language>confused, if serviceName longer sid meaning get screwed call namespace i.e. a namespace *not* a namespace. implications of this in atlas? If feels getConnectionDataString return service name if is specified, returns sid sid is *always* provided if serviceName, *need* namespace explicitly migrating over. chat this face face</technical_language>

Target:
public Optional<String> namespace() { if (getSid().isPresent()) { return getSid(); } return serviceNameConfiguration().map(ServiceNameConfiguration::namespaceOverride); }
Source:
<code>public Note get(String noteId, String notePath, AuthenticationInfo subject) throws IOException { <START> LOG.info("====get{}:{}", noteId, notePath); <END> return getNote(noteId, notePath); }</code><technical_language>please update - this format remove ====</technical_language>

Target:
public Note get(String noteId, String notePath, AuthenticationInfo subject) throws IOException { LOG.debug("get note, noteId: {}, notePath:{}", noteId, notePath); return getNote(noteId, notePath); }
Source:
<code>public IStatus validate(IProject project, String path) { if(fileExists(path)) { return Status.OK_STATUS; } <START> return new Status(IStatus.ERROR, "XML", "File not found : "+ path); <END> }</code><technical_language>PLUGIN_ID</technical_language>

Target:
public IStatus validate(IProject project, String path) { if (fileExists(path)) { return Status.OK_STATUS; } return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CustomTrace_FileNotFound + ": " + path); }
Source:
<code>public void configure(JobConf job) { KMER_SIZE = Integer.parseInt(job.get(GenomixJobConf.KMER_LENGTH)); Kmer.setGlobalKmerLength(KMER_SIZE); lineCount = 0; String filename = job.get("map.input.file"); String[] tokens = filename.split("\\.(?=[^\\.]+$)"); if (tokens.length > 2) throw new IllegalStateException("Parse error trying to parse filename... split extension tokens are: " + tokens.toString()); String basename = tokens[0]; String extension = tokens.length == 2 ? tokens[1] : ""; if (extension.equals("fastq") || extension.equals("fq")) { if (!(job.getInputFormat() instanceof NLineInputFormat)) { throw new IllegalStateException("Fastq files require the NLineInputFormat (was " + job.getInputFormat() <START> + " )."); <END> } if (job.getInt("mapred.line.input.format.linespermap", -1) % 4 != 0) { throw new IllegalStateException( "Fastq files require the `mapred.line.input.format.linespermap` option to be divisible by 4 (was " + job.get("mapred.line.input.format.linespermap") + ")."); } fastqFormat = true; } }</code><technical_language>set mateId anymore?</technical_language>

Target:
public void configure(JobConf job) { KMER_SIZE = Integer.parseInt(job.get(GenomixJobConf.KMER_LENGTH)); Kmer.setGlobalKmerLength(KMER_SIZE); }
Source:
<code>public void removePageMultiTrees(final String pageIdentifier) { for (final String group : getGroups()) { <START> removePageMultiTrees(pageIdentifier, group); <END> } }</code><technical_language>this in a simple expression, like: getGroups().forEach(group -> removePageMultiTrees(pageIdentifier, group));</technical_language>

Target:
public void removePageMultiTrees(final String pageIdentifier) { Arrays.asList(getGroups()).forEach(group -> removePageMultiTrees(pageIdentifier, group)); }
Source:
<code>protected void onResume() { super.onResume(); instanceSaved = false; reinitMenu(); if (!Preferences.isLoggedIn(this)) { <START> SharedPreferences sharedPrefs = this.getSharedPreferences( <END> "skip_intro", this.MODE_PRIVATE); if (sharedPrefs.getInt("clickedSkip", 0) == 0) startActivity(new Intent(this, IntroActivity.class)); else startActivity(new Intent(this, AccountActivity.class)); finish(); } }</code><technical_language>a Settings class nice o SharedPreferences implementation</technical_language>

Target:
protected void onResume() { super.onResume(); instanceSaved = false; reinitMenu(); if (!Preferences.isLoggedIn(this)) { if(Preferences.getSkipButton() == false) startActivity(new Intent(this, IntroActivity.class)); else startActivity(new Intent(this, AccountActivity.class)); finish(); } }
Source:
<code>public GetPQValuesResponse dequeueGetPQValuesPeriodicResponse( final String correlationUid ) throws OsgpException { <START> LOGGER.debug( "dequeueSetDataRequest called with correlation uid {}", correlationUid ); <END> return (GetPQValuesResponse) processResponse( correlationUid ); }</code><technical_language>dequeueSetDataRequest</technical_language>

Target:
public GetPQValuesResponse dequeueGetPQValuesPeriodicResponse(final String correlationUid) throws OsgpException { LOGGER.debug("dequeueGetPQValuesPeriodicResponse called with correlation uid {}", correlationUid); return (GetPQValuesResponse) processResponse(correlationUid); }
Source:
<code>protected ValidationResult validateBondModeVsNetworksAttachedToIt( Collection<NetworkAttachment> attachmentsToConfigure) { Map<String, Bond> parameterBondsByName = mapParameterBondsByName(); Map<String, VdsNetworkInterface> hostInterfacesByNetworkName = Entities.hostInterfacesByNetworkName(existingInterfaces); ValidationResult validationResult = ValidationResult.VALID; for (NetworkAttachment attachment : attachmentsToConfigure){ if (!mustAttachementBeCheckedForBondMode(attachment, hostInterfacesByNetworkName)){ continue; } Bond modifiedOrNewBond = parameterBondsByName.get(attachment.getNicName()); <START> if (modifiedOrNewBond != null){ <END> validationResult = checkBondModeForNewOrModifiedBond(attachment, modifiedOrNewBond); } else { validationResult = checkBondModeForExistingBond(attachment); } if (!validationResult.isValid()){ return validationResult; } } return ValidationResult.VALID; }</code><technical_language>'checkBondModeForNewOrModifiedBond' correct functionality in of case (its name 'checkBondMode(..)'). in case of 'modifiedOrNewBond == null' add method for 'existingBond'</technical_language>

Target:
protected ValidationResult validateBondModeVsNetworksAttachedToIt( Collection<NetworkAttachment> attachmentsToConfigure) { Map<String, VdsNetworkInterface> hostInterfacesByNetworkName = Entities.hostInterfacesByNetworkName(existingInterfaces); for (NetworkAttachment attachment : attachmentsToConfigure){ if (!mustAttachementBeCheckedForBondMode(attachment, hostInterfacesByNetworkName)){ continue; } Bond modifiedOrNewBond = bondsMap.get(attachment.getNicName()); ValidationResult validationResult = checkBondMode(attachment, modifiedOrNewBond); if (!validationResult.isValid()){ return validationResult; } } return ValidationResult.VALID; }
Source:
<code><START> public void checkAlwaysTransitionHasLowestPriority(RegularState state) { <END> Iterator<Transition> iterator = state.getOutgoingTransitions().iterator(); while (iterator.hasNext()) { Transition transition = iterator.next(); Trigger trigger = transition.getTrigger(); if (trigger instanceof DefaultTrigger && iterator.hasNext()) { warning(String.format(ALWAYS_TRUE_TRANSITION_USED, transition.getSpecification()), transition, null, -1); } else if (trigger instanceof ReactionTrigger) { ReactionTrigger reactTrigger = (ReactionTrigger) trigger; EList<EventSpec> triggers = reactTrigger.getTriggers(); if (triggers.size() == 1 && reactTrigger.getGuard() == null) { EventSpec eventSpec = triggers.get(0); if (eventSpec instanceof AlwaysEvent && iterator.hasNext()) { warning(String.format(ALWAYS_TRUE_TRANSITION_USED, getTransitionDeclaration(transition)), transition, null, -1); } } } } }</code><technical_language>add warnings for transitions priority. message like: ' Dead transition. This transition due previous transition '%s' trigger</technical_language>

Target:
public void checkAlwaysTransitionHasLowestPriority(RegularState state) { Iterator<Transition> iterator = state.getOutgoingTransitions().iterator(); Transition deadTransition = null; while (iterator.hasNext()) { Transition transition = iterator.next(); Trigger trigger = transition.getTrigger(); if (deadTransition != null) { warning(String.format(DEAD_TRANSITION, getTransitionDeclaration(deadTransition)), transition, null, -1); } if (trigger instanceof DefaultTrigger && iterator.hasNext()) { warning(String.format(ALWAYS_TRUE_TRANSITION_USED, transition.getSpecification()), transition, null, -1); if(deadTransition == null) { deadTransition = transition; } } else if (trigger instanceof ReactionTrigger) { ReactionTrigger reactTrigger = (ReactionTrigger) trigger; EList<EventSpec> triggers = reactTrigger.getTriggers(); if (triggers.size() == 1 && reactTrigger.getGuard() == null) { EventSpec eventSpec = triggers.get(0); if (eventSpec instanceof AlwaysEvent && iterator.hasNext()) { warning(String.format(ALWAYS_TRUE_TRANSITION_USED, getTransitionDeclaration(transition)), transition, null, -1); if(deadTransition == null) { deadTransition = transition; } } } } } }
Source:
<code>protected Serializer<Object> locate() { if (isAvailable("io.jsonwebtoken.io.JacksonSerializer")) { return Classes.newInstance("io.jsonwebtoken.io.JacksonSerializer"); } else if (isAvailable("io.jsonwebtoken.io.OrgJsonSerializer")) { return Classes.newInstance("io.jsonwebtoken.io.OrgJsonSerializer"); <START> } else if (isAvailable("com.google.gson.GsonBuilder")) { <END> return Classes.newInstance("io.jsonwebtoken.io.GsonSerializer"); } else { throw new IllegalStateException("Unable to discover any JSON Serializer implementations on the classpath."); } }</code><technical_language>This checking for "io.jsonwebtoken.io.GsonDeserializer" "com.google.gson.GsonBuilder"</technical_language>

Target:
protected Serializer<Object> locate() { if (isAvailable("io.jsonwebtoken.io.JacksonSerializer")) { return Classes.newInstance("io.jsonwebtoken.io.JacksonSerializer"); } else if (isAvailable("io.jsonwebtoken.io.OrgJsonSerializer")) { return Classes.newInstance("io.jsonwebtoken.io.OrgJsonSerializer"); } else if (isAvailable("io.jsonwebtoken.gson.io.GsonSerializer")) { return Classes.newInstance("io.jsonwebtoken.gson.io.GsonSerializer"); } else { throw new IllegalStateException("Unable to discover any JSON Serializer implementations on the classpath."); } }
Source:
<code><START> public HashMapExecutionDags() { <END> this.map = new ConcurrentHashMap<>(); }</code><technical_language>public</technical_language>

Target:
private HashMapExecutionDags() { this.map = new ConcurrentHashMap<>(); }
Source:
<code>private void process(Id contentId) throws org.atlasapi.entity.util.WriteException { Timer.Context time = metricsTimer.time(); Resolved<Content> content = resolveContent(contentId); if (content.getResources().isEmpty()) { log.error("Failed to resolve content {}", contentId); throw new IllegalArgumentException("Failed to resolve content " + contentId); } WriteResult<Content, Content> result = writer.writeContent(content.getResources().first().get()); if (result.written()) { log.debug("Bootstrapped content {}", result.toString()); columbusTelescopeReporter.reportSuccessfulMigration( content.getResources().first().get() ); time.stop(); } else { log.debug("Content has not been written: {}", result.toString()); <START> columbusTelescopeReporter.reportFailedMigration( <END> content.getResources().first().get(), result.toString() ); contentNotWrittenMeter.mark(); } }</code><technical_language>Is unwritten content a failure? unchanged entities return false well</technical_language>

Target:
private void process(Id contentId) throws org.atlasapi.entity.util.WriteException { Timer.Context time = metricsTimer.time(); Resolved<Content> content = resolveContent(contentId); if (content.getResources().isEmpty()) { log.error("Failed to resolve content {}", contentId); throw new IllegalArgumentException("Failed to resolve content " + contentId); } WriteResult<Content, Content> result = writer.writeContent(content.getResources().first().get()); if (result.written()) { log.debug("Bootstrapped content {}", result.toString()); columbusTelescopeReporter.reportSuccessfulMigration( content.getResources().first().get() ); time.stop(); } else { log.debug("Content has not been written: {}", result.toString()); contentNotWrittenMeter.mark(); } }
Source:
<code><START> public void test_arithmetic_binary_operations() throws Exception { <END> assertThat(getSymbol("exp1").types().getUniqueKnownType()).isEqualTo(PrimitiveType.NUMBER); assertThat(getSymbol("exp2").types().getUniqueKnownType()).isEqualTo(PrimitiveType.STRING); assertThat(getSymbol("exp3").types().getUniqueKnownType()).isEqualTo(PrimitiveType.NUMBER); }</code><technical_language>@vilchik-elena test case type of operand</technical_language>

Target:
public void test_arithmetic_binary_operations() throws Exception { assertThat(getSymbol("exp1").types()).containsOnly(PrimitiveType.NUMBER); assertThat(getSymbol("exp2").types()).containsOnly(PrimitiveType.STRING); assertThat(getSymbol("exp3").types()).containsOnly(PrimitiveType.NUMBER); assertThat(getSymbol("exp5").types()).containsOnly(PrimitiveType.UNKNOWN); assertThat(getSymbol("exp6").types()).containsOnly(PrimitiveType.NUMBER); }
Source:
<code>protected void assertNoMachinesAvailableForApp(TestApplication app) { try { app.start(ImmutableList.of(pool.getDynamicLocation())); fail("Expected exception when starting app with too many entities for pool"); } catch (Exception e) { <START> Throwable t = Exceptions.getFirstThrowableOfType(e, NoMachinesAvailableException.class); <END> assertTrue(t != null, "expected " + NoMachinesAvailableException.class.getName() + " to be thrown, not found in " + e); } }</code><technical_language>I generally do if (t == null) throw e some such, get full stacktrace of exception if unexpected one</technical_language>

Target:
protected void assertNoMachinesAvailableForApp(TestApplication app) { try { app.start(ImmutableList.of(pool.getDynamicLocation())); fail("Expected exception when starting app with too many entities for pool"); } catch (Exception e) { Throwable t = Exceptions.getFirstThrowableOfType(e, NoMachinesAvailableException.class); if (t == null) { throw new RuntimeException(e); } } }
Source:
<code>public Value applyAssoc(String assocOrig) { switch (assocOrig) { case "left": return Associativity.Left(); case "right": return Associativity.Right(); case "non-assoc": return Associativity.NonAssoc(); default: <START> throw new RuntimeException("Incorrect assoc string: " + assocOrig); <END> } }</code><technical_language>I convention is AssertionError for this</technical_language>

Target:
public Value applyAssoc(String assocOrig) { switch (assocOrig) { case "left": return Associativity.Left(); case "right": return Associativity.Right(); case "non-assoc": return Associativity.NonAssoc(); default: throw new AssertionError("Incorrect assoc string: " + assocOrig); } }
Source:
<code><START> private void computeTopPaths() { <END> int cp = beginIndex; int ch = list[cp].getPathHash(); long cw = list[cp].getWeight(); totalWeight = list[cp].getWeight(); for (int i = cp + 1; i < endIndex; i++) { ObjectToPack o = list[i]; if (ch != o.getPathHash()) { if (MIN_TOP_PATH < cw) { if (topPathCnt < topPaths.length) { TopPath p = new TopPath(cw, ch, cp, i); topPaths[topPathCnt] = p; if (++topPathCnt == topPaths.length) Arrays.sort(topPaths); } else if (topPaths[0].weight < cw) { topPaths[0] = new TopPath(cw, ch, cp, i); if (topPaths[0].compareTo(topPaths[1]) > 0) Arrays.sort(topPaths); } } cp = i; ch = o.getPathHash(); cw = 0; } cw += o.getWeight(); totalWeight += o.getWeight(); } Arrays.sort(topPaths, 0, topPathCnt, new Comparator<TopPath>() { public int compare(TopPath a, TopPath b) { return a.beginIdx - b.beginIdx; } }); for (int i = 0; i < topPathCnt; i++) totalWeight -= topPaths[i].weight; }</code><technical_language>This return 2 things: List<TopPath>, List<Slice>. Then, iterator assign TopPath thread. iterate slice weight thread is met</technical_language>

Target:
private void computeTopPaths() { int cp = beginIndex; int ch = list[cp].getPathHash(); long cw = list[cp].getWeight(); totalWeight = list[cp].getWeight(); for (int i = cp + 1; i < endIndex; i++) { ObjectToPack o = list[i]; if (ch != o.getPathHash()) { if (MIN_TOP_PATH < cw) { if (topPathCnt < topPaths.length) { TopPath p = new TopPath(cw, ch, cp, i); topPaths[topPathCnt] = p; if (++topPathCnt == topPaths.length) Arrays.sort(topPaths); } else if (topPaths[0].weight < cw) { topPaths[0] = new TopPath(cw, ch, cp, i); if (topPaths[0].compareTo(topPaths[1]) > 0) Arrays.sort(topPaths); } } cp = i; ch = o.getPathHash(); cw = 0; } cw += o.getWeight(); totalWeight += o.getWeight(); } Arrays.sort(topPaths, 0, topPathCnt, new Comparator<TopPath>() { public int compare(TopPath a, TopPath b) { return a.beginIdx - b.beginIdx; } }); for (int i = 0; i < topPathCnt; i++) totalWeight -= topPaths[i].weight; System.out.println(String.format("%d top paths:", topPathCnt)); for(int i = 0; i < topPathCnt; i++) System.out.println(String.format(" %8x %5d %5d", topPaths[i].pathHash, topPaths[i].endIdx - topPaths[i].beginIdx, topPaths[i].weight)); }
Source:
<code>private LoadBalancerStats createLoadBalancerStatsFromConfig(IClientConfig clientConfig) { String loadBalancerStatsClassName = clientConfig .get(CommonClientConfigKey.NFLoadBalancerStatsClassName, LoadBalancerStats.class.getName()); try { return (LoadBalancerStats) ClientFactory.instantiateInstanceWithClientConfig( loadBalancerStatsClassName, clientConfig); } catch (Exception e) { <START> throw new RuntimeException("Error initializing LoadBalancerStats", e); <END> } }</code><technical_language>instead of throwing a RuntimeException, more compatible if fallback emitting a WARN log create stats class existing new LoadBalancerStats(clientName)</technical_language>

Target:
private LoadBalancerStats createLoadBalancerStatsFromConfig(IClientConfig clientConfig) { String loadBalancerStatsClassName = clientConfig .get(CommonClientConfigKey.NFLoadBalancerStatsClassName, LoadBalancerStats.class.getName()); try { return (LoadBalancerStats) ClientFactory.instantiateInstanceWithClientConfig( loadBalancerStatsClassName, clientConfig); } catch (Exception e) { logger.warn("Error initializing configured LoadBalancerStats class - " + String.valueOf(loadBalancerStatsClassName) + ". Falling-back to a new LoadBalancerStats instance instead.", e); return new LoadBalancerStats(clientConfig.getClientName()); } }
Source:
<code>boolean isInTokenModeNeeded(boolean needTokensForGII, boolean needRIDestroyToken) { <START> return (needTokensForGII || needRIDestroyToken) && !getConcurrencyChecksEnabled(); <END> }</code><technical_language>Small change, swap check around? evaluate ConcurrencyCheck. this check a greater chance short circuit conditional sooner</technical_language>

Target:
boolean isInTokenModeNeeded(boolean needTokensForGII, boolean needRIDestroyToken) { return !getConcurrencyChecksEnabled() && (needTokensForGII || needRIDestroyToken); }
Source:
<code>public Mediator createSpecificMediator(OMElement omElement, Properties properties) { BamMediator bam = new BamMediator(); if (StringUtils.isEmpty(this.getServerProfileName(omElement))) { handleException("BAM Mediator : Server Profile Name can not be empty"); } else if (StringUtils.isEmpty(this.getStreamName(omElement))) { handleException("BAM Mediator : Stream Name can not be empty"); } else if (StringUtils.isEmpty(this.getStreamVersion(omElement))) { <START> handleException("BAM Mediator : Stream Version can not be empty"); <END> } bam.setServerProfile(this.getServerProfileName(omElement)); bam.getStream().setStreamConfiguration(new StreamConfiguration()); bam.getStream().getStreamConfiguration().setName(this.getStreamName(omElement)); bam.getStream().getStreamConfiguration().setVersion(this.getStreamVersion(omElement)); return bam; }</code><technical_language>simply String.isEmpty() for checking string is empty</technical_language>

Target:
public Mediator createSpecificMediator(OMElement omElement, Properties properties) { BamMediator bam = new BamMediator(); String serverProfilePath = SERVER_PROFILE_LOCATION + "/" + this.getServerProfileName(omElement); String streamName = this.getStreamName(omElement); String streamVersion = this.getStreamVersion(omElement); if (isNotNullOrEmpty(serverProfilePath) && isNotNullOrEmpty(streamName) && isNotNullOrEmpty(streamVersion)) { bam.setServerProfile(serverProfilePath); bam.getStream().setStreamConfiguration(new StreamConfiguration()); bam.getStream().getStreamConfiguration().setName(streamName); bam.getStream().getStreamConfiguration().setVersion(streamVersion); } return bam; }
Source:
<code><START> public void testHostPortArgsDefault() throws Exception { <END> KafkaExternalLoaderCLIArguments args = new KafkaExternalLoaderCLIArguments(); args.parse("KafaExternalLoader", new String[] { "-z", "localhost:2181", "-t", "volt-topic", "KAFKA_IMPORT" } ); List<String> hosts = args.getVoltHosts(); Assert.assertEquals(Arrays.asList(new String[]{"localhost:21212"}), hosts); StringWriter sw = new StringWriter(); args = new KafkaExternalLoaderCLIArguments(new PrintWriter(sw)); args.parse("KafaExternalLoader", new String[] { "--servers", "host1:100,host2:200", "--host", "host3,host4", "-z", "localhost:2181", "-t", "volt-topic", "KAFKA_IMPORT" } ); hosts = args.getVoltHosts(); Assert.assertEquals(Arrays.asList(new String[]{"host3:21212", "host4:21212"}), hosts); Assert.assertTrue(sw.toString().startsWith("Warning: --servers argument is deprecated; please use --host instead")); }</code><technical_language>Do need tests this for legacy loader</technical_language>

Target:
public void testHostPortArgsDefault() throws Exception { KafkaExternalLoaderCLIArguments args = new KafkaExternalLoaderCLIArguments(); args.parse("KafaExternalLoader", new String[] { "-z", "localhost:2181", "-t", "volt-topic", "KAFKA_IMPORT" } ); List<String> hosts = args.getVoltHosts(); Assert.assertEquals(Arrays.asList(new String[]{"localhost:21212"}), hosts); StringWriter sw = new StringWriter(); args = new KafkaExternalLoaderCLIArguments(new PrintWriter(sw)); args.parse("KafaExternalLoader", new String[] { "--servers", "host1:100,host2:200", "--host", "host3,host4", "-z", "localhost:2181", "-t", "volt-topic", "KAFKA_IMPORT" } ); hosts = args.getVoltHosts(); Assert.assertEquals(Arrays.asList(new String[]{"host3:21212", "host4:21212"}), hosts); System.out.println(sw.toString()); Assert.assertTrue(sw.toString().startsWith("Warning: --servers argument is deprecated in favor of --host; value is ignored.")); }
Source:
<code><START> public void testArrayPrependFunction23() throws Exception { <END> Object[] o = new Object[270]; for (int i = 0; i < o.length - 2; i++) o[i] = null; o[o.length - 2] = "1"; o[o.length - 1] = "2"; Object[] o2 = new Object[271]; for (int i = 0; i < o2.length - 2; i++) o2[i] = null; o2[o2.length - 2] = "1"; o2[o2.length - 1] = "2"; Object element = null; PDataType baseType = PVarchar.INSTANCE; PhoenixArray arr = new PhoenixArray(baseType, o); PhoenixArray expected = new PhoenixArray(baseType, o2); test(arr, element, PDataType.fromTypeId(baseType.getSqlType() + PDataType.ARRAY_TYPE_BASE), null, null, baseType, 1, null, expected, SortOrder.ASC, SortOrder.DESC); }</code><technical_language>Good</technical_language>

Target:
public void testArrayPrependFunction23() throws Exception { byte[][] o = new byte[][]{new byte[]{2, 3}, new byte[]{42, 3}, new byte[]{5, 3}, new byte[]{6, 3}, new byte[]{2, 5}}; byte[][] o2 = new byte[][]{new byte[]{5, 6}, new byte[]{2, 3}, new byte[]{42, 3}, new byte[]{5, 3}, new byte[]{6, 3}, new byte[]{2, 5}}; byte[] element = new byte[]{5, 6}; PDataType baseType = PBinary.INSTANCE; PhoenixArray arr = new PhoenixArray(baseType, o); PhoenixArray expected = new PhoenixArray(baseType, o2); test(arr, element, PDataType.fromTypeId(baseType.getSqlType() + PDataType.ARRAY_TYPE_BASE), 2, null, baseType, 1, null, expected, SortOrder.ASC, SortOrder.DESC); }
Source:
<code>public void testIdMismatchFails() throws Exception { final Job job = new Job(JobId.fromString("foo:bar:badf00d"), "bar", EMPTY_COMMAND, EMPTY_ENV, EMPTY_PORTS, EMPTY_REGISTRATION, <START> EMPTY_VOLUMES, ""); <END> final JobId recomputedId = job.toBuilder().build().getId(); assertEquals(ImmutableSet.of("Id hash mismatch: " + job.getId().getHash() + " != " + recomputedId.getHash()), validator.validate(job)); }</code><technical_language>a NO_DOMAIN constant instead of a literal empty string</technical_language>

Target:
public void testIdMismatchFails() throws Exception { final Job job = new Job(JobId.fromString("foo:bar:badf00d"), "bar", EMPTY_COMMAND, EMPTY_ENV, EMPTY_PORTS, EMPTY_REGISTRATION, EMPTY_VOLUMES, EMPTY_EXPIRES, EMPTY_REGISTRATION_DOMAIN); final JobId recomputedId = job.toBuilder().build().getId(); assertEquals(ImmutableSet.of("Id hash mismatch: " + job.getId().getHash() + " != " + recomputedId.getHash()), validator.validate(job)); }
Source:
<code><START> public void checkLoginFailedMessage() { waitForElementToBeDisplayed(R.id.alertTitle); } <END></code><technical_language>this is similar isLoginFailed() method below; is needed</technical_language>

Target:
public void checkLoginFailedMessage() { waitForElementToBeDisplayed(ALERT_LOGIN); }
Source:
<code>ContactPopMenu(ContactTreeRootNode.ContactInfo contactInfo) { this.contactInfo = contactInfo; SarosPluginContext.initComponent(this); <START> JMenu menuShareProject = new JMenu("Work together on..."); <END> menuShareProject.setIcon(IconManager.SESSIONS_ICON); List<String> nonCompliantModules = new ArrayList<>(); for (Project project : ProjectManager.getInstance().getOpenProjects()) { Pair<JMenu, List<String>> results = prepareProjectMenu(project); if (results == null) { return; } JMenu projectMenu = results.first; List<String> projectNonCompliantModules = results.second; menuShareProject.add(projectMenu); if (!projectNonCompliantModules.isEmpty()) { nonCompliantModules.addAll(projectNonCompliantModules); } } if (!nonCompliantModules.isEmpty()) { NotificationPanel.showWarning( MessageFormat.format( Messages.Contact_saros_message_conditional, MessageFormat.format( Messages.ContactPopMenu_invalid_module_message_condition, nonCompliantModules)), Messages.ContactPopMenu_invalid_module_title); } add(menuShareProject); }</code><technical_language>do a constant string instead of storing menu title in messages.properties</technical_language>

Target:
ContactPopMenu(ContactTreeRootNode.ContactInfo contactInfo) { this.contactInfo = contactInfo; JMenu menuShareProject = new JMenu(Messages.ContactPopMenu_root_popup_text); menuShareProject.setIcon(IconManager.SESSIONS_ICON); List<String> nonCompliantModules = new ArrayList<>(); for (Project project : ProjectManager.getInstance().getOpenProjects()) { Pair<JMenu, List<String>> results = prepareProjectMenu(project); if (results == null) { return; } JMenu projectMenu = results.first; List<String> projectNonCompliantModules = results.second; menuShareProject.add(projectMenu); if (!projectNonCompliantModules.isEmpty()) { nonCompliantModules.addAll(projectNonCompliantModules); } } if (!nonCompliantModules.isEmpty()) { NotificationPanel.showWarning( MessageFormat.format( Messages.Contact_saros_message_conditional, MessageFormat.format( Messages.ContactPopMenu_invalid_module_message_condition, nonCompliantModules)), Messages.ContactPopMenu_invalid_module_title); } add(menuShareProject); }
Source:
<code>private void backup() throws IOException { <START> if (streamIDs.isEmpty()) { <END> log.warn("back up is called with empty streamIDs!"); } for (UUID streamId : streamIDs) { if (!tableExists(streamId)) { log.warn("cannot back up a non-existent table: {}", streamId); continue; } String fileName = backupTempDirPath + File.separator + streamId; backupTable(fileName, streamId); } log.info("successfully backed up tables to directory", streamIDs.size(), backupTempDirPath); }</code><technical_language>add a null check aslo</technical_language>

Target:
private void backup() throws IOException { if (streamIDs.isEmpty()) { log.warn("back up is called with empty streamIDs!"); return; } for (UUID streamId : streamIDs) { if (!tableExists(streamId)) { log.warn("cannot back up a non-existent table: {}", streamId); continue; } String fileName = backupTempDirPath + File.separator + streamId; backupTable(fileName, streamId); } log.info("successfully backed up tables to directory", streamIDs.size(), backupTempDirPath); }
Source:
<code>public String[] getProtocolsMask(long noOpt) { <START> ctx.setOptions(noOpt); <END> return WolfSSL.getProtocolsMask(noOpt); }</code><technical_language>handle case "ctx" is null here. Consider returning null throwing a IllegalStateException similar other methods in WolfSSLContext.java do</technical_language>

Target:
public String[] getProtocolsMask(long noOpt) { if(ctx != null) ctx.setOptions(noOpt); return WolfSSL.getProtocolsMask(noOpt); }
Source:
<code>public static Runnable wrap(final Runnable runnable) { final Map<WeakReference<? extends ExecutorInheritableThreadLocal<?>>, Object> mapForNewThread = ExecutorInheritableThreadLocal.getMapForNewThread(); Runnable wrappedRunnable = Tracers.wrap(new Runnable() { @Override public void run() { ConcurrentMap<WeakReference<? extends ExecutorInheritableThreadLocal<?>>, Object> oldMap = ExecutorInheritableThreadLocal.installMapOnThread(mapForNewThread); try { runnable.run(); <START> } finally { <END> ExecutorInheritableThreadLocal.uninstallMapOnThread(oldMap); } } }); if (runnable instanceof Future<?>) { @SuppressWarnings("unchecked") Future<Object> unsafeFuture = (Future<Object>) runnable; return new ForwardingRunnableFuture<Object>(wrappedRunnable, unsafeFuture); } return wrappedRunnable; }</code><technical_language>wanted highlight changing super.run() runnable.run(). I this is fine, ForwardingRunnableFuture.run calls runnable.run()</technical_language>

Target:
public static Runnable wrap(final Runnable runnable) { Runnable wrappedRunnable = wrapRunnable(runnable); if (runnable instanceof Future<?>) { @SuppressWarnings("unchecked") Future<Object> unsafeFuture = (Future<Object>) runnable; return new ForwardingRunnableFuture<>(wrappedRunnable, unsafeFuture); } return wrappedRunnable; }
Source:
<code>protected static void configureScanner(Job job, Node query, GlobalIndexVisitor globalInexVisitor, TypeRegistry<String> typeRegistry) throws AccumuloSecurityException, AccumuloException, TableNotFoundException { QueryOptimizer optimizer = new QueryOptimizer(query, globalInexVisitor, typeRegistry); NodeToJexl nodeToJexl = new NodeToJexl(typeRegistry); String jexl = nodeToJexl.transform(optimizer.getOptimizedQuery()); String originalJexl = nodeToJexl.transform(query); Collection<Range> ranges = new ArrayList<Range>(); if(jexl.equals("()") || jexl.equals("")) { ranges.add(new Range(END_BYTE)); } else { for (String shard : optimizer.getShards()) ranges.add(new Range(shard)); } setRanges(job, ranges); IteratorSetting setting = new IteratorSetting(16, OptimizedQueryIterator.class); setting.addOption(BooleanLogicIterator.QUERY_OPTION, originalJexl); setting.addOption(BooleanLogicIterator.FIELD_INDEX_QUERY, jexl); final String[] selectFields = job.getConfiguration().getStrings("selectFields"); <START> setting.addOption("auths", getScanAuthorizations(job).serialize()); <END> if (selectFields != null && selectFields.length > 0) { IteratorSetting iteratorSetting = new IteratorSetting(16, SelectFieldsExtractor.class); SelectFieldsExtractor.setSelectFields(iteratorSetting, new HashSet<String>(Arrays.asList(selectFields))); } addIterator(job, setting); }</code><technical_language>"auths" a public constant exposed OptimizedQueryIterator class here</technical_language>

Target:
protected static void configureScanner(Job job, Node query, GlobalIndexVisitor globalInexVisitor, TypeRegistry<String> typeRegistry) throws AccumuloSecurityException, AccumuloException, TableNotFoundException { QueryOptimizer optimizer = new QueryOptimizer(query, globalInexVisitor, typeRegistry); NodeToJexl nodeToJexl = new NodeToJexl(typeRegistry); String jexl = nodeToJexl.transform(optimizer.getOptimizedQuery()); String originalJexl = nodeToJexl.transform(query); Collection<Range> ranges = new ArrayList<Range>(); if(jexl.equals("()") || jexl.equals("")) { ranges.add(new Range(END_BYTE)); } else { for (String shard : optimizer.getShards()) ranges.add(new Range(shard)); } setRanges(job, ranges); IteratorSetting setting = new IteratorSetting(16, OptimizedQueryIterator.class); setting.addOption(BooleanLogicIterator.QUERY_OPTION, originalJexl); setting.addOption(BooleanLogicIterator.FIELD_INDEX_QUERY, jexl); final String[] selectFields = job.getConfiguration().getStrings(SELECT_FIELDS); if (selectFields != null && selectFields.length > 0) { IteratorSetting iteratorSetting = new IteratorSetting(16, SelectFieldsExtractor.class); SelectFieldsExtractor.setSelectFields(iteratorSetting, new HashSet<String>(Arrays.asList(selectFields))); } addIterator(job, setting); }
Source:
<code>private static JsonObject fork( <START> final String organization) throws Exception { <END> return Json.createObjectBuilder() .add("id", 1) .add(ORGANIZATION, organization) .build(); }</code><technical_language>I Exception thrown this method</technical_language>

Target:
private static JsonObject fork( final String organization) { return Json.createObjectBuilder() .add("id", 1) .add(ORGANIZATION, organization) .build(); }
Source:
<code><START> protected ImmutableList<String> getAllImports( <END> final Ds3Request ds3Request, final String packageName) { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); if (isSpectraDs3(packageName)) { builder.add(getParentImport(ds3Request)); } builder.addAll(getImportsFromParamList(ds3Request.getRequiredQueryParams())); builder.addAll(getImportsFromParamList(ds3Request.getOptionalQueryParams())); if (isResourceAnArg(ds3Request.getResource(), ds3Request.includeIdInPath()) && RequestConverterUtil.isResourceId(ds3Request.getResource())) { builder.add("java.util.UUID"); } return builder.build().asList(); }</code><technical_language>This static</technical_language>

Target:
public ImmutableList<String> getAllImports( final Ds3Request ds3Request, final String packageName) { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); if (isSpectraDs3(packageName)) { builder.add(getParentImport(ds3Request)); } builder.addAll(getImportsFromParamList(ds3Request.getRequiredQueryParams())); builder.addAll(getImportsFromParamList(ds3Request.getOptionalQueryParams())); if (isResourceAnArg(ds3Request.getResource(), ds3Request.includeIdInPath()) && RequestConverterUtil.isResourceId(ds3Request.getResource())) { builder.add("java.util.UUID"); } return builder.build().asList(); }