auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private List<Instructor> getInstructorEntitiesForGoogleId(String googleId, boolean omitArchived) { if (omitArchived) { Query q = getPM().newQuery(Instructor.class); q.declareParameters("String googleIdParam, boolean omitArchivedParam"); q.setFilter("googleId == googleIdParam && isArchived != omitArchivedParam"); @SuppressWarnings("unchecked") List<Instructor> instructorList = (List<Instructor>) q.execute(googleId, omitArchived); System.out.println("1- " + instructorList.size()); System.out.println("2- " + getInstructorEntitiesForGoogleId(googleId).size()); return instructorList; } else { <START> return getInstructorEntitiesForGoogleId(googleId); <END> } }</code><technical_language>Consider writing shorter branch first. Readability is if else closer</technical_language>

Target:
private List<Instructor> getInstructorEntitiesForGoogleId(String googleId, boolean omitArchived) { if (!omitArchived) { return getInstructorEntitiesForGoogleId(googleId); } else { Query q = getPM().newQuery(Instructor.class); q.declareParameters("String googleIdParam, boolean omitArchivedParam"); q.setFilter("googleId == googleIdParam && isArchived != omitArchivedParam"); @SuppressWarnings("unchecked") List<Instructor> instructorList = (List<Instructor>) q.execute(googleId, omitArchived); return instructorList; } }
Source:
<code>private NewSymbolTable newSymbolTable(String filename) { File moduleBaseDir = new File("src/test/resources/highlighter/"); sensorContext = SensorContextTester.create(moduleBaseDir); inputFile = new DefaultInputFile("moduleKey", filename) .setModuleBaseDir(moduleBaseDir.toPath()); <START> inputFile.initMetadata(new FileMetadata().readMetadata(inputFile.file(), Charset.defaultCharset())); <END> return sensorContext.newSymbolTable().onFile(inputFile); }</code><technical_language>@vilchik-elena Charset.defaultCharset() is a bad idea. a big issue here, a charset relying system default charset</technical_language>

Target:
private NewSymbolTable newSymbolTable(String filename) { File moduleBaseDir = new File("src/test/resources/highlighter/"); sensorContext = SensorContextTester.create(moduleBaseDir); inputFile = new DefaultInputFile("moduleKey", filename) .setModuleBaseDir(moduleBaseDir.toPath()); inputFile.initMetadata(new FileMetadata().readMetadata(inputFile.file(), Charsets.UTF_8)); return sensorContext.newSymbolTable().onFile(inputFile); }
Source:
<code><R extends RelNode> RelOptRuleOperand( Class<R> clazz, RelTrait trait, Predicate<? super R> predicate, RelOptRuleOperandChildPolicy childPolicy, ImmutableList<RelOptRuleOperand> children) { assert clazz != null; if (clazz == RelSubset.class) { assert children.size() == 0; <START> } <END> switch (childPolicy) { case ANY: break; case LEAF: assert children.size() == 0; break; case UNORDERED: assert children.size() == 1; break; default: assert children.size() > 0; } this.childPolicy = childPolicy; this.clazz = Objects.requireNonNull(clazz); this.trait = trait; this.predicate = Objects.requireNonNull((Predicate) predicate); this.children = children; for (RelOptRuleOperand child : this.children) { assert child.parent == null : "cannot re-use operands"; child.parent = this; } }</code><technical_language>need this, rule operand HepPlanner/VolcanoPlanner agnostic</technical_language>

Target:
<R extends RelNode> RelOptRuleOperand( Class<R> clazz, RelTrait trait, Predicate<? super R> predicate, RelOptRuleOperandChildPolicy childPolicy, ImmutableList<RelOptRuleOperand> children) { assert clazz != null; switch (childPolicy) { case ANY: break; case LEAF: assert children.size() == 0; break; case UNORDERED: assert children.size() == 1; break; default: assert children.size() > 0; } this.childPolicy = childPolicy; this.clazz = Objects.requireNonNull(clazz); this.trait = trait; this.predicate = Objects.requireNonNull((Predicate) predicate); this.children = children; for (RelOptRuleOperand child : this.children) { assert child.parent == null : "cannot re-use operands"; child.parent = this; } }
Source:
<code>public void testGetRoutingData() { ZNRecord testZnRecord1 = new ZNRecord("testZnRecord1"); List<String> testShardingKeys1 = Arrays.asList("/sharding/key/1/a", "/sharding/key/1/b", "/sharding/key/1/c"); testZnRecord1.setListField(ZNRECORD_LIST_FIELD_KEY, testShardingKeys1); ZNRecord testZnRecord2 = new ZNRecord("testZnRecord2"); List<String> testShardingKeys2 = Arrays.asList("/sharding/key/2/a", "/sharding/key/2/b", "/sharding/key/2/c", "/sharding/key/2/d"); testZnRecord2.setListField(ZNRECORD_LIST_FIELD_KEY, testShardingKeys2); _baseAccessor.create(ROUTING_DATA_PATH + "/testRealmAddress1", testZnRecord1, AccessOption.PERSISTENT); _baseAccessor.create(ROUTING_DATA_PATH + "/testRealmAddress2", testZnRecord2, AccessOption.PERSISTENT); <START> MetadataStoreRoutingDataReader zkRoutingDataReader = new ZkRoutingDataReader(ZK_ADDR); <END> try { Map<String, List<String>> routingData = zkRoutingDataReader.getRoutingData(); Assert.assertEquals(routingData.size(), 2); Assert.assertEquals(routingData.get("testRealmAddress1"), testShardingKeys1); Assert.assertEquals(routingData.get("testRealmAddress2"), testShardingKeys2); } catch (InvalidRoutingDataException e) { Assert.fail("Not expecting InvalidRoutingDataException"); } _baseAccessor.remove(ROUTING_DATA_PATH, AccessOption.PERSISTENT); }</code><technical_language>this a private variable reuse it? Create a @beforeClass. create a @afterClass method close ZK connections/other connected resources (such base data accessor)</technical_language>

Target:
public void testGetRoutingData() { ZNRecord testZnRecord1 = new ZNRecord("testZnRecord1"); List<String> testShardingKeys1 = Arrays.asList("/sharding/key/1/a", "/sharding/key/1/b", "/sharding/key/1/c"); testZnRecord1.setListField(ZkRoutingDataReader.ZNRECORD_LIST_FIELD_KEY, testShardingKeys1); ZNRecord testZnRecord2 = new ZNRecord("testZnRecord2"); List<String> testShardingKeys2 = Arrays.asList("/sharding/key/2/a", "/sharding/key/2/b", "/sharding/key/2/c", "/sharding/key/2/d"); testZnRecord2.setListField(ZkRoutingDataReader.ZNRECORD_LIST_FIELD_KEY, testShardingKeys2); _baseAccessor.create(ZkRoutingDataReader.ROUTING_DATA_PATH + "/testRealmAddress1", testZnRecord1, AccessOption.PERSISTENT); _baseAccessor.create(ZkRoutingDataReader.ROUTING_DATA_PATH + "/testRealmAddress2", testZnRecord2, AccessOption.PERSISTENT); MetadataStoreRoutingDataReader zkRoutingDataReader = new ZkRoutingDataReader(ZK_ADDR); try { Map<String, List<String>> routingData = zkRoutingDataReader.getRoutingData(); Assert.assertEquals(routingData.size(), 2); Assert.assertEquals(routingData.get("testRealmAddress1"), testShardingKeys1); Assert.assertEquals(routingData.get("testRealmAddress2"), testShardingKeys2); } catch (InvalidRoutingDataException e) { Assert.fail("Not expecting InvalidRoutingDataException"); } }
Source:
<code><START> public static Command<Void> continueInterceptedRequest(InterceptionId interceptionId, Optional<ErrorReason> errorReason, Optional<String> rawResponse, <END> Optional<String> url, Optional<String> method, Optional<String> postData, Optional<Map<String, String>> headers, Optional<AuthChallengeResponse> authChallengeResponse) { Objects.requireNonNull(interceptionId, "interceptionId must be set."); Map<String, Object> params = new HashMap<>(); params.put("interceptionId", interceptionId); errorReason.ifPresent(reason -> params.put("errorReason", errorReason)); errorReason.ifPresent(string -> params.put("rawResponse", rawResponse)); errorReason.ifPresent(string -> params.put("url", url)); errorReason.ifPresent(string -> params.put("method", method)); errorReason.ifPresent(string -> params.put("postData", postData)); errorReason.ifPresent(map -> params.put("headers", headers)); errorReason.ifPresent(response -> params.put("authChallengeResponse", authChallengeResponse)); return new Command<>(domainName + ".continueInterceptedRequest", params); }</code><technical_language>Nit: coding style for project slowly moving "one param line if line length limit" (line length limit is ~120 chars)</technical_language>

Target:
public static Command<Void> continueInterceptedRequest(InterceptionId interceptionId, Optional<ErrorReason> errorReason, Optional<String> rawResponse, Optional<String> url, Optional<String> method, Optional<String> postData, Optional<Map<String, String>> headers, Optional<AuthChallengeResponse> authChallengeResponse) { Objects.requireNonNull(interceptionId, "interceptionId must be set."); final ImmutableMap.Builder<String, Object> params = ImmutableMap.builder(); params.put("interceptionId", interceptionId.toString()); errorReason.ifPresent(reason -> params.put("errorReason", errorReason.get().name())); rawResponse.ifPresent(string -> params.put("rawResponse", rawResponse.toString())); url.ifPresent(string -> params.put("url", url.toString())); method.ifPresent(string -> params.put("method", method.toString())); postData.ifPresent(string -> params.put("postData", postData.toString())); headers.ifPresent(map -> params.put("headers", headers)); authChallengeResponse.ifPresent(response -> params.put("authChallengeResponse", authChallengeResponse)); return new Command<>(DOMAIN_NAME + ".continueInterceptedRequest", params.build()); }
Source:
<code>public GraphicsProperties() { <START> vendor = "Unknown"; <END> renderer = "Unknown"; openGLVersion = "Unsupported"; vulkanVersion = "Unsupported"; }</code><technical_language>this.vendor, for values</technical_language>

Target:
public GraphicsProperties() { this.vendor = "Unknown"; this.renderer = "Unknown"; this.openglVersion = "Unsupported"; this.openglCoreVersion = "Unsupported"; this.vulkanVersion = "Unsupported"; }
Source:
<code>public static Test suite() throws Exception { WysiwygTestSuite suite = new WysiwygTestSuite("WYSIWYG Selenium Tests", ColibriSkinExecutor.class); addTestCase(suite, SubmitTest.class); addTestCase(suite, StandardFeaturesTest.class); addTestCase(suite, HistoryTest.class); addTestCase(suite, LineTest.class); addTestCase(suite, TableTest.class); addTestCase(suite, LinkTest.class); addTestCase(suite, ListTest.class); addTestCase(suite, MacroTest.class); addTestCase(suite, ImageTest.class); addTestCase(suite, TabsTest.class); addTestCase(suite, NativeJavaScriptApiTest.class); addTestCase(suite, ColorTest.class); addTestCase(suite, AlignmentTest.class); addTestCase(suite, RemoveFormattingTest.class); addTestCase(suite, FontTest.class); addTestCase(suite, CacheTest.class); addTestCase(suite, RegularUserTest.class); addTestCase(suite, ImportTest.class); addTestCase(suite, EmbedTest.class); addTestCase(suite, EditInlineTest.class); <START> addTestCase(suite, ShortCutsTest.class); <END> return new XWikiSeleniumTestSetup(new XWikiTestSetup(new WysiwygTestSetup(suite))); }</code><technical_language>"Shortcut" is a word camel-case it. Anyway, grouped tests based functionality testing. For instance put tests for macro shortcut keys in MacroTest in a separate test case for shortcut keys. I I prefer tests SubmitTest because, all, testing submit is triggered a shortcut key</technical_language>

Target:
public static Test suite() throws Exception { WysiwygTestSuite suite = new WysiwygTestSuite("WYSIWYG Selenium Tests", ColibriSkinExecutor.class); addTestCase(suite, SubmitTest.class); addTestCase(suite, StandardFeaturesTest.class); addTestCase(suite, HistoryTest.class); addTestCase(suite, LineTest.class); addTestCase(suite, TableTest.class); addTestCase(suite, LinkTest.class); addTestCase(suite, ListTest.class); addTestCase(suite, MacroTest.class); addTestCase(suite, ImageTest.class); addTestCase(suite, TabsTest.class); addTestCase(suite, NativeJavaScriptApiTest.class); addTestCase(suite, ColorTest.class); addTestCase(suite, AlignmentTest.class); addTestCase(suite, RemoveFormattingTest.class); addTestCase(suite, FontTest.class); addTestCase(suite, CacheTest.class); addTestCase(suite, RegularUserTest.class); addTestCase(suite, ImportTest.class); addTestCase(suite, EmbedTest.class); addTestCase(suite, EditInlineTest.class); return new XWikiSeleniumTestSetup(new XWikiTestSetup(new WysiwygTestSetup(suite))); }
Source:
<code>public BoltConnectionElementBeanInfo() { super(BoltConnectionElement.class); createPropertyGroup("connection", new String[] { "boltUri", "username", "password" }); PropertyDescriptor propertyDescriptor = property("boltUri"); propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE); propertyDescriptor.setValue(DEFAULT, "bolt://localhost:7687"); propertyDescriptor = property("username"); propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE); propertyDescriptor.setValue(DEFAULT, "neo4j"); propertyDescriptor = property("password", TypeEditor.PasswordEditor); propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE); propertyDescriptor.setValue(DEFAULT, ""); if(log.isDebugEnabled()) { <START> for (PropertyDescriptor pd : getPropertyDescriptors()) { <END> log.debug(pd.getName()); log.debug(pd.getDisplayName()); } } }</code><technical_language>merge this in a single log</technical_language>

Target:
public BoltConnectionElementBeanInfo() { super(BoltConnectionElement.class); createPropertyGroup("connection", new String[] { "boltUri", "username", "password" }); PropertyDescriptor propertyDescriptor = property("boltUri"); propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE); propertyDescriptor.setValue(DEFAULT, "bolt://localhost:7687"); propertyDescriptor = property("username"); propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE); propertyDescriptor.setValue(DEFAULT, "neo4j"); propertyDescriptor = property("password", TypeEditor.PasswordEditor); propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE); propertyDescriptor.setValue(DEFAULT, ""); if(log.isDebugEnabled()) { String descriptorsAsString = Arrays.stream(getPropertyDescriptors()) .map(pd -> pd.getName() + "=" + pd.getDisplayName()) .collect(Collectors.joining(" ,")); log.debug(descriptorsAsString); } }
Source:
<code><START> public synchronized double getPreviousDisconnectionTimestamp() { <END> return previousDisconnectionTimestamp; }</code><technical_language>case for this</technical_language>

Target:
public double getPreviousDisconnectionTimestamp() { return previousDisconnectionTimestamp; }
Source:
<code>public List<AbstractProject<?,?>> getJobList(ItemGroup context, EnvVars buildEnvironment) { List<AbstractProject<?,?>> r = new ArrayList<AbstractProject<?,?>>(); <START> String expandedJobs = getExpandedJobs(jobs, buildEnvironment); <END> for (String name : Util.tokenize(expandedJobs,",")) { AbstractProject job = Hudson.getInstance().getItem(name.trim(), context, AbstractProject.class); if(job!=null) r.add(job); } return r; }</code><technical_language>This change a security risk, allow injecting arbitrary job names</technical_language>

Target:
public List<AbstractProject<?,?>> getJobList(ItemGroup context, EnvVars buildEnvironment) { List<AbstractProject<?,?>> r = new ArrayList<AbstractProject<?,?>>(); String expandedJobs = getExpandedJobs(jobs, buildEnvironment); if (expandedJobs == null) return r; for (String name : Util.tokenize(expandedJobs,",")) { AbstractProject job = JenkinsHelper.getInstance().getItem(name.trim(), context, AbstractProject.class); if(job!=null) r.add(job); } return r; }
Source:
<code>public void setCollections(final Set<String> collections) { <START> this.collections = collections != null ? new TreeSet<>(collections) : null; <END> }</code><technical_language>Avoid logic in this class</technical_language>

Target:
public void setCollections(final Set<String> collections) { this.collections = collections; }
Source:
<code>public void downloadBlob(String container, String name, File destination, ExecutorService executor) { ListeningExecutorService listeningExecutor = MoreExecutors.listeningDecorator(executor); RandomAccessFile raf = null; try { long contentLength = api .getObjectApi(regionId, container) .getWithoutBody(name) .getPayload() .getContentMetadata() .getContentLength(); raf = new RandomAccessFile(destination.getAbsoluteFile(), "rw"); raf.seek(contentLength - 1); raf.write(0); long partSize = getMinimumMultipartPartSize(); long from; long to; List<ListenableFuture<Void>> results = new ArrayList<ListenableFuture<Void>>(); for (from = 0; from < contentLength; from = from + partSize) { to = (from + partSize >= contentLength) ? contentLength - 1 : from + partSize - 1; BlobDownloader b = new BlobDownloader(regionId, container, name, raf, from, to); results.add(listeningExecutor.submit(b)); } Futures.getUnchecked(Futures.allAsList(results)); <START> raf.close(); <END> } catch (IOException e) { if (raf != null) { try { raf.close(); } catch (IOException e1) } destination.delete(); throw new RuntimeException(e); } finally { if (raf != null) { try { raf.close(); } catch (IOException e1) } } }</code><technical_language>This is redundant; reach finally block immediately</technical_language>

Target:
public void downloadBlob(String container, String name, File destination, ExecutorService executor) { ListeningExecutorService listeningExecutor = MoreExecutors.listeningDecorator(executor); RandomAccessFile raf = null; try { long contentLength = api .getObjectApi(regionId, container) .getWithoutBody(name) .getPayload() .getContentMetadata() .getContentLength(); raf = new RandomAccessFile(destination.getAbsoluteFile(), "rw"); raf.seek(contentLength - 1); raf.write(0); long partSize = getMinimumMultipartPartSize(); long from; long to; List<ListenableFuture<Void>> results = new ArrayList<ListenableFuture<Void>>(); for (from = 0; from < contentLength; from = from + partSize) { to = (from + partSize >= contentLength) ? contentLength - 1 : from + partSize - 1; BlobDownloader b = new BlobDownloader(regionId, container, name, raf, from, to); results.add(listeningExecutor.submit(b)); } Futures.getUnchecked(Futures.allAsList(results)); } catch (IOException e) { Closeables2.closeQuietly(raf); destination.delete(); throw new RuntimeException(e); } finally { Closeables2.closeQuietly(raf); } }
Source:
<code><START> public org.infinispan.configuration.cache.Configuration greetingCache() { <END> return new ConfigurationBuilder() .eviction().strategy(EvictionStrategy.LRU).maxEntries(4) .build(); }</code><technical_language>I wanna "noisy" full class name in methods this class</technical_language>

Target:
public Configuration greetingCache() { return new ConfigurationBuilder() .eviction().strategy(EvictionStrategy.LRU).maxEntries(4) .build(); }
Source:
<code>public void removeMember(final Group group, final User user) { ArrayList<Role> groupRoles = newArrayList(group.getRoles()); final RoleMembership member = roleMembershipService.getMemberships(groupRoles) .stream() .filter(m -> m.getUser().getId().equals(user.getId())) .findFirst() .orElseThrow(() -> new UnknownEntityException( <START> roleMembershipMetadata, <END> roleMembershipMetadata.getAttribute( RoleMembershipMetadata.USER), user.getUsername())); roleMembershipService.removeMembership(member); }</code><technical_language>i argue this clearer before, chained is should</technical_language>

Target:
public void removeMember(final Group group, final User user) { ArrayList<Role> groupRoles = newArrayList(group.getRoles()); final RoleMembership membership = findRoleMembership(user, groupRoles); roleMembershipService.removeMembership(membership); }
Source:
<code>public static LocalInstance startLocalInstance(String applicationKey, ExecutorService exec) throws IOException { final ServerSocketChannel channel = ServerSocketChannel.open(); channel.configureBlocking(false); channel.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); final int port = ((InetSocketAddress) channel.getLocalAddress()).getPort(); Preferences.userNodeForPackage(Main.class).putInt(applicationKey, port); LOG.info("InstanceManager bound to port {}", port); Selector selector = Selector.open(); channel.register(selector, SelectionKey.OP_ACCEPT); LocalInstance instance = new LocalInstance(applicationKey) { @Override public void close() { <START> try { <END> selector.close(); } catch (IOException e) { LOG.error("error closing socket", e); } try { channel.close(); } catch (IOException e) { LOG.error("error closing selector", e); } if (getSavedPort(applicationKey).orElse(-1).equals(port)) { Preferences.userNodeForPackage(Main.class).remove(applicationKey); } } }; exec.submit(() -> { try { final Set<SelectionKey> keysToRemove = new HashSet<>(); while (selector.select() > 0) { final Set<SelectionKey> keys = selector.selectedKeys(); for (SelectionKey key : keys) { if (Thread.interrupted()) { return; } try { if (key.isAcceptable()) { final SocketChannel accepted = channel.accept(); if (accepted != null) { LOG.info("accepted incoming connection"); accepted.configureBlocking(false); accepted.register(selector, SelectionKey.OP_READ | SelectionKey.OP_WRITE); } } instance.handle(key); } catch (IOException | IllegalStateException e) { LOG.error("exception in selector", e); } finally { keysToRemove.add(key); } } keys.removeAll(keysToRemove); } } catch (ClosedSelectorException e) { return; } catch (Throwable e) { LOG.error("error while selecting", e); } }); return instance; }</code><technical_language>IOUtils.closeQuietly(...)</technical_language>

Target:
public static LocalInstance startLocalInstance(String applicationKey, ExecutorService exec) throws IOException { final ServerSocketChannel channel = ServerSocketChannel.open(); channel.configureBlocking(false); channel.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); final int port = ((InetSocketAddress) channel.getLocalAddress()).getPort(); Preferences.userNodeForPackage(Main.class).putInt(applicationKey, port); LOG.info("InstanceManager bound to port {}", port); Selector selector = Selector.open(); channel.register(selector, SelectionKey.OP_ACCEPT); LocalInstance instance = new LocalInstance(applicationKey, channel, selector); exec.submit(() -> { try { instance.port = ((InetSocketAddress) channel.getLocalAddress()).getPort(); } catch (IOException e) { } instance.selectionLoop(); }); return instance; }
Source:
<code>public String getTargetUrl(Class<? extends Component> navigationTarget, RouteParameters parameters) { return iterateUrlTemplates(navigationTarget, urlTemplate -> { try { return getRouteModel().getUrl(urlTemplate, parameters); <START> } catch (IllegalArgumentException e) { <END> return null; } }); }</code><technical_language>![CRITICAL](<LINK_1> 'Severity: CRITICAL') log rethrow this exception. [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
public String getTargetUrl(Class<? extends Component> navigationTarget, RouteParameters parameters) { return iterateTemplates(navigationTarget, template -> { try { return getRouteModel().getUrl(template, parameters); } catch (IllegalArgumentException e) { return null; } }); }
Source:
<code><START> private void beforeInvocation() throws Exception { <END> ActionContext.setContext(invocation.getInvocationContext()); }</code><technical_language>Reducing scope affect users blocks adding other implementations</technical_language>

Target:
protected void beforeInvocation() throws Exception { ActionContext.setContext(invocation.getInvocationContext()); }
Source:
<code>protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException{ Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode model = resource.getModel(); <START> attributeDefinition.validateAndSet(operation, model); <END> JaxrsContextParamHandler.setContextParam(attributeName, valueToRestore); }</code><technical_language>belong in this method</technical_language>

Target:
protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException{ JaxrsContextParamHandler.setContextParam(attributeName, valueToRestore); }
Source:
<code>public void testName(Method method) throws Exception { Util.print("test name: " + method.getName()); bundles[0] = Util.readELBundles()[0][0]; bundles[0] = new Bundle(bundles[0], cluster.getEnvFileName(), cluster.getPrefix()); bundles[0].generateUniqueBundle(); bundles[0].setInputFeedDataPath(baseHDFSDir + "/${YEAR}/${MONTH}/${DAY}/${HOUR}/${MINUTE}"); bundles[0].setProcessValidity("2010-01-02T01:00Z", "2010-01-02T01:04Z"); bundles[0].setProcessPeriodicity(5, TimeUnit.minutes); bundles[0].setOutputFeedPeriodicity(5, TimeUnit.minutes); bundles[0].setOutputFeedLocationData(baseHDFSDir + "/output-data/${YEAR}/${MONTH}/${DAY}/${HOUR}/${MINUTE}"); bundles[0].setProcessConcurrency(1); <START> bundles[0].setProcessLibPath("/examples/apps/testLib/"); <END> }</code><technical_language>/examples relative of base hdfs dir? applies other places in test</technical_language>

Target:
public void testName(Method method) throws Exception { Util.print("test name: " + method.getName()); bundles[0] = Util.readELBundles()[0][0]; bundles[0] = new Bundle(bundles[0], cluster.getEnvFileName(), cluster.getPrefix()); bundles[0].generateUniqueBundle(); bundles[0].setInputFeedDataPath(baseHDFSDir + "/${YEAR}/${MONTH}/${DAY}/${HOUR}/${MINUTE}"); bundles[0].setProcessValidity("2010-01-02T01:00Z", "2010-01-02T01:04Z"); bundles[0].setProcessPeriodicity(5, TimeUnit.minutes); bundles[0].setOutputFeedPeriodicity(5, TimeUnit.minutes); bundles[0].setOutputFeedLocationData(baseHDFSDir + "/output-data/${YEAR}/${MONTH}/${DAY}/${HOUR}/${MINUTE}"); bundles[0].setProcessConcurrency(1); bundles[0].setProcessLibPath(testLibDir); }
Source:
<code>private Ingress generateIngress( String machineName, String serviceName, ServicePort servicePort, Map<String, ServerConfig> ingressesServers) { <START> ExternalServerIngressBuilder bld = new ExternalServerIngressBuilder(); <END> String host = strategy.getIngressHost(serviceName, servicePort); if (host != null) { bld = bld.withHost(host); } return bld.withPath( String.format( pathTransformFmt, ensureEndsWithSlash(strategy.getIngressPath(serviceName, servicePort)))) .withName(strategy.getIngressName(serviceName, servicePort)) .withMachineName(machineName) .withServiceName(serviceName) .withAnnotations(ingressAnnotations) .withServicePort(servicePort.getName()) .withServers(ingressesServers) .build(); }</code><technical_language>Is bld shortcut of builder word? I name here</technical_language>

Target:
private Ingress generateIngress( String machineName, String serviceName, ServicePort servicePort, Map<String, ServerConfig> ingressesServers) { ExternalServerIngressBuilder ingressBuilder = new ExternalServerIngressBuilder(); String host = strategy.getIngressHost(serviceName, servicePort); if (host != null) { ingressBuilder = ingressBuilder.withHost(host); } return ingressBuilder .withPath( String.format( pathTransformFmt, ensureEndsWithSlash(strategy.getIngressPath(serviceName, servicePort)))) .withName(getIngressName(serviceName, servicePort)) .withMachineName(machineName) .withServiceName(serviceName) .withAnnotations(ingressAnnotations) .withServicePort(servicePort.getName()) .withServers(ingressesServers) .build(); }
Source:
<code>protected void processAnnotationOnMethod(MethodMetadata data, Annotation methodAnnotation, Method method) { <START> if(!(methodAnnotation instanceof RequestMapping)) <END> return; RequestMapping mapping = RequestMapping.class.cast(methodAnnotation); if (mapping != null) { checkOne(method, mapping.method(), "method"); data.template().method(mapping.method()[0].name()); StringBuilder path = new StringBuilder(); RequestMapping classMapping = method.getDeclaringClass().getAnnotation(RequestMapping.class); if(classMapping != null && classMapping.value() != null && classMapping.value().length == 1) { path.append(classMapping.value()[0]); } path.append(mapping.value().length == 1 ? mapping.value()[0] : ""); String pathValue = emptyToNull(path.toString()); checkState(pathValue != null, "value was empty on method %s", method.getName()); if (path.charAt(0) != '/' && !data.template().toString().endsWith("/")) { path.insert(0, "/"); } data.template().append(path.toString()); checkAtMostOne(method, mapping.produces(), "produces"); String[] serverProduces = mapping.produces(); String clientAccepts = serverProduces.length == 0 ? null : emptyToNull(serverProduces[0]); if (clientAccepts != null) { data.template().header(ACCEPT, clientAccepts); } checkAtMostOne(method, mapping.consumes(), "consumes"); String[] serverConsumes = mapping.consumes(); String clientProduces = serverConsumes.length == 0 ? null : emptyToNull(serverConsumes[0]); if (clientProduces != null) { data.template().header(CONTENT_TYPE, clientProduces); } if (mapping.headers() != null && mapping.headers().length > 0) { for (String header : mapping.headers()) { int colon = header.indexOf(':'); data.template().header(header.substring(0, colon), header.substring(colon + 2)); } } } }</code><technical_language>Please change this, brackets spaces</technical_language>

Target:
protected void processAnnotationOnMethod(MethodMetadata data, Annotation methodAnnotation, Method method) { if (!(methodAnnotation instanceof RequestMapping)) { return; } RequestMapping methodMapping = RequestMapping.class.cast(methodAnnotation); checkOne(method, methodMapping.method(), "method"); data.template().method(methodMapping.method()[0].name()); checkAtMostOne(method, methodMapping.value(), "value"); if(methodMapping.value().length > 0) { String pathValue = emptyToNull(methodMapping.value()[0]); if (pathValue != null) { if (!pathValue.startsWith("/") && !data.template().toString().endsWith("/")) { pathValue = "/" + pathValue; } data.template().append(pathValue); } } parseProduces(data, method, methodMapping); parseConsumes(data, method, methodMapping); parseHeaders(data, method, methodMapping); }
Source:
<code>public static boolean compareItemStacks(@Nonnull ItemStack stack1, @Nonnull ItemStack stack2) <START> { <END> checkNotNull(stack1, "stack1"); checkNotNull(stack2, "stack2"); return stack2.getItem() == stack1.getItem() && (stack2.getMetadata() == 32767 || stack2.getMetadata() == stack1.getMetadata()); }</code><technical_language>Wrong formatting</technical_language>

Target:
public static boolean compareItemStacks(@Nonnull ItemStack stack1, @Nonnull ItemStack stack2) { checkNotNull(stack1, "stack1"); checkNotNull(stack2, "stack2"); return stack2.getItem() == stack1.getItem() && (stack2.getMetadata() == Short.MAX_VALUE || stack2.getMetadata() == stack1.getMetadata()); }
Source:
<code>private void createNotificationChannel(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { <START> CharSequence name = context.getResources().getString(R.string.channel_name); <END> String description = context.getResources().getString(R.string.channel_description); int importance = NotificationManager.IMPORTANCE_DEFAULT; NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance); channel.setDescription(description); channel.enableVibration(false); channel.enableLights(false); channel.setSound(null, null); NotificationManager notificationManager = context.getSystemService(NotificationManager.class); notificationManager.createNotificationChannel(channel); } }</code><technical_language>suggestion CharSequence name = context.getResources().getString(R.string.app_name); Please app name of *flavor* instead of hardcoding "Pocket Code" this string. resource file is, e.g., <LINK_1> <LINK_0></technical_language>

Target:
private void createNotificationChannel(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = context.getResources().getString(R.string.app_name); String description = context.getResources().getString(R.string.channel_description, name); int importance = NotificationManager.IMPORTANCE_DEFAULT; NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance); channel.setDescription(description); channel.enableVibration(false); channel.enableLights(false); channel.setSound(null, null); NotificationManager notificationManager = context.getSystemService(NotificationManager.class); notificationManager.createNotificationChannel(channel); } }
Source:
<code>public Object execute(ActionContext context) throws Exception { super.execute(context); String filter = createFilter(); if (filter == null) { return null; } int printingMaxRows = this.maxRows != null ? this.maxRows : DEFAULT_MAX_ROWS; if (verbose) { context.out.println("filter is '" + filter + "'"); <START> context.out.println("maxRows='" + printingMaxRows + "'"); <END> } printStats(context, filter, printingMaxRows); return null; }</code><technical_language>need for printingMaxRows...</technical_language>

Target:
public Object execute(ActionContext context) throws Exception { super.execute(context); String filter = createFilter(); if (filter == null) { return null; } if (verbose) { context.out.println("filter is '" + filter + "'"); context.out.println("maxRows='" + maxRows + "'"); } printStats(context, filter); return null; }
Source:
<code>public void setIconConfig(List<String> icons) { Map<String, Map<String, String>> iconMap = new HashMap<>(); icons.forEach( icon -> { String key = icon.split("=")[0]; String[] config = icon.split("=")[1].split(","); Map<String, String> tempMap = new HashMap<>(); <START> tempMap.put("className", config[0]); <END> tempMap.put("code", config[1]); tempMap.put("font", config[2]); tempMap.put("size", config[3]); iconMap.put(key, tempMap); }); this.iconConfig = iconMap; }</code><technical_language>checking size of config split</technical_language>

Target:
public void setIconConfig(List<String> icons) { Map<String, Map<String, String>> iconMap = new HashMap<>(); icons.forEach( icon -> { String key = icon.split("=")[0]; String[] config = icon.split("=")[1].split(","); if (config.length != 4) { LOGGER.debug("Icon Configuration entry malformed, discarding.", icon); } else { Map<String, String> tempMap = new HashMap<>(); tempMap.put("className", config[0]); tempMap.put("code", config[1]); tempMap.put("font", config[2]); tempMap.put("size", config[3]); iconMap.put(key, tempMap); } }); this.iconConfig = iconMap; }
Source:
<code>public @NonNull Iterable<@NonNull TmfAnalysisRequirement> getAnalysisRequirements() { LttngUstTrace trace = getTrace(); ILttngUstEventLayout layout; if (trace == null) { layout = DefaultLttngUstEventLayout.getInstance(); } else { layout = trace.getEventLayout(); } if (fAnalysisRequirements == null) { @NonNull Set<@NonNull String> requiredEventsFields = ImmutableSet.of( layout.contextProcname(), layout.contextVtid()); @NonNull TmfAnalysisEventFieldRequirement entryReq = new TmfAnalysisEventFieldRequirement( requiredEventsFields, ValuePriorityLevel.MANDATORY, ImmutableSet.of(layout.eventCygProfileFuncEntry(), layout.eventCygProfileFastFuncEntry())); entryReq.addInformation(nullToEmptyString(Messages.LttnUstCallStackAnalysisModule_EventsLoadingInformation)); @NonNull TmfAnalysisEventFieldRequirement exitReq = new TmfAnalysisEventFieldRequirement(requiredEventsFields, ValuePriorityLevel.MANDATORY, ImmutableSet.of(layout.eventCygProfileFuncExit(), layout.eventCygProfileFastFuncExit())); <START> exitReq.addInformation(nullToEmptyString(Messages.LttnUstCallStackAnalysisModule_EventsLoadingInformation)); <END> fAnalysisRequirements = ImmutableSet.of(entryReq, exitReq); } return checkNotNull(fAnalysisRequirements); }</code><technical_language>text repeats information twice. requirements information, skip for one</technical_language>

Target:
public @NonNull Iterable<@NonNull TmfAnalysisRequirement> getAnalysisRequirements() { LttngUstTrace trace = getTrace(); ILttngUstEventLayout layout; if (trace == null) { layout = ILttngUstEventLayout.DEFAULT_LAYOUT; } else { layout = trace.getEventLayout(); } Set<@NonNull TmfAnalysisRequirement> requirements = fAnalysisRequirements; if (requirements == null) { @NonNull Set<@NonNull String> requiredEventsFields = checkNotNull(ImmutableSet.of( layout.contextProcname(), layout.contextVtid())); @NonNull TmfAnalysisEventFieldRequirement entryReq = new TmfAnalysisEventFieldRequirement( checkNotNull(ImmutableSet.of(layout.eventCygProfileFuncEntry(), layout.eventCygProfileFastFuncEntry())), requiredEventsFields, ValuePriorityLevel.MANDATORY); @NonNull TmfAnalysisEventFieldRequirement exitReq = new TmfAnalysisEventFieldRequirement( checkNotNull(ImmutableSet.of(layout.eventCygProfileFuncExit(), layout.eventCygProfileFastFuncExit())), requiredEventsFields, ValuePriorityLevel.MANDATORY); exitReq.addInformation(nullToEmptyString(Messages.LttnUstCallStackAnalysisModule_EventsLoadingInformation)); requirements = checkNotNull(ImmutableSet.of(entryReq, exitReq)); fAnalysisRequirements = requirements; } return requirements; }
Source:
<code>private List<String> getIgnorePatterns() { <START> int index = arguments.indexOf(toArg(IOptionKeys.IGNORE_PATTERN)); <END> return this.getValues(index); }</code><technical_language>if argument expected doesnt exist code another argument for Input argument. check complain default</technical_language>

Target:
private List<String> getIgnorePatterns() { int index = arguments.indexOf(toArg(IOptionKeys.IGNORE_PATTERN)) + 1; return this.getValues(index); }
Source:
<code>public int getConnectionIdleTime() { <START> int idleTime = getIntProperty(PassThroughConfigPNames.CONNECTION_IDLE_TIME, getDefaultConnectionIdleTime()); <END> if (idleTime < 0) { return 0; } return idleTime; }</code><technical_language>giving priority CONNECTION_IDLE_TIME. configuration is CONNECTION_GRACE_TIME. give priority CONNECTION_GRACE_TIME. If defined, need check CONNECTION_IDLE_TIME</technical_language>

Target:
public int getConnectionIdleTime() { int idleTime; if (isIntPropertyConfigured(PassThroughConfigPNames.CONNECTION_GRACE_TIME)) { idleTime = getIdleTimeFromGraceTime(); } else { idleTime = getIntProperty(PassThroughConfigPNames.CONNECTION_IDLE_TIME, getIdleTimeFromGraceTime()); } if (idleTime < 0) { return 0; } return idleTime; }
Source:
<code>public void triggerNow() { <END> ThreadPoolUtil.execute(this::ovfUpdateTimer); }</code><technical_language>ah apparently looked SchedulerUtil#triggerJob.. replace existing fixedDelayJob, reschedule it, work for vm-pool monitoring</technical_language>

Target:
public void triggerNow() { if (updateTimerJobId != null) { SchedulerUtil scheduler = Injector.get(SchedulerUtilQuartzImpl.class); scheduler.triggerJob(updateTimerJobId); } }
Source:
<code>public Map<String, String> allocate(Network network, VmNetworkInterface nic) { deallocate(nic); try { <START> com.woorea.openstack.quantum.model.Network quantumNetwork = <END> getClient().networks().show(network.getProvidedBy().getExternalId()).execute(); PortForCreate port = new PortForCreate(); port.setAdminStateUp(true); port.setName(nic.getName()); port.setTenantId(quantumNetwork.getTenantId()); port.setMacAddress(nic.getMacAddress()); port.setNetworkId(quantumNetwork.getId()); port.setDeviceOwner(DEVICE_OWNER); port.setDeviceId(nic.getId().toString()); Port createdPort = getClient().ports().create(port).execute(); Map<String, String> runtimeProperties = new HashMap<>(); runtimeProperties.put("vnic_id", createdPort.getId()); runtimeProperties.put("provider_type", provider.getType().name()); runtimeProperties.put("plugin_type", provider.getAdditionalProperties().getPluginType().name()); return runtimeProperties; } catch (RuntimeException e) { throw new VdcBLLException(VdcBllErrors.PROVIDER_FAILURE, e); } }</code><technical_language>please omit 'quantum' property name: quantumNetwork</technical_language>

Target:
public Map<String, String> allocate(Network network, VmNetworkInterface nic) { deallocate(nic); try { com.woorea.openstack.quantum.model.Network externalNetwork = getClient().networks().show(network.getProvidedBy().getExternalId()).execute(); PortForCreate port = new PortForCreate(); port.setAdminStateUp(true); port.setName(nic.getName()); port.setTenantId(externalNetwork.getTenantId()); port.setMacAddress(nic.getMacAddress()); port.setNetworkId(externalNetwork.getId()); port.setDeviceOwner(DEVICE_OWNER); port.setDeviceId(nic.getId().toString()); Port createdPort = getClient().ports().create(port).execute(); Map<String, String> runtimeProperties = new HashMap<>(); runtimeProperties.put("vnic_id", createdPort.getId()); runtimeProperties.put("provider_type", provider.getType().name()); runtimeProperties.put("plugin_type", provider.getAdditionalProperties().getPluginType().name()); return runtimeProperties; } catch (RuntimeException e) { throw new VdcBLLException(VdcBllErrors.PROVIDER_FAILURE, e); } }
Source:
<code>public IStatus addComment(IReviewItem item, IComment comment, IProgressMonitor monitor) { short side = RIGHT_SIDE; String id = item.getId(); if (id.startsWith(BASE)) { id = id.substring(BASE.length()); <START> side = LEFT_SIDE; <END> } Patch.Key key = Patch.Key.parse(id); for (ILocation location : comment.getLocations()) { if (location instanceof ILineLocation) { ILineLocation lineLocation = (ILineLocation) location; SaveDraftRequest request = new SaveDraftRequest(key, lineLocation.getRangeMin(), side); request.setMessage(comment.getDescription()); if (comment.getId() != null && !(comment.getId().isEmpty())) { request.setUuid(comment.getId()); } GerritOperation<PatchLineComment> operation = getOperationFactory().createSaveDraftOperation(getTask(), request); IStatus status = operation.run(monitor); PatchLineComment patchLineComment = operation.getOperationResult(); if (patchLineComment != null && patchLineComment.getKey() != null) { comment.setId(patchLineComment.getKey().get()); } return status; } } throw new RuntimeException(Messages.GerritReviewBehavior_Internal_Exception + comment.getId()); }</code><technical_language>code there. i added constants</technical_language>

Target:
public IStatus addComment(IReviewItem item, IComment comment, IProgressMonitor monitor) { short side = RIGHT_SIDE; String id = item.getId(); if (id.startsWith(BASE)) { id = id.substring(BASE.length()); side = LEFT_SIDE; } Patch.Key key = Patch.Key.parse(id); for (ILocation location : comment.getLocations()) { if (location instanceof ILineLocation) { ILineLocation lineLocation = (ILineLocation) location; SaveDraftRequest request = new SaveDraftRequest(key, lineLocation.getRangeMin(), side); request.setMessage(comment.getDescription()); if (!StringUtils.isEmptyOrNull(comment.getId())) { request.setUuid(comment.getId()); } GerritOperation<PatchLineComment> operation = getOperationFactory().createSaveDraftOperation(getTask(), request); IStatus status = operation.run(monitor); PatchLineComment patchLineComment = operation.getOperationResult(); if (patchLineComment != null && patchLineComment.getKey() != null) { comment.setId(patchLineComment.getKey().get()); } return status; } } throw new RuntimeException(NLS.bind(Messages.GerritReviewBehavior_Internal_Exception, comment.getId())); }
Source:
<code>public void indexUseCases(final UseCaseScenariosList useCaseScenariosList, final BuildIdentifier buildIdentifier) { if(!searchAdapter.isEngineRunning()) { <START> LOGGER.info("No search engine running."); <END> return; } searchAdapter.setupNewBuild(buildIdentifier); searchAdapter.indexUseCases(useCaseScenariosList, buildIdentifier); LOGGER.info("Indexed build " + buildIdentifier); }</code><technical_language>this adds a lot of noise log log this allways info. Please avoid this. do nothing, engine is running (or log trace, if this is needed - I is remove it). for other similar logs in this class</technical_language>

Target:
public void indexUseCases(final UseCaseScenariosList useCaseScenariosList, final BuildIdentifier buildIdentifier) { if(!searchAdapter.isEngineRunning()) { return; } searchAdapter.setupNewBuild(buildIdentifier); searchAdapter.indexUseCases(useCaseScenariosList, buildIdentifier); LOGGER.info("Indexed use cases for build " + buildIdentifier); }
Source:
<code>public TimeZoneType getTimeZoneType() { VmOsType vmOsType = (VmOsType) getModel().getOSType().getSelectedItem(); <START> return vmOsType == null ? TimeZoneType.GENERAL_TIMEZONE : TimeZoneType.getTimeZoneByOs(vmOsType); <END> }</code><technical_language>Yes, this solve NPE, if I suggest place for this null check TimeZoneType.getTimeZoneByOs method, avoid similar omissions in future. sense for getTimeZoneByOs return GENERAL_TIMEZONE if osType is unspecified</technical_language>

Target:
public TimeZoneType getTimeZoneType() { VmOsType vmOsType = (VmOsType) getModel().getOSType().getSelectedItem(); return TimeZoneType.getTimeZoneByOs(vmOsType); }
Source:
<code>public void testCreateDocumentUnderPlacelessDoc() { DocumentModel parentFile = session.newDocumentModel(null, "parentFile", "File"); parentFile = session.createDocument(parentFile); assertNull(parentFile.getParentRef()); session.save(); DocumentModel childFile = session.newDocumentModel(parentFile.getRef(), "childFile", "File"); childFile = session.createDocument(childFile); session.save(); reopenSession(); parentFile = session.getDocument(new IdRef(parentFile.getId())); assertNull(parentFile.getParentRef()); childFile = session.getDocument(new IdRef(childFile.getId())); assertEquals(parentFile.getRef(), childFile.getParentRef()); session.removeDocument(parentFile.getRef()); session.save(); <START> assertFalse("parentFile should be removed", session.exists(parentFile.getRef())); assertFalse("childFile should be removed", session.exists(childFile.getRef())); <END> }</code><technical_language>of pertinence of messages here... java assertFalse(session.exists(parentFile.getRef())); assertFalse(session.exists(childFile.getRef())); enough</technical_language>

Target:
public void testCreateDocumentUnderPlacelessDoc() { DocumentModel parent = session.newDocumentModel(null, "parent", "File"); parent = session.createDocument(parent); assertNull(parent.getParentRef()); session.save(); DocumentModel child = session.newDocumentModel(parent.getRef(), "child", "File"); child = session.createDocument(child); session.save(); reopenSession(); parent = session.getDocument(parent.getRef()); assertNull(parent.getParentRef()); child = session.getDocument(child.getRef()); assertEquals(parent.getRef(), child.getParentRef()); session.removeDocument(parent.getRef()); session.save(); assertFalse(session.exists(parent.getRef())); assertFalse(session.exists(child.getRef())); }