auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void authenticate() throws MessagingException, IOException { switch (settings.getAuthType()) { case XOAUTH2: if (hasCapability(Capabilities.AUTH_XOAUTH2) && hasCapability(Capabilities.SASL_IR) <START> && oauthTokenProvider != null) { <END> authXoauth2withSASLIR(); } else { throw new MessagingException("Server doesn't support SASL XOAUTH2."); } break; case CRAM_MD5: { if (hasCapability(Capabilities.AUTH_CRAM_MD5)) { authCramMD5(); } else { throw new MessagingException("Server doesn't support encrypted passwords using CRAM-MD5."); } break; } case PLAIN: { if (hasCapability(Capabilities.AUTH_PLAIN)) { saslAuthPlainWithLoginFallback(); } else if (!hasCapability(Capabilities.LOGINDISABLED)) { login(); } else { throw new MessagingException("Server doesn't support unencrypted passwords using AUTH=PLAIN " + "and LOGIN is disabled."); } break; } case EXTERNAL: { if (hasCapability(Capabilities.AUTH_EXTERNAL)) { saslAuthExternal(); } else { throw new CertificateValidationException(CertificateValidationException.Reason.MissingCapability); } break; } default: { throw new MessagingException("Unhandled authentication method found in the server settings (bug)."); } } }</code><technical_language>Is a case oauthTokenProvider is null a bug? handled in exception of own, error message is wrong in this case</technical_language>

Target:
private void authenticate() throws MessagingException, IOException { switch (settings.getAuthType()) { case XOAUTH2: if (oauthTokenProvider == null) { throw new MessagingException("No OAuthToken Provider available."); } else if (hasCapability(Capabilities.AUTH_XOAUTH2) && hasCapability(Capabilities.SASL_IR)) { authXoauth2withSASLIR(); } else { throw new MessagingException("Server doesn't support SASL XOAUTH2."); } break; case CRAM_MD5: { if (hasCapability(Capabilities.AUTH_CRAM_MD5)) { authCramMD5(); } else { throw new MessagingException("Server doesn't support encrypted passwords using CRAM-MD5."); } break; } case PLAIN: { if (hasCapability(Capabilities.AUTH_PLAIN)) { saslAuthPlainWithLoginFallback(); } else if (!hasCapability(Capabilities.LOGINDISABLED)) { login(); } else { throw new MessagingException("Server doesn't support unencrypted passwords using AUTH=PLAIN " + "and LOGIN is disabled."); } break; } case EXTERNAL: { if (hasCapability(Capabilities.AUTH_EXTERNAL)) { saslAuthExternal(); } else { throw new CertificateValidationException(CertificateValidationException.Reason.MissingCapability); } break; } default: { throw new MessagingException("Unhandled authentication method found in the server settings (bug)."); } } }
Source:
<code>private boolean deleteDownload(Download download) { boolean deleted = false; try { File stagingFolder = download.fetchZipFile().getParentFile(); <START> deleted = FileUtils.deleteQuietly(stagingFolder); <END> manager.delete(download); } catch (URISyntaxException ex) { log.error("Invalid file pointer", ex); } return deleted; }</code><technical_language>if this fails manager.delete fails? I guess more important doe manager.delete() pass deleting @ file system. flip this manager.delete() runs first</technical_language>

Target:
private boolean deleteDownload(Download download) { boolean deleted = false; try { manager.delete(download); File stagingFolder = download.fetchZipFile().getParentFile(); deleted = FileUtils.deleteQuietly(stagingFolder); } catch (URISyntaxException ex) { log.error("Invalid file pointer", ex); } return deleted; }
Source:
<code>public Set<IFolder> getFoldersToIgnore(IProject project, IProgressMonitor monitor) { Set<IFolder> res = new HashSet<>(); res.addAll(new ProjectWithJavaResourcesImportConfigurator().getFoldersToIgnore(project, monitor)); try { IFile buildPropertiesFile = PDEProject.getBuildProperties(project); Properties buildProperties = new Properties(); if (buildPropertiesFile.exists()) { <START> InputStream stream = buildPropertiesFile.getContents(); <END> buildProperties.load(stream); stream.close(); } for (Entry<?, ?> entry : buildProperties.entrySet()) { String entryKey = (String)entry.getKey(); if (entryKey.startsWith("src.") || entryKey.startsWith("source.") || entryKey.startsWith("bin.") || entryKey.startsWith("output.")) { for (String token : ((String) entry.getValue()).split(",")) { token = token.trim(); if (token.endsWith("/")) { token = token.substring(0, token.length() - 1); } if (token != null && token.length() > 0 && !token.equals(".")) { IFolder folder = project.getFolder(token); if (folder.exists()) { res.add(folder); } } } } } } catch (Exception ex) { PDEPlugin.log(ex); } return res; }</code><technical_language>try resources</technical_language>

Target:
public Set<IFolder> getFoldersToIgnore(IProject project, IProgressMonitor monitor) { Set<IFolder> res = new HashSet<>(); res.addAll(new ProjectWithJavaResourcesImportConfigurator().getFoldersToIgnore(project, monitor)); IFile buildPropertiesFile = PDEProject.getBuildProperties(project); Properties buildProperties = new Properties(); if (!buildPropertiesFile.exists()) { return Collections.emptySet(); } try (InputStream stream = buildPropertiesFile.getContents()) { buildProperties.load(stream); for (Entry<?, ?> entry : buildProperties.entrySet()) { String entryKey = (String) entry.getKey(); if (entryKey.startsWith("src.") || entryKey.startsWith(IBuildEntry.JAR_PREFIX) || entryKey.startsWith("bin.") || entryKey.startsWith(IBuildEntry.OUTPUT_PREFIX)) { for (String token : ((String) entry.getValue()).split(",")) { token = token.trim(); if (token.endsWith("/")) { token = token.substring(0, token.length() - 1); } if (token != null && token.length() > 0 && !token.equals(".")) { IFolder folder = project.getFolder(token); if (folder.exists()) { res.add(folder); } } } } } return res; } catch (CoreException | IOException ex) { PDEPlugin.log(ex); return Collections.emptySet(); } }
Source:
<code>public LoginCredentials apply(Template template, LoginCredentials fromNode) { LoginCredentials creds = fromNode; LoginCredentials credsFromParameters = credentialsFromImageOrTemplateOptions.apply(template); if (credsFromParameters != null) { Builder builder = LoginCredentials.builder(creds); if (credsFromParameters.getUser() != null) builder.user(credsFromParameters.getUser()); if (credsFromParameters.getOptionalPassword().isPresent()) if (credsFromParameters.getOptionalPassword().get().isEmpty()) builder.noPassword(); else builder.password(credsFromParameters.getOptionalPassword().get()); if (credsFromParameters.getOptionalPrivateKey().isPresent()) <START> if (credsFromParameters.getOptionalPassword().get().isEmpty()) <END> builder.noPassword(); else builder.privateKey(credsFromParameters.getOptionalPrivateKey().get()); if (credsFromParameters.shouldAuthenticateSudo()) builder.authenticateSudo(true); creds = builder.build(); } return creds; }</code><technical_language>This throw a NPE if optional password is present. able remove this if statement is covered previous one</technical_language>

Target:
public LoginCredentials apply(Template template, LoginCredentials fromNode) { LoginCredentials creds = fromNode; LoginCredentials credsFromParameters = credentialsFromImageOrTemplateOptions.apply(template); if (credsFromParameters != null) { Builder builder = LoginCredentials.builder(creds); if (credsFromParameters.getUser() != null) builder.user(credsFromParameters.getUser()); if (credsFromParameters.getOptionalPassword().isPresent()) if (credsFromParameters.getOptionalPassword().get().isEmpty()) builder.noPassword(); else builder.password(credsFromParameters.getOptionalPassword().get()); if (credsFromParameters.getOptionalPrivateKey().isPresent()) if (credsFromParameters.getOptionalPrivateKey().get().isEmpty()) builder.noPrivateKey(); else builder.privateKey(credsFromParameters.getOptionalPrivateKey().get()); if (credsFromParameters.shouldAuthenticateSudo()) builder.authenticateSudo(true); creds = builder.build(); } return creds; }
Source:
<code>public List<EnvironmentPipelineModel> getAllRemotePipelinesForUserInEnvironment(Username user,EnvironmentConfig environment) { List<EnvironmentPipelineModel> pipelines = new ArrayList<EnvironmentPipelineModel>(); for (EnvironmentPipelineConfig pipelineConfig : environment.getRemotePipelines()) { String pipelineName = CaseInsensitiveString.str(pipelineConfig.getName()); if (securityService.hasViewPermissionForPipeline(user, pipelineName)) { <START> if (environment != null) { <END> pipelines.add(new EnvironmentPipelineModel(pipelineName, CaseInsensitiveString.str(environment.name()))); } else { pipelines.add(new EnvironmentPipelineModel(pipelineName)); } } } Collections.sort(pipelines); return pipelines; }</code><technical_language>do need this null check here? If environment null, [this line ](<LINK_0> throw exception already</technical_language>

Target:
public List<EnvironmentPipelineModel> getAllRemotePipelinesForUserInEnvironment(Username user,EnvironmentConfig environment) { List<EnvironmentPipelineModel> pipelines = new ArrayList<EnvironmentPipelineModel>(); for (EnvironmentPipelineConfig pipelineConfig : environment.getRemotePipelines()) { String pipelineName = CaseInsensitiveString.str(pipelineConfig.getName()); if (securityService.hasViewPermissionForPipeline(user, pipelineName)) { pipelines.add(new EnvironmentPipelineModel(pipelineName, CaseInsensitiveString.str(environment.name()))); } } Collections.sort(pipelines); return pipelines; }
Source:
<code>public Span nextSpan(ConsumerRecord record) { <START> TraceContext context = tracing.propagation() <END> .extractor(extractor) .extract(record).context(); if (context != null) { return tracing.tracer().toSpan(context); } else { return tracing.tracer().newTrace(); } }</code><technical_language>check flags, propagated info sample. in else, extracted propagation flags</technical_language>

Target:
public Span nextSpan(ConsumerRecord record) { TraceContextOrSamplingFlags contextOrSamplingFlags = extractor.extract(record); if (contextOrSamplingFlags.context() != null) { return tracing.tracer().toSpan(contextOrSamplingFlags.context()); } else { return tracing.tracer().newTrace(contextOrSamplingFlags.samplingFlags()); } }
Source:
<code><START> InetUtils zipkinInetUtils(){ <END> return new InetUtils(new InetUtilsProperties()); }</code><technical_language>I this is needed. add this</technical_language>

Target:
public InetUtils zipkinInetUtils(){ return new InetUtils(new InetUtilsProperties()); }
Source:
<code>public void showFormList(String[] forms) { if(forms.length == 0) { snackbar = Snackbar.make(root, ApplicationConstants.EMPTY_STRING, Snackbar.LENGTH_INDEFINITE); View customSnackBarView = getLayoutInflater().inflate(R.layout.snackbar, null); Snackbar.SnackbarLayout snackBarLayout = (Snackbar.SnackbarLayout) snackbar.getView(); snackBarLayout.setPadding(0, 0, 0, 0); TextView noticeField = customSnackBarView.findViewById(R.id.snackbar_text); noticeField.setText(R.string.snackbar_no_forms_found); <START> TextView dismiss_button = customSnackBarView.findViewById(R.id.snackbar_action_button); <END> Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), ApplicationConstants.TypeFacePathConstants.ROBOTO_MEDIUM); dismiss_button.setTypeface(typeface); dismiss_button.setOnClickListener(v -> snackbar.dismiss()); snackBarLayout.addView(customSnackBarView, 0); snackbar.show(); } formList.setAdapter(new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, android.R.id.text1, forms)); }</code><technical_language>camel case. java conventions</technical_language>

Target:
public void showFormList(String[] forms) { if(forms.length == 0) { snackbar = Snackbar.make(root, ApplicationConstants.EMPTY_STRING, Snackbar.LENGTH_INDEFINITE); View customSnackBarView = getLayoutInflater().inflate(R.layout.snackbar, null); Snackbar.SnackbarLayout snackBarLayout = (Snackbar.SnackbarLayout) snackbar.getView(); snackBarLayout.setPadding(0, 0, 0, 0); TextView noticeField = customSnackBarView.findViewById(R.id.snackbar_text); noticeField.setText(R.string.snackbar_no_forms_found); TextView dismissButton = customSnackBarView.findViewById(R.id.snackbar_action_button); Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), ApplicationConstants.TypeFacePathConstants.ROBOTO_MEDIUM); dismissButton.setTypeface(typeface); dismissButton.setOnClickListener(v -> snackbar.dismiss()); snackBarLayout.addView(customSnackBarView, 0); snackbar.show(); } formList.setAdapter(new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, android.R.id.text1, forms)); }
Source:
<code>private String sendMessage(final JmsTemplate template, final String msg) { String resultString = template.execute(new SessionCallback<String>() { @Override public String doInJms(Session session) throws JMSException { Queue queue = session.createQueue("receive"); MessageProducer producer = session.createProducer(queue); <START> TemporaryQueue tempQueue = session.createTemporaryQueue(); <END> MessageConsumer consumer = session.createConsumer(tempQueue); TextMessage message = session.createTextMessage(msg); message.setJMSReplyTo(tempQueue); message.setJMSCorrelationID(UUID.randomUUID().toString()); producer.send(message); TextMessage response = (TextMessage) consumer.receive(1000); JmsUtils.closeMessageProducer(producer); JmsUtils.closeMessageConsumer(consumer); return response.getText(); } }, true); return resultString; }</code><technical_language>pls... a good example</technical_language>

Target:
private String sendMessage(final JmsTemplate template, final String msg) { String resultString = template.execute(new SessionCallback<String>() { @Override public String doInJms(Session session) throws JMSException { Queue queue = session.createQueue("receive"); MessageProducer producer = session.createProducer(queue); TemporaryQueue tempQueue = session.createTemporaryQueue(); MessageConsumer consumer = session.createConsumer(tempQueue); TextMessage message = session.createTextMessage(msg); message.setJMSReplyTo(tempQueue); producer.send(message); TextMessage response = (TextMessage) consumer.receive(1000); assertThat("server should set the value of the correltion ID to the value of the received message id", response.getJMSCorrelationID(), is(message.getJMSMessageID())); JmsUtils.closeMessageProducer(producer); JmsUtils.closeMessageConsumer(consumer); return response.getText(); } }, true); return resultString; }
Source:
<code>@Override public void registerWorldGen(ICubicWorldServer world, GeneratorPipeline pipeline) { ServerCubeCache cubeCache = world.getCubeCache(); ChunkProviderOverworld vanillaGen = new ChunkProviderOverworld((World) world, world.getSeed(), true, ""); GeneratorStage terrain = new GeneratorStage("terrain"); GeneratorStage surface = new GeneratorStage("surface"); <START> GeneratorStage testStage = new TestStage("testStage"); <END> GeneratorStage population = new GeneratorStage("population"); pipeline.addStage(terrain, new VanillaTerrainProcessor(surface, world, vanillaGen, 5)); pipeline.addStage(GeneratorStage.LIGHTING, new FirstLightProcessor(GeneratorStage.LIGHTING, "Lighting", cubeCache, 5)); pipeline.addStage(testStage, new NullProcessor("Testing", cubeCache)); pipeline.addStage(population, new VanillaPopulationProcessor(population, world, vanillaGen, 5)); }</code><technical_language>Is this needed for testing? If for testing, removed</technical_language>

Target:
@Override public void registerWorldGen(ICubicWorldServer world, GeneratorPipeline pipeline) { ServerCubeCache cubeCache = world.getCubeCache(); ChunkProviderOverworld vanillaGen = new ChunkProviderOverworld((World) world, world.getSeed(), true, ""); GeneratorStage terrain = new IndependentGeneratorStage("terrain"); GeneratorStage surface = new IndependentGeneratorStage("surface"); GeneratorStage population = new IndependentGeneratorStage("population"); pipeline.addStage(terrain, new VanillaTerrainProcessor(surface, world, vanillaGen, 5)); pipeline.addStage(GeneratorStage.LIGHTING, new FirstLightProcessor(GeneratorStage.LIGHTING, "Lighting", cubeCache, 5)); pipeline.addStage(population, new VanillaPopulationProcessor(population, world, vanillaGen, 5)); }
Source:
<code>private <R extends Row, T> ListenableFuture<Result> issueAsyncRowRequest(Row row, Batch.Callback<T> callback, Object[] results, int index) throws InterruptedException { LOG.trace("issueRowRequest(Row, Batch.Callback, Object[], index"); SettableFuture<Result> resultFuture = SettableFuture.create(); RpcResultFutureCallback<T> futureCallback = new RpcResultFutureCallback<T>(row, callback, index, results, resultFuture); results[index] = null; <START> if (service.isShutdown()) { <END> ListenableFuture<? extends GeneratedMessage> failFuture = Futures.immediateFailedFuture(new ConnectionClosedException( "Cannot perform batch operations when a connection is closed")); Futures.addCallback(failFuture, futureCallback); } else { ListenableFuture<? extends GeneratedMessage> future = issueAsyncRequest(row); Futures.addCallback(future, futureCallback, service); } return resultFuture; }</code><technical_language>This good. Is a unit test test this behavior? if (closed) expect ConnectionClosedException else expect async</technical_language>

Target:
private <R extends Row, T> ListenableFuture<Result> issueAsyncRowRequest(Row row, Batch.Callback<T> callback, Object[] results, int index) { LOG.trace("issueRowRequest(Row, Batch.Callback, Object[], index"); SettableFuture<Result> resultFuture = SettableFuture.create(); RpcResultFutureCallback<T> futureCallback = new RpcResultFutureCallback<T>(row, callback, index, results, resultFuture); results[index] = null; if (service.isShutdown()) { ListenableFuture<? extends GeneratedMessage> failFuture = Futures.immediateFailedFuture(new IOException( "Cannot perform batch operations when a connection is closed")); Futures.addCallback(failFuture, futureCallback); } else { ListenableFuture<? extends GeneratedMessage> future = issueAsyncRequest(row); Futures.addCallback(future, futureCallback, service); } return resultFuture; }
Source:
<code><START> public static PointValue parse( CharSequence text, AnyValue[] fieldsFromHeader ) <END> { AnyValue[] fieldsFromData = parseIntoArray( text ); if ( fieldsFromHeader != null ) { for ( int i = 0; i < fieldsFromData.length; i++ ) { if ( fieldsFromData[i] == null ) { fieldsFromData[i] = fieldsFromHeader[i]; } } } return fromInputFields( fieldsFromData ); }</code><technical_language>renaming fieldsFromHeader defaultFields user agnostic</technical_language>

Target:
public static PointValue parse( CharSequence text, AnyValue[] fieldsFromHeader ) { AnyValue[] fieldsFromData = parseIntoArray( text ); if ( fieldsFromHeader != null ) { assert fieldsFromData.length == fieldsFromHeader.length; for ( int i = 0; i < fieldsFromData.length; i++ ) { if ( fieldsFromData[i] == null ) { fieldsFromData[i] = fieldsFromHeader[i]; } } } return fromInputFields( fieldsFromData ); }
Source:
<code>private void start() throws IOException { zookeeper = new EmbeddedZookeeper(); brokerConfig.put(KafkaConfig$.MODULE$.ZkConnectProp(), zKConnectString()); brokerConfig.put(KafkaConfig$.MODULE$.PortProp(), 0); putIfAbsent(brokerConfig, KafkaConfig$.MODULE$.HostNameProp(), "localhost"); putIfAbsent(brokerConfig, KafkaConfig$.MODULE$.DeleteTopicEnableProp(), true); putIfAbsent(brokerConfig, KafkaConfig$.MODULE$.GroupInitialRebalanceDelayMsProp(), 0); putIfAbsent(brokerConfig, KafkaConfig$.MODULE$.OffsetsTopicReplicationFactorProp(), (short) brokers.length); putIfAbsent(brokerConfig, KafkaConfig$.MODULE$.AutoCreateTopicsEnableProp(), false); Object listenerConfig = brokerConfig.get(KafkaConfig$.MODULE$.InterBrokerListenerNameProp()); if (listenerConfig != null) { listenerName = new ListenerName(listenerConfig.toString()); } for (int i = 0; i < brokers.length; i++) { brokerConfig.put(KafkaConfig$.MODULE$.BrokerIdProp(), i); brokerConfig.put(KafkaConfig$.MODULE$.LogDirProp(), createLogDir()); <START> brokers[i] = TestUtils.createServer(new KafkaConfig(brokerConfig, true), time, null); <END> } Map<String, Object> producerProps = new HashMap<>(); producerProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers()); producerProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer"); producerProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer"); producer = new KafkaProducer<>(producerProps); }</code><technical_language>do need pass in null? default is anyway</technical_language>

Target:
private void start() throws IOException { zookeeper = new EmbeddedZookeeper(); brokerConfig.put(KafkaConfig$.MODULE$.ZkConnectProp(), zKConnectString()); brokerConfig.put(KafkaConfig$.MODULE$.PortProp(), 0); putIfAbsent(brokerConfig, KafkaConfig$.MODULE$.HostNameProp(), "localhost"); putIfAbsent(brokerConfig, KafkaConfig$.MODULE$.DeleteTopicEnableProp(), true); putIfAbsent(brokerConfig, KafkaConfig$.MODULE$.GroupInitialRebalanceDelayMsProp(), 0); putIfAbsent(brokerConfig, KafkaConfig$.MODULE$.OffsetsTopicReplicationFactorProp(), (short) brokers.length); putIfAbsent(brokerConfig, KafkaConfig$.MODULE$.AutoCreateTopicsEnableProp(), false); Object listenerConfig = brokerConfig.get(KafkaConfig$.MODULE$.InterBrokerListenerNameProp()); if (listenerConfig != null) { listenerName = new ListenerName(listenerConfig.toString()); } for (int i = 0; i < brokers.length; i++) { brokerConfig.put(KafkaConfig$.MODULE$.BrokerIdProp(), i); brokerConfig.put(KafkaConfig$.MODULE$.LogDirProp(), createLogDir()); brokers[i] = TestUtils.createServer(new KafkaConfig(brokerConfig, true), time); } Map<String, Object> producerProps = new HashMap<>(); producerProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers()); producerProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer"); producerProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer"); producer = new KafkaProducer<>(producerProps); }
Source:
<code>public Set<LanguageServerLauncher> getAll(Workspace workspace) { for (Map.Entry<String, ? extends Machine> machineEntry : <START> workspace.getRuntime().getMachines().entrySet()) { <END> String machineName = machineEntry.getKey(); Machine machine = machineEntry.getValue(); Map<String, ? extends Server> servers = machine.getServers(); for (Map.Entry<String, ? extends Server> serverEntry : servers.entrySet()) { String serverName = serverEntry.getKey(); Server server = serverEntry.getValue(); String serverUrl = server.getUrl(); Map<String, String> serverAttributes = server.getAttributes(); if (lslRegistry.keySet().contains(machineName + serverName)) { continue; } if (!lsConfigurationDetector.isDetected(serverAttributes)) { continue; } LanguageServerDescription description = lsConfigurationExtractor.extract(serverAttributes); try { URI uri = new URI(serverUrl); String host = uri.getHost(); int port = uri.getPort(); SocketLanguageServerLauncher launcher = new SocketLanguageServerLauncher(description, host, port); lslRegistry.put(machineName + serverName, launcher); } catch (URISyntaxException e) { LOG.error("Can't parse server url: {}", serverUrl, e); } } } return unmodifiableSet(new HashSet<>(lslRegistry.values())); }</code><technical_language>FYI runtime null in cases</technical_language>

Target:
public Set<LanguageServerLauncher> getAll(Workspace workspace) { Runtime runtime = workspace.getRuntime(); if (runtime == null) { return emptySet(); } for (Map.Entry<String, ? extends Machine> machineEntry : runtime.getMachines().entrySet()) { String machineName = machineEntry.getKey(); Machine machine = machineEntry.getValue(); Map<String, ? extends Server> servers = machine.getServers(); for (Map.Entry<String, ? extends Server> serverEntry : servers.entrySet()) { String serverName = serverEntry.getKey(); Server server = serverEntry.getValue(); String serverUrl = server.getUrl(); Map<String, String> serverAttributes = server.getAttributes(); if (lslRegistry.keySet().contains(machineName + serverName)) { continue; } if (!lsConfigurationDetector.isDetected(serverAttributes)) { continue; } LanguageServerDescription description = lsConfigurationExtractor.extract(serverAttributes); try { URI uri = new URI(serverUrl); String host = uri.getHost(); int port = uri.getPort(); SocketLanguageServerLauncher launcher = new SocketLanguageServerLauncher(description, host, port); lslRegistry.put(machineName + serverName, launcher); } catch (URISyntaxException e) { LOG.error("Can't parse server url: {}", serverUrl, e); } } } return unmodifiableSet(new HashSet<>(lslRegistry.values())); }
Source:
<code>public Container iand(final ArrayContainer b2) { if (-1 == cardinality) { <START> Util.intersect(bitmap, b2.content, b2.cardinality); <END> return this; } else { return b2.and(this); } }</code><technical_language>This sense me</technical_language>

Target:
public Container iand(final ArrayContainer b2) { if (-1 == cardinality) { Util.intersectArrayIntoBitmap(bitmap, b2.content, b2.cardinality); return this; } else { return b2.and(this); } }
Source:
<code>public Model getGETModel(Representation rep) { ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { modelImpl .property("uuid", new StringProperty()) .property("display", new StringProperty()) .property("voided", new BooleanProperty()) .property("patient", new RefProperty("#/definitions/PatientGetRef")) .property("encounter", new RefProperty("#/definitions/EncounterGetRef")) <START> .property("orders", new RefProperty("#/definitions/OrderGetRef")) <END> .property("orderSet", new RefProperty("#/definitions/OrdersetGetRef")); } if (rep instanceof DefaultRepresentation) { modelImpl .property("uuid", new StringProperty()) .property("display", new StringProperty()) .property("voided", new BooleanProperty()) .property("patient", new RefProperty("#/definitions/PatientGetRef")) .property("encounter", new RefProperty("#/definitions/EncounterGetRef")) .property("orders", new RefProperty("#/definitions/OrderGetRef")) .property("orderSet", new RefProperty("#/definitions/OrdersetGetRef")); } else if (rep instanceof FullRepresentation) { modelImpl .property("uuid", new StringProperty()) .property("display", new StringProperty()) .property("voided", new BooleanProperty()) .property("auditInfo", new BooleanProperty()) .property("patient", new RefProperty("#/definitions/PatientGetRef")) .property("encounter", new RefProperty("#/definitions/EncounterGetRef")) .property("orders", new ArrayProperty(new RefProperty("#/definitions/OrderGetRef"))) .property("orderSet", new RefProperty("#/definitions/OrdersetGetRef")); } else if (rep instanceof RefRepresentation) { modelImpl .property("display", new StringProperty()) .property("uuid", new StringProperty()); } return modelImpl; }</code><technical_language>Is this if condition required ? i If statement this is</technical_language>

Target:
public Model getGETModel(Representation rep) { ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); if (rep instanceof DefaultRepresentation) { modelImpl.property("uuid", new StringProperty()).property("display", new StringProperty()) .property("voided", new BooleanProperty()) .property("patient", new RefProperty("#/definitions/PatientGetRef")) .property("encounter", new RefProperty("#/definitions/EncounterGetRef")) .property("orders", new RefProperty("#/definitions/OrderGetRef")) .property("orderSet", new RefProperty("#/definitions/OrdersetGetRef")); } else if (rep instanceof FullRepresentation) { modelImpl.property("uuid", new StringProperty()).property("display", new StringProperty()) .property("voided", new BooleanProperty()).property("auditInfo", new BooleanProperty()) .property("patient", new RefProperty("#/definitions/PatientGetRef")) .property("encounter", new RefProperty("#/definitions/EncounterGetRef")) .property("orders", new ArrayProperty(new RefProperty("#/definitions/OrderGetRef"))) .property("orderSet", new RefProperty("#/definitions/OrdersetGetRef")); } else if (rep instanceof RefRepresentation) { modelImpl.property("display", new StringProperty()).property("uuid", new StringProperty()); } return modelImpl; }
Source:
<code>public void onNext(T t) { if (!isDisposed()) { try { if (internalBuffer.getAndIncrement() < bufferSize) { onNext.accept(t); } <START> if (internalBuffer.get() == bufferSize) { <END> onComplete.run(); get().cancel(); } } catch (Throwable e) { Exceptions.throwIfFatal(e); get().cancel(); onError(e); } } }</code><technical_language>end flow bufferSize number of elements received</technical_language>

Target:
public void onNext(T t) { if (!isDisposed()) { try { onNext.accept(t); int c = consumed + 1; if (c == limit) { consumed = 0; get().request(limit); } else { consumed = c; } } catch (Throwable e) { Exceptions.throwIfFatal(e); get().cancel(); onError(e); } } }
Source:
<code>public void testSetCustomDimensions() throws Exception { CustomDimensions customDimensions = new CustomDimensions(); customDimensions.set(1, "foo"); customDimensions.set(2, "bar"); <START> customDimensions.set(3, "empty").set(3, null); <END> QueryHashMap<String, String> queryParams = parseEventUrl(customDimensions.build()); assertEquals(queryParams.get("dimension1"), "foo"); assertEquals(queryParams.get("dimension2"), "bar"); assertFalse(queryParams.containsKey("dimension3")); }</code><technical_language>Good check! is expected behavior client/server side for empty string ""</technical_language>

Target:
public void testSetCustomDimensions() throws Exception { CustomDimensions customDimensions = new CustomDimensions(); customDimensions.set(0, "foo"); customDimensions.set(1, "foo"); customDimensions.set(2, "bar"); customDimensions.set(3, "empty").set(3, null); customDimensions.set(4, ""); QueryHashMap<String, String> queryParams = parseEventUrl(customDimensions.build()); assertEquals(queryParams.get("dimension1"), "foo"); assertEquals(queryParams.get("dimension2"), "bar"); assertFalse(queryParams.containsKey("dimension0")); assertFalse(queryParams.containsKey("dimension3")); assertFalse(queryParams.containsKey("dimension4")); }
Source:
<code><START> public void batch_mutate(String kvsMethodName, <END> Map<ByteBuffer, Map<String, List<Mutation>>> mutation_map, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { mutation_map.forEach((key, tableToMutations) -> { tableToMutations.forEach((table, mutations) -> { getCellsWrittenMeterForTable(table).mark(mutations.size()); }); }); }</code><technical_language>call delegate in means writes happen</technical_language>

Target:
public void batch_mutate(String kvsMethodName, Map<ByteBuffer, Map<String, List<Mutation>>> mutation_map, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { delegate.batch_mutate(kvsMethodName, mutation_map, consistency_level); Map<String, Long> tablesToCells = new HashMap<>(mutation_map.size()); mutation_map.values().forEach(tableToCellsMap -> { tableToCellsMap.forEach((table, cells) -> { Long numberOfCells = tablesToCells.getOrDefault(table, 0L); tablesToCells.put(table, numberOfCells + cells.size()); }); }); tablesToCells.forEach((table, numberOfCells) -> getCellsWrittenMeterForTable(table).mark(numberOfCells)); }
Source:
<code><START> public void setReplicators(Replicator[] replicators) { <END> if (replicators != null && replicators.length > 0) { if (mReplicationPolicyManager == null) { mReplicationPolicyManager = new ReplicationPolicyManager(); } mReplicationPolicyManager.addReplicators(replicators); mReplicationPolicyManager.setReplicationsCompletedListener(this); synchronized (mCommandQueue) { mReplicatorsInitialised = true; for (Message msg : mCommandQueue) { mServiceHandler.sendMessage(msg); } mCommandQueue.clear(); } } else { throw new RuntimeException( "No replications setup. Please pass Replicators to setReplicators(Replicator[])"); } }</code><technical_language>is expected behaviour if this method is called twice? a bit concerned appears a setter, present add additional replicators. happened in previous implementation if Replicator[] returned getReplicators() modified. I need do of things: 1. allow list changed throw IllegalStateException similar if setReplicators is called twice. 2. setter behaviour creating a new ReplicationPolicyManager (or clear existing replicators calling mReplicationPolicyManager.addReplicators is a do this present). 3. Rename method addReplicators allow replicators added. I for cases 2 3 some considerations need for command queue is processed if commands effectively apply groups of replicators</technical_language>

Target:
public void setReplicators(Replicator[] replicators) { if (mReplicatorsInitialised) { throw new IllegalStateException("Replicators already set"); } if (replicators != null && replicators.length > 0) { if (mReplicationPolicyManager == null) { mReplicationPolicyManager = new ReplicationPolicyManager(); } mReplicationPolicyManager.addReplicators(replicators); mReplicationPolicyManager.setReplicationsCompletedListener(this); synchronized (mCommandQueue) { mReplicatorsInitialised = true; for (Message msg : mCommandQueue) { mServiceHandler.sendMessage(msg); } mCommandQueue.clear(); } } else { throw new IllegalArgumentException( "No replications setup. Please pass Replicators to setReplicators(Replicator[])"); } }
Source:
<code>public Location getLocation() { <START> return new Location((Extent) getEntityWorld(), new Vector3d(getPositionVector().xCoord, getPositionVector().yCoord, <END> getPositionVector().zCoord)); }</code><technical_language>This added [VecHelper](<LINK_0> for convenience</technical_language>

Target:
public Location getLocation() { return new Location((Extent) getEntityWorld(), VecHelper.toVector(getPositionVector())); }
Source:
<code>private boolean containsInstance(Object bean) { for (Object element : list) { <START> if (JHelper.objectSameReference(element, bean)) { <END> return true; } } return false; }</code><technical_language>== here. Method name usage clear</technical_language>

Target:
private boolean containsInstance(Object bean) { for (Object element : list) { if (element == bean) { return true; } } return false; }
Source:
<code>public static String resolveAsStringConstant(ExpressionTree tree) { ExpressionTree expression = tree; while (expression.is(Tree.Kind.PARENTHESIZED_EXPRESSION)) { expression = ((ParenthesizedTree) expression).expression(); } if (expression.is(Tree.Kind.MEMBER_SELECT)) { expression = ((MemberSelectExpressionTree) expression).identifier(); } if (expression.is(Tree.Kind.IDENTIFIER)) { IdentifierTree id = (IdentifierTree) expression; Symbol symbol = id.symbol(); if (symbol instanceof JavaSymbol.ConstantJavaSymbol) { <START> Object constantValue = ((JavaSymbol.ConstantJavaSymbol) symbol).value(); <END> if (constantValue instanceof String) { return (String) constantValue; } } } if (expression.is(Tree.Kind.STRING_LITERAL)) { return LiteralUtils.trimQuotes(((LiteralTree) expression).value()); } if (expression.is(Tree.Kind.PLUS)) { BinaryExpressionTree binaryExpression = (BinaryExpressionTree) expression; String left = resolveAsStringConstant(binaryExpression.leftOperand()); String right = resolveAsStringConstant(binaryExpression.rightOperand()); if (left != null && right != null) { return left + right; } } return null; }</code><technical_language>For this I value() method returning optional variable symbol : empty varibable wrapping a constants</technical_language>

Target:
public static String resolveAsStringConstant(ExpressionTree tree) { Object constant = resolveAsConstant(tree); return constant instanceof String ? (String) constant : null; }
Source:
<code>private static CloseableHttpResponse getAllRoutingData() throws IOException { HttpGet requestAllData = new HttpGet( MSDS_ENDPOINT + MetadataStoreRoutingConstants.MSDS_GET_ALL_ROUTING_DATA_ENDPOINT); try (CloseableHttpClient httpClient = HttpClients.custom() <START> .setConnectionBackoffStrategy(new DefaultBackoffStrategy()) <END> .setRetryHandler(new DefaultHttpRequestRetryHandler()).build()) { return httpClient.execute(requestAllData); } }</code><technical_language>I a timeout setting. If set timeout, system defined timeout infinite timeout. system responsive stable, considering timeout: connectTimeout, socketTimeout, etc.</technical_language>

Target:
private static String getAllRoutingData() throws IOException { ENDPOINT should provide high-availability - it risks becoming a single point of failure if it's backed by a single IP address/host HttpGet requestAllData = new HttpGet( MSDS_ENDPOINT + MetadataStoreRoutingConstants.MSDS_GET_ALL_ROUTING_DATA_ENDPOINT); RequestConfig config = RequestConfig.custom().setConnectTimeout(HTTP_TIMEOUT_IN_MS) .setConnectionRequestTimeout(HTTP_TIMEOUT_IN_MS).setSocketTimeout(HTTP_TIMEOUT_IN_MS) .build(); try (CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(config) .setConnectionBackoffStrategy(new DefaultBackoffStrategy()) .setRetryHandler(new DefaultHttpRequestRetryHandler()).build()) { HttpEntity entity = httpClient.execute(requestAllData).getEntity(); if (entity == null) { throw new IOException("Response's entity is null!"); } return EntityUtils.toString(entity, "UTF-8"); } }
Source:
<code>public void testNonQuietOutputIsSorted() throws Exception { when(options.getBoolean("q")).thenReturn(false); <START> int ret = command.run(options, client, out, false, null); <END> assertEquals(0, ret); assertEquals(expectedOrder, readJobIdsFromOutput(true)); }</code><technical_language>final inline call assertEquals</technical_language>

Target:
public void testNonQuietOutputIsSorted() throws Exception { when(options.getBoolean("q")).thenReturn(false); final int ret = command.run(options, client, out, false, null); assertEquals(0, ret); assertEquals(expectedOrder, readJobIdsFromOutput(true)); }
Source:
<code><START> static final File baseSchemaIndexFolder( File databaseStoreDir ) <END> { return path( databaseStoreDir, "schema", "index" ); }</code><technical_language>need final</technical_language>

Target:
static File baseSchemaIndexFolder( File databaseStoreDir ) { return path( databaseStoreDir, "schema", "index" ); }
Source:
<code>public String setInputCommand(Command command){ <START> switch(((StringType) command).toString().toLowerCase()){ <END> case "btaudio": return "extInput:btAudio"; case "tv": return "extInput:tv"; case "analog": return "extInput:line"; case "usb": return "storage:usb1"; case "network": return "dlna:music"; } return ((StringType) command).toString(); }</code><technical_language>need cast StringType here. (same for other handlers)</technical_language>

Target:
public String setInputCommand(Command command) { switch (command.toString().toLowerCase()) { case "btaudio": return "extInput:btAudio"; case "tv": return "extInput:tv"; case "analog": return "extInput:line"; case "usb": return "storage:usb1"; case "network": return "dlna:music"; case "cast": return "cast:audio"; } return command.toString(); }
Source:
<code>private XADataSource createXaDataSourceInstance(String className) { try { Class<?> dataSourceClass = ClassUtils.forName(className, this.getClass().getClassLoader()); Object instance = BeanUtils.instantiate(dataSourceClass); Assert.isInstanceOf(XADataSource.class, instance); return (XADataSource) instance; } catch (Exception ex) { throw new IllegalStateException( <START> "Unable to create XADataSource instance from '" + className + "'"); <END> } }</code><technical_language>good include causing exception user created</technical_language>

Target:
private XADataSource createXaDataSourceInstance(String className) { try { Class<?> dataSourceClass = ClassUtils.forName(className, this.getClass().getClassLoader()); Object instance = BeanUtils.instantiate(dataSourceClass); Assert.isInstanceOf(XADataSource.class, instance); return (XADataSource) instance; } catch (Exception ex) { throw new IllegalStateException( "Unable to create XADataSource instance from '" + className + "'", ex); } }
Source:
<code><START> private void setValuesForGroupby(List<BlockBuilder> blockBuilders, List<Type> types, int numGroupByClause, JsonNode group, String[] values) <END> { for (int k = 0; k < group.size(); k++) { setValue(types.get(k), blockBuilders.get(k), group.get(k).asText()); } for (int aggrIndex = 0; aggrIndex < values.length; ++aggrIndex) { int metricColumnIndex = aggrIndex + numGroupByClause; if (metricColumnIndex < blockBuilders.size()) { setValue(types.get(metricColumnIndex), blockBuilders.get(metricColumnIndex), values[aggrIndex]); } } }</code><technical_language>stream() foreach(). In general, prefer lambdas classic for loops for kinds of cases</technical_language>

Target:
private void setValuesForGroupby( List<BlockBuilder> blockBuilders, List<Type> types, int numGroupByClause, JsonNode group, String[] values) { for (int i = 0; i < group.size(); i++) { setValue(types.get(i), blockBuilders.get(i), group.get(i).asText()); } for (int i = 0; i < values.length; i++) { int metricColumnIndex = i + numGroupByClause; if (metricColumnIndex < blockBuilders.size()) { setValue(types.get(metricColumnIndex), blockBuilders.get(metricColumnIndex), values[i]); } } }
Source:
<code>private static void invokeForEachKeyFactory(KeyFactoryRunnable runnable) throws Exception { for (Provider provider : getKeyFactoryProviders()) { try { runnable.run(getKeyFactory(provider)); <START> } catch (Exception e) { <END> throw new Exception("provider: " + provider.getName(), e); } } }</code><technical_language>Throwable</technical_language>

Target:
private static void invokeForEachKeyFactory(KeyFactoryRunnable runnable) throws Exception { for (Provider provider : getKeyFactoryProviders()) { try { runnable.run(getKeyFactory(provider)); } catch (Throwable e) { throw new Exception("provider: " + provider.getName(), e); } } }
Source:
<code>protected void doConnectViaSsh(Deployment deployment, LoginCredentials creds) { SshClient ssh = sshFactory.create(HostAndPort.fromParts(deployment.virtualIPs().get(0).address(), 22), creds); try { ssh.connect(); ExecResponse hello = ssh.exec("echo hello"); assertEquals(hello.getOutput().trim(), "hello"); System.err.println(ssh.exec("df -k").getOutput()); System.err.println(ssh.exec("mount").getOutput()); <START> System.err.println(ssh.exec("uname -a").getOutput()); <END> } finally { if (ssh != null) ssh.disconnect(); } }</code><technical_language>Consider removing console output</technical_language>

Target:
protected void doConnectViaSsh(Deployment deployment, LoginCredentials creds) { SshClient ssh = sshFactory.create(HostAndPort.fromParts(deployment.virtualIPs().get(0).address(), 22), creds); try { ssh.connect(); ExecResponse hello = ssh.exec("echo hello"); assertEquals(hello.getOutput().trim(), "hello"); } finally { if (ssh != null) ssh.disconnect(); } }
Source:
<code>public GarageDoorData(JsonNode rootNode) throws IOException { if (rootNode.has("Devices")) { JsonNode node = rootNode.get("Devices"); if (node.isArray()) { logger.trace("Chamberlain MyQ Devices:"); int arraysize = node.size(); for (int i = 0; i < arraysize; i++) { int deviceId = node.get(i).get("MyQDeviceId").asInt(); String deviceName = node.get(i).get("SerialNumber") .asText(); String deviceType = node.get(i).get("MyQDeviceTypeName") .asText(); if (deviceType.contains("Garage") && deviceType.contains("Door") <START> && deviceType.contains("Opener")) { <END> JsonNode attributes = node.get(i).get("Attributes"); if (attributes.isArray()) { int attributesSize = attributes.size(); for (int j = 0; j < attributesSize; j++) { String attributeName = attributes.get(j) .get("AttributeDisplayName").asText(); if (attributeName.contains("doorstate")) { int doorstate = attributes.get(j) .get("Value").asInt(); logger.trace( "DeviceID: DeviceName: DeviceType: Doorstate : ", deviceId, deviceName, deviceType, doorstate); devices.add(new GarageDoorDevice(deviceId, deviceType, deviceName, doorstate)); break; } } } } } } } }</code><technical_language>Suggest instead a static final java.util.regex.Pattern match strings in case change later</technical_language>

Target:
public GarageDoorData(JsonNode rootNode) throws IOException { if (rootNode.has("Devices")) { JsonNode node = rootNode.get("Devices"); if (node.isArray()) { logger.trace("Chamberlain MyQ Devices:"); int arraysize = node.size(); for (int i = 0; i < arraysize; i++) { int deviceId = node.get(i).get("MyQDeviceId").asInt(); String deviceName = node.get(i).get("SerialNumber") .asText(); String deviceType = node.get(i).get("MyQDeviceTypeName") .asText(); if (DEVICE_TYPE_PATTERN.matcher(deviceType).matches()) { JsonNode attributes = node.get(i).get("Attributes"); if (attributes.isArray()) { int attributesSize = attributes.size(); for (int j = 0; j < attributesSize; j++) { String attributeName = attributes.get(j) .get("AttributeDisplayName").asText(); if (attributeName.contains("doorstate")) { int doorstate = attributes.get(j) .get("Value").asInt(); logger.trace( "DeviceID: DeviceName: DeviceType: Doorstate : ", deviceId, deviceName, deviceType, doorstate); devices.add(new GarageDoorDevice(deviceId, deviceType, deviceName, doorstate)); break; } } } } } } } }
Source:
<code>public static void setStartupBehavior(int startupBehavior) { log(LogUtil.info("setStartupBehavior = '" + startupBehavior + "' 0=dialog, 1=background, 2=disable")); IEclipsePreferences node = getPreferences(); if (startupBehavior == TipManager.START_DIALOG) { node.put(PREF_STARTUP_BEHAVIOR, PREF_STARTUP_BEHAVIOR_DIALOG); } else if (startupBehavior == TipManager.START_BACKGROUND) { node.put(PREF_STARTUP_BEHAVIOR, PREF_STARTUP_BEHAVIOR_BACKGROUND); } else { node.put(PREF_STARTUP_BEHAVIOR, PREF_STARTUP_BEHAVIOR_DISABLE); } try { node.flush(); } catch (BackingStoreException e) { throw new <START> RuntimeException(e); <END> } }</code><technical_language>This is highly unexpected. I log original error instead return</technical_language>

Target:
public static void setStartupBehavior(int startupBehavior) { log(LogUtil.info("setStartupBehavior = '" + startupBehavior + "' 0=dialog, 1=background, 2=disable")); IEclipsePreferences node = getPreferences(); if (startupBehavior == TipManager.START_DIALOG) { node.put(PREF_STARTUP_BEHAVIOR, PREF_STARTUP_BEHAVIOR_DIALOG); } else if (startupBehavior == TipManager.START_DISABLE) { node.put(PREF_STARTUP_BEHAVIOR, PREF_STARTUP_BEHAVIOR_DISABLE); } else { node.put(PREF_STARTUP_BEHAVIOR, PREF_STARTUP_BEHAVIOR_BACKGROUND); } try { node.flush(); } catch (BackingStoreException e) { log(LogUtil.error(e)); } }