auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public boolean areDevicesCoupled(final String deviceId, final String mbusDeviceId, Short mbusChannel) { final Device device = this.deviceRepository.findByDeviceIdentification(deviceId); final SmartMeter mbusDevice = this.smartMeterRepository.findByDeviceIdentification(mbusDeviceId); <START> return (mbusDevice != null) <END> && (device != null) && (mbusDevice.getGatewayDevice() != null) && ((mbusDevice.getGatewayDevice().getId() != null) && mbusDevice.getGatewayDevice().getId().equals(device.getId())) && ((mbusChannel == null) || mbusDevice.getChannel().equals(mbusChannel)); }</code><technical_language>I prefer put this contraption in a method, give a name does. (And local variables split logic in smaller chunks.)</technical_language>

Target:
public boolean areDevicesCoupled(final String deviceId, final String mbusDeviceId, Short mbusChannel) { final Device device = this.deviceRepository.findByDeviceIdentification(deviceId); final SmartMeter mbusDevice = this.smartMeterRepository.findByDeviceIdentification(mbusDeviceId); return this.areDevicesCoupled(mbusDevice, device) && this.isMbusChannelEqual(mbusChannel, mbusDevice); }
Source:
<code>public void setOnGround(boolean onGround) { super.setOnGround(onGround); if (onGround && this.getFallDistance() > 3) { float damage = this.getFallDistance() - 3; damage = Math.round(damage); <START> if (damage == 0) return; <END> EntityDamageEvent ev = new EntityDamageEvent(this, EntityDamageEvent.DamageCause.FALL, damage); this.getServer().getPluginManager().callEvent(ev); if (ev.isCancelled()) return; this.setLastDamageCause(ev); this.damage(damage); } this.setFallDistance(0); }</code><technical_language>{}</technical_language>

Target:
public void setOnGround(boolean onGround) { super.setOnGround(onGround); if (onGround && this.getFallDistance() > 3) { float damage = this.getFallDistance() - 3; damage = Math.round(damage); if (damage == 0) { return; } EntityDamageEvent ev = new EntityDamageEvent(this, EntityDamageEvent.DamageCause.FALL, damage); this.getServer().getPluginManager().callEvent(ev); if (ev.isCancelled()) { return; } this.setLastDamageCause(ev); this.damage(ev.getDamage()); } this.setFallDistance(0); }
Source:
<code>public static String readPasswordIfNeeded(String user, String pwd, String prompt) throws IOException { if ((null!=user) && (user.trim().length()>0)) { if ((pwd==null) || (pwd.trim().length() == 0)) { Console console = System.console(); if (console == null) { throw new IOException("Unable to read password from console."); } <START> return new String(console.readPassword(prompt)); <END> } } return pwd; }</code><technical_language>readPassword() takes a format string arguments for format. If prompt contains %s, throw IllegalFormatException expects a matching argument. safe, readPassword("%s", prompt). readPassword() return null if EOF is read input. In case, prompt for input password is read. A while loop do</technical_language>

Target:
public static String readPasswordIfNeeded(String user, String pwd, String prompt) throws IOException { if ((null!=user) && (user.trim().length()>0)) { if ((pwd==null) || (pwd.trim().length() == 0)) { Console console = System.console(); if (console == null) { throw new IOException("Unable to read password from console."); } char[] val = console.readPassword("%s", prompt); if (val != null) { return new String(val); } else { return ""; } } } return pwd; }
Source:
<code>CallBatcherImpl(DatabaseClient client, CallManagerImpl.CallerImpl<E> caller, Class<W> inputType, CallArgsGenerator<E> generator) { <START> this(client, caller, inputType); <END> this.callArgsGenerator = generator; }</code><technical_language>throw IllegalArgumentException if generator is null</technical_language>

Target:
CallBatcherImpl(DatabaseClient client, CallManagerImpl.CallerImpl<E> caller, Class<W> inputType, CallArgsGenerator<E> generator) { this(client, caller, inputType); if(generator == null) throw new IllegalArgumentException("Call Argument Generator cannot be null."); this.callArgsGenerator = generator; }
Source:
<code>private Injector createSysInjector() { final List<Module> modules = new ArrayList<Module>(); modules.add(new WorkQueue.Module()); modules.add(new ChangeHookRunner.Module()); modules.add(new ReceiveCommitsExecutorModule()); modules.add(cfgInjector.getInstance(GerritGlobalModule.class)); modules.add(new DefaultCacheFactory.Module()); modules.add(new SmtpEmailSender.Module()); modules.add(new SignedTokenEmailTokenVerifier.Module()); modules.add(new PluginModule()); modules.add(new CanonicalWebUrlModule() { @Override protected Class<? extends Provider<String>> provider() { return HttpCanonicalWebUrlProvider.class; } }); modules.add(SshKeyCacheImpl.module()); modules.add(new MasterNodeStartup()); modules.add(new AbstractModule() { @Override protected void configure() { <START> bindConstant().annotatedWith(Names.named("Headless")).to(false); <END> } }); return cfgInjector.createChildInjector(modules); }</code><technical_language>This is hazard of @Named. name is consistent name in other places. :-) Please define new type carry this information like: public class GerritUiOptions { public boolean enableDefaultUi() { return !headless; } } inject instance of GerritUiOptions bind(GerritUiOptions.class).toInstance(options); If want @Named a Boolean define a public static final String in @Named annotation reduce risk a typo</technical_language>

Target:
private Injector createSysInjector() { final List<Module> modules = new ArrayList<Module>(); modules.add(new WorkQueue.Module()); modules.add(new ChangeHookRunner.Module()); modules.add(new ReceiveCommitsExecutorModule()); modules.add(cfgInjector.getInstance(GerritGlobalModule.class)); modules.add(new DefaultCacheFactory.Module()); modules.add(new SmtpEmailSender.Module()); modules.add(new SignedTokenEmailTokenVerifier.Module()); modules.add(new PluginModule()); modules.add(new CanonicalWebUrlModule() { @Override protected Class<? extends Provider<String>> provider() { return HttpCanonicalWebUrlProvider.class; } }); modules.add(SshKeyCacheImpl.module()); modules.add(new MasterNodeStartup()); modules.add(new AbstractModule() { @Override protected void configure() { bind(GerritUiOptions.class).toInstance(new GerritUiOptions(false)); } }); return cfgInjector.createChildInjector(modules); }
Source:
<code>public TileEntity createTileEntity(World var1, IBlockState state) { try { for (EntityMetaTag tag : EntityMetaTag.values()) { if (tag.meta == state.getBlock().getMetaFromState(state)) { return (TileEntity) tag.cls.getConstructor().newInstance(); } } System.out.println("Unknown block meta-tag: " + state.getBlock().getMetaFromState(state)); return (TileEntity) EntityMetaTag.Basic.cls.getConstructor().newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { <START> e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } while (true) ; <END> }</code><technical_language>Absolutely not. Do do that</technical_language>

Target:
public TileEntity createTileEntity(World var1, IBlockState state) { try { for (EntityMetaTag tag : EntityMetaTag.values()) { if (tag.meta == state.getBlock().getMetaFromState(state)) { return (TileEntity) tag.cls.getConstructor().newInstance(); } } System.out.println("Unknown block meta-tag: " + state.getBlock().getMetaFromState(state)); return (TileEntity) EntityMetaTag.Basic.cls.getConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { e.printStackTrace(); } throw new IllegalStateException("Failed to create tile entity."); }
Source:
<code><START> public boolean isMainPage() { <END> return properties.isMainPage(); }</code><technical_language>perfectly valid construct a PageTitle PageProperties, do need a null check in isDisambiguationPage()</technical_language>

Target:
public boolean isMainPage() { if (hasProperties()) { return properties.isMainPage(); } else { throw new NullPointerException("No PageProperties object exists for this PageTitle!"); } }
Source:
<code>public void required() { realm.beginTransaction(); MutableRealmIntegerTypes c1 = realm.createObject(MutableRealmIntegerTypes.class); realm.commitTransaction(); <START> Table table = realm.getTable(MutableRealmIntegerTypes.class); <END> assertFalse(table.isColumnNullable(table.getColumnIndex(MutableRealmIntegerTypes.FIELD_NONNULLABLE_MUTABLEREALMINTEGER))); try { c1.columnNonNullableMutableRealmInteger.set(null); fail("should not be able to set an @Required MutableRealmInteger null"); } catch(IllegalStateException ignore) { } c1 = new MutableRealmIntegerTypes(); c1.columnNonNullableMutableRealmInteger.set(null); realm.beginTransaction(); try { MutableRealmIntegerTypes c2 = realm.copyToRealm(c1); fail("should not be able to copy an null valute to a @Required MutableRealmInteger"); } catch(IllegalArgumentException ignore) { } realm.commitTransaction(); }</code><technical_language>realm.getSchema().get("MutableRealmIntegerTypes").isNullable(MutableRealmIntegerTypes.FIELD_NONNULLABLE_MUTABLEREALMINTEGER) instead. need reduce usage of level APIs in test if is possible. level API changed in future (we move more Object Store.)</technical_language>

Target:
public void required() { realm.beginTransaction(); MutableRealmIntegerTypes c1 = realm.createObject(MutableRealmIntegerTypes.class); realm.commitTransaction(); assertFalse( realm.getSchema().get("MutableRealmIntegerTypes") .isNullable(MutableRealmIntegerTypes.FIELD_NONNULLABLE_MUTABLEREALMINTEGER)); try { c1.columnNonNullableMutableRealmInteger.set(null); fail("should not be able to set an @Required MutableRealmInteger null"); } catch(IllegalStateException ignore) { } c1 = new MutableRealmIntegerTypes(); c1.columnNonNullableMutableRealmInteger.set(null); realm.beginTransaction(); try { MutableRealmIntegerTypes c2 = realm.copyToRealm(c1); fail("should not be able to copy an null valute to a @Required MutableRealmInteger"); } catch(IllegalArgumentException ignore) { } realm.commitTransaction(); }
Source:
<code><START> public boolean start() <END> { if (!started.get()) { LOGGER.info("started polling lookup [%s]", id); started.set(pollingLookup.isOpen()); } return started.get(); }</code><technical_language>start stop called time</technical_language>

Target:
public boolean start() { synchronized (started) { if (!started.get()) { LOGGER.info("started polling lookup [%s]", id); started.set(pollingLookup.isOpen()); } return started.get(); } }
Source:
<code>public void start() throws BundleException { final InjectorConfig config = new InjectorConfig(this); config.setListener(new InjectorCreationFailListener() { @Override public void creationFailed() { try { injectorCreationSuccess = false; started = false; bundleContext.getBundle().stop(); } catch (BundleException e) { <START> e.printStackTrace(); <END> } } }); Dictionary<String, Object> properties = new Hashtable<String, Object>(); registration = bundleContext.registerService(InjectorConfig.class.getName(), config, properties); if (injectorCreationSuccess) { started = true; } else { started = false; throw new BundleException("Failed to create an injector", BundleException.ACTIVATOR_ERROR); } }</code><technical_language>logger</technical_language>

Target:
public void start() throws BundleException { final InjectorConfig config = new InjectorConfig(this); Dictionary<String, Object> properties = new Hashtable<String, Object>(); bundleContext.registerService(InjectorConfig.class.getName(), config, properties); if (injectorCreationSuccess) { started = true; } else { started = false; throw new BundleException("Failed to create an injector", BundleException.ACTIVATOR_ERROR); } }
Source:
<code>public Security createCredentials(@NonNull final String strategy, @NonNull final String kuid, @NonNull final JSONObject credentials, final Options options, final ResponseListener<JSONObject> listener) { try { JSONObject body = new JSONObject() .put("strategy", strategy) <START> .put("kuid", kuid) <END> .put("body", credentials); kuzzle.query(buildQueryArgs("security", "createCredentials"), body, options, new OnQueryDoneListener() { @Override public void onSuccess(JSONObject response) { try { if (listener != null) { listener.onSuccess(response.getJSONObject("result")); } } catch (JSONException e) { throw new RuntimeException(e); } } @Override public void onError(JSONObject error) { if (listener != null) { listener.onError(error); } } }); } catch (JSONException e) { throw new RuntimeException(e); } return this; }</code><technical_language>Kuzzle's createCredentials awaits _id, kuid</technical_language>

Target:
public Security createCredentials(@NonNull final String strategy, @NonNull final String kuid, @NonNull final JSONObject credentials, final Options options, final ResponseListener<JSONObject> listener) { try { JSONObject body = new JSONObject() .put("strategy", strategy) .put("_id", kuid) .put("body", credentials); kuzzle.query(buildQueryArgs("security", "createCredentials"), body, options, new OnQueryDoneListener() { @Override public void onSuccess(JSONObject response) { try { if (listener != null) { listener.onSuccess(response.getJSONObject("result")); } } catch (JSONException e) { throw new RuntimeException(e); } } @Override public void onError(JSONObject error) { if (listener != null) { listener.onError(error); } } }); } catch (JSONException e) { throw new RuntimeException(e); } return this; }
Source:
<code>public static void clean(ByteBuffer buffer) { try { Object cleaner = CLEANER_FIELD.get(buffer); CLEAN_METHOD.invoke(cleaner); <START> } catch (IllegalAccessException | InvocationTargetException e) { <END> logger.warn("Clean failed for buffer " + buffer.getClass().getSimpleName(), e); } }</code><technical_language>cases of uninitialized (null) field and/or method handled somehow</technical_language>

Target:
public static void clean(ByteBuffer buffer) { if (CLEANER_FIELD == null || CLEAN_METHOD == null) { return; } try { Object cleaner = CLEANER_FIELD.get(buffer); CLEAN_METHOD.invoke(cleaner); } catch (IllegalAccessException | InvocationTargetException | NullPointerException e) { logger.warn("Clean failed for buffer " + buffer.getClass().getSimpleName(), e); } }
Source:
<code>public Builder setPrefixName(String prefix) { <START> this.keyName = prefix; <END> return this; }</code><technical_language>add separate variable for prefix. This add confusion difference b/w key prefix</technical_language>

Target:
public Builder setPrefixName(String prefix) { this.name = prefix; return this; }
Source:
<code>private Collection<String> computeRowValueCollection(int lineNumber) { Collection<String> rowValues = newLinkedList(); for (String type : modulesByType.keySet()) { <START> Iterator<ModuleDefinitionResource> modules = modulesByType.get(type).iterator(); <END> ModuleDefinitionResource module = Iterators.get(modules, lineNumber, null); rowValues.add(computeModuleValue(module)); } return rowValues; }</code><technical_language>This rescan list time. Overall, this class a lot of ceremony draw table. code is "easy understand", maintaining 4 counters current row type table.getRows().get(i) done trick. this trashed,</technical_language>

Target:
private Collection<String> computeRowValueCollection(int lineNumber) { Collection<String> rowValues = newLinkedList(); for (String type : modulesByType.keySet()) { ModuleDefinitionResource module = Iterators.get(iteratorsByType.get(type), lineNumber, null); rowValues.add(computeModuleValue(module)); } return rowValues; }
Source:
<code>private void addBondSlaveToBonds(Nic sourceNic, String destinationNicName) { String <START> bondName = <END> sourceNic.getBondName(); if (!destinationBondSlavesByName.containsKey(bondName)) { destinationBondSlavesByName.put(bondName, new ArrayList<>()); } destinationBondSlavesByName.get(bondName).add(destinationNicName); }</code><technical_language>sourceBondName</technical_language>

Target:
private void addBondSlaveToBonds(Nic sourceNic, String destinationNicName) { String sourceBondName = sourceNic.getBondName(); if (!destinationBondSlavesByName.containsKey(sourceBondName)) { destinationBondSlavesByName.put(sourceBondName, new ArrayList<>()); } destinationBondSlavesByName.get(sourceBondName).add(destinationNicName); }
Source:
<code>public synchronized long getTimeToNextJob() { TimerJobInstance item = (TimerJobInstance) queue.peek(); <START> return (item != null && item.getTrigger().hasNextFireTime() != null) ? item.getTrigger().hasNextFireTime().getTime() - this.timer.get() : -1; <END> }</code><technical_language>This happen</technical_language>

Target:
public synchronized long getTimeToNextJob() { TimerJobInstance item = (TimerJobInstance) queue.peek(); return (item != null) ? item.getTrigger().hasNextFireTime().getTime() - this.timer.get() : -1; }
Source:
<code>public void handleIncoming(@PathVariable String configName, @RequestParam Map<String, String> params) { LOGGER.info("Incoming SMS - configName = {}, params = {}", configName, params); Config config; if (configService.hasConfig(configName)) { config = configService.getConfig(configName); } else { String msg = String.format("Invalid config in incoming request: %s, params: %s", configName, params); LOGGER.error(msg); statusMessageService.warn(msg, SMS_MODULE); return; } Template template = templateService.getTemplate(config.getTemplateName()); eventRelay.sendEventMessage(inboundEvent(config.getName(), <START> getSenderKey(params, template), <END> getRecipientKey(params, template), getMessageKey(params, template), getMsgIdKey(params, template), getTimestampKey(params, template))); smsRecordsDataService.create(new SmsRecord(config.getName(), INBOUND, getSenderKey(params, template), getMessageKey(params, template), now(), getStatusKey(params, template), null, null, getMsgIdKey(params, template), null)); }</code><technical_language>naming is wrong, do return keys actual values, Key part get removed</technical_language>

Target:
public void handleIncoming(@PathVariable String configName, @RequestParam Map<String, String> params) { LOGGER.info("Incoming SMS - configName = {}, params = {}", configName, params); Config config; if (configService.hasConfig(configName)) { config = configService.getConfig(configName); } else { String msg = String.format("Invalid config in incoming request: %s, params: %s", configName, params); LOGGER.error(msg); statusMessageService.warn(msg, SMS_MODULE); return; } Template template = templateService.getTemplate(config.getTemplateName()); eventRelay.sendEventMessage(inboundEvent(config.getName(), getSender(params, template), getRecipient(params, template), getMessage(params, template), getMsgId(params, template), getTimestamp(params, template))); smsRecordsDataService.create(new SmsRecord(config.getName(), INBOUND, getSender(params, template), getMessage(params, template), now(), getStatus(params, template), null, null, getMsgId(params, template), null)); }
Source:
<code>private void flatMap(IndexedRecord input, ProcessContext context) throws IOException { interpreter.set("inputJSON", new PyString(input.toString())); long timeInit = System.currentTimeMillis(); interpreter.exec("outputJSON = userFunction(inputJSON)"); PyObject outputList = interpreter.get("outputJSON"); if (outputList instanceof PyList) { PyList list = (PyList) outputList; for (Object output : list) { <START> if (jsonGenericRecordConverter == null) { <END> JsonSchemaInferrer jsonSchemaInferrer = new JsonSchemaInferrer(new ObjectMapper()); Schema jsonSchema = jsonSchemaInferrer.inferSchema(output.toString()); jsonGenericRecordConverter = new JsonGenericRecordConverter(jsonSchema); } GenericRecord outputRecord = jsonGenericRecordConverter.convertToAvro(output.toString()); context.output(outputRecord); } } }</code><technical_language>double check Talend code formatter</technical_language>

Target:
private void flatMap(IndexedRecord input, ProcessContext context) throws IOException { PyObject outputList = pyFn.__call__(new PyString(input.toString())); if (outputList instanceof PyList) { PyList list = (PyList) outputList; for (Object output : list) { if (jsonGenericRecordConverter == null) { JsonSchemaInferrer jsonSchemaInferrer = new JsonSchemaInferrer(new ObjectMapper()); Schema jsonSchema = jsonSchemaInferrer.inferSchema(output.toString()); jsonGenericRecordConverter = new JsonGenericRecordConverter(jsonSchema); } GenericRecord outputRecord = jsonGenericRecordConverter.convertToAvro(output.toString()); context.output(outputRecord); } } }
Source:
<code>public void saveOrder_shouldPassDrugOrderWithADrugNonCodedWhenDrugOrderIsNonCoded() throws Exception { Patient patient = Context.getPatientService().getPatient(7); CareSetting careSetting = Context.getOrderService().getCareSetting(2); OrderType orderType = Context.getOrderService().getOrderTypeByName("Drug order"); <START> assertNull(Context.getAdministrationService().getGlobalPropertyObject( <END> OpenmrsConstants.GLOBAL_PROPERTY_DRUG_ORDER_REQUIRE_DRUG)); DrugOrder order = new DrugOrder(); Encounter encounter = Context.getEncounterService().getEncounter(3); order.setEncounter(encounter); order.setConcept(Context.getOrderService().getNonCodedDrugConcept()); order.setDrugNonCoded("Non coded drug"); order.setPatient(patient); order.setCareSetting(careSetting); order.setOrderer(Context.getProviderService().getProvider(1)); order.setDateActivated(encounter.getEncounterDatetime()); order.setOrderType(orderType); order.setDosingType(FreeTextDosingInstructions.class); order.setInstructions("None"); order.setDosingInstructions("Test Instruction"); Errors errors = new BindException(order, "order"); new DrugOrderValidator().validate(order, errors); Assert.assertFalse(errors.hasFieldErrors()); }</code><technical_language>nan</technical_language>

Target:
public void saveOrder_shouldPassDrugOrderWithADrugNonCodedWhenDrugOrderIsNonCoded() throws Exception { executeDataSet("org/openmrs/api/include/OrderServiceTest-nonCodedDrugs.xml"); Patient patient = Context.getPatientService().getPatient(7); CareSetting careSetting = Context.getOrderService().getCareSetting(2); OrderType orderType = Context.getOrderService().getOrderTypeByName("Drug order"); GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DRUG_ORDER_REQUIRE_DRUG, "true"); Context.getAdministrationService().saveGlobalProperty(gp); DrugOrder order = new DrugOrder(); Encounter encounter = Context.getEncounterService().getEncounter(3); order.setEncounter(encounter); order.setConcept(Context.getOrderService().getNonCodedDrugConcept()); order.setDrugNonCoded("Non coded drug"); order.setPatient(patient); order.setCareSetting(careSetting); order.setOrderer(Context.getProviderService().getProvider(1)); order.setDateActivated(encounter.getEncounterDatetime()); order.setOrderType(orderType); order.setDosingType(FreeTextDosingInstructions.class); order.setInstructions("None"); order.setDosingInstructions("Test Instruction"); Errors errors = new BindException(order, "order"); new DrugOrderValidator().validate(order, errors); Assert.assertFalse(errors.hasFieldErrors()); }
Source:
<code>protected void endVmCommand() { if (CommandCoordinatorUtil.getChildCommandIds(getCommandId()).size() > 1) { <START> log.info("There are still running Coco tasks"); <END> return; } Snapshot createdSnapshot = getSnapshotDao().get(getVmId(), getParameters().getSnapshotType(), SnapshotStatus.LOCKED); boolean taskGroupSucceeded = createdSnapshot != null && getParameters().getTaskGroupSuccess(); boolean liveSnapshotRequired = isLiveSnapshotApplicable(); boolean liveSnapshotSucceeded = false; if (taskGroupSucceeded) { getSnapshotDao().updateStatus(createdSnapshot.getId(), SnapshotStatus.OK); if (liveSnapshotRequired) { liveSnapshotSucceeded = performLiveSnapshot(createdSnapshot); } else { if (getParameters().isSaveMemory() && createdSnapshot.containsMemory()) { logMemorySavingFailed(); getSnapshotDao().removeMemoryFromSnapshot(createdSnapshot.getId()); removeMemoryVolumesOfSnapshot(createdSnapshot); } } } else { if (createdSnapshot != null) { revertToActiveSnapshot(createdSnapshot.getId()); if (getParameters().isSaveMemory() && createdSnapshot.containsMemory()) { removeMemoryVolumesOfSnapshot(createdSnapshot); } } else { log.warn("No snapshot was created for VM '{}' which is in LOCKED status", getVmId()); } } incrementVmGeneration(); endActionOnDisks(); setSucceeded(taskGroupSucceeded && (!liveSnapshotRequired || liveSnapshotSucceeded)); getReturnValue().setEndActionTryAgain(false); }</code><technical_language>s/Coco/CoCo</technical_language>

Target:
protected void endVmCommand() { if (CommandCoordinatorUtil.getChildCommandIds(getCommandId()).size() > 1) { log.info("There are still running CoCo tasks"); return; } Snapshot createdSnapshot = getSnapshotDao().get(getVmId(), getParameters().getSnapshotType(), SnapshotStatus.LOCKED); boolean taskGroupSucceeded = createdSnapshot != null && getParameters().getTaskGroupSuccess(); boolean liveSnapshotRequired = isLiveSnapshotApplicable(); boolean liveSnapshotSucceeded = false; if (taskGroupSucceeded) { getSnapshotDao().updateStatus(createdSnapshot.getId(), SnapshotStatus.OK); if (liveSnapshotRequired) { liveSnapshotSucceeded = performLiveSnapshot(createdSnapshot); } else { if (getParameters().isSaveMemory() && createdSnapshot.containsMemory()) { logMemorySavingFailed(); getSnapshotDao().removeMemoryFromSnapshot(createdSnapshot.getId()); removeMemoryVolumesOfSnapshot(createdSnapshot); } } } else { if (createdSnapshot != null) { revertToActiveSnapshot(createdSnapshot.getId()); if (getParameters().isSaveMemory() && createdSnapshot.containsMemory()) { removeMemoryVolumesOfSnapshot(createdSnapshot); } } else { log.warn("No snapshot was created for VM '{}' which is in LOCKED status", getVmId()); } } incrementVmGeneration(); endActionOnDisks(); setSucceeded(taskGroupSucceeded && (!liveSnapshotRequired || liveSnapshotSucceeded)); getReturnValue().setEndActionTryAgain(false); }
Source:
<code>public void findDependedUponMethods() throws NoSuchMethodException { TestClass testClass = new TestClass(); ConstructorOrMethod constructorOrMethod = new ConstructorOrMethod(testClass.getClass().getMethod("dummyMethod")); IAnnotationFinder annotationFinder = new JDK15AnnotationFinder(new AnnotationTransformer()); ITestNGMethod method = new ConfigurationMethod( constructorOrMethod, annotationFinder, false, false, false, false, false, false, true, false, new String[0], new String[0], testClass); ITestNGMethod[] methods = new ITestNGMethod[0]; method.addMethodDependedUpon("dummyDependsOnMethod"); MethodHelper.findDependedUponMethods(method, methods); <START> fail("Should have risen a nice exception"); <END> }</code><technical_language>I dont need this TestNG design fail a test method expected throw exception test method doesn't</technical_language>

Target:
public void findDependedUponMethods() throws NoSuchMethodException { TestClass testClass = new TestClass(); ConstructorOrMethod constructorOrMethod = new ConstructorOrMethod(testClass.getClass().getMethod("dummyMethod")); IAnnotationFinder annotationFinder = new JDK15AnnotationFinder(new AnnotationTransformer()); ITestNGMethod method = new ConfigurationMethod( constructorOrMethod, annotationFinder, false, false, false, false, false, false, true, false, new String[0], new String[0], testClass); method.addMethodDependedUpon("dummyDependsOnMethod"); ITestNGMethod[] methods = new ITestNGMethod[0]; MethodHelper.findDependedUponMethods(method, methods); }
Source:
<code>public void register(SystemStreamPartition systemStreamPartition, String offset) { String offsetToRegister; if (offset == null) { LOG.info("Registering ssp with starting offset null, overriding to 0", systemStreamPartition); offsetToRegister = "0"; } else { LOG.info("Registering ssp with starting offset {}", systemStreamPartition, offset); offsetToRegister = offset; } <START> sspToOffset.put(systemStreamPartition, (offset == null) ? "0" : offsetToRegister); <END> }</code><technical_language>if, else compare for offset == null, do again</technical_language>

Target:
public void register(SystemStreamPartition systemStreamPartition, String offset) { String offsetToRegister; if (offset == null) { LOG.info("Registering ssp with starting offset null, overriding to 0", systemStreamPartition); offsetToRegister = "0"; } else { LOG.info("Registering ssp with starting offset {}", systemStreamPartition, offset); offsetToRegister = offset; } sspToOffset.put(systemStreamPartition, offsetToRegister); }
Source:
<code>public CamusSweeperPlanner setPropertiesLogger(Properties props, Logger log) { dUtils = new DateUtils(props); <START> hourFormatter = dUtils.getDateTimeFormatter("YYYY/MM/dd/HH"); <END> return super.setPropertiesLogger(props, log); }</code><technical_language>formatter string defined a constant</technical_language>

Target:
public CamusSweeperPlanner setPropertiesLogger(Properties props, Logger log) { dUtils = new DateUtils(props); hourFormatter = dUtils.getDateTimeFormatter(YYYY_MM_DD_HH); return super.setPropertiesLogger(props, log); }
Source:
<code>public void set(@NonNull final RandomCard card) { setTitle(getString(R.string.view_random_card_title)); setSubtitle(String.format(getString(R.string.view_random_card_subtitle), WikipediaApp.getInstance().getAppLanguageLocalizedName(card.site().languageCode()))); setIcon(R.drawable.icon_feed_random); <START> setOnClickListener(new OnClickListener() { <END> @Override public void onClick(View v) { new RandomSummaryService(card.site(), new RandomSummaryService.RandomSummaryCallback() { @Override public void onSuccess(PageTitle title) { if (callback != null) { callback.onSelectPage(title); } } @Override public void onError(Throwable t) { L.w("Failed to get random card", t); } }).get(); } }); }</code><technical_language>Minor: levels of callbacks making method a broad deep. Consider breaking this up</technical_language>

Target:
public void set(@NonNull final RandomCard card) { setTitle(getString(R.string.view_random_card_title)); setSubtitle(String.format(getString(R.string.view_random_card_subtitle), WikipediaApp.getInstance().getAppLanguageLocalizedName(card.site().languageCode()))); setIcon(R.drawable.icon_random_48_x_48_dprandom_icon); setOnClickListener(new CallbackAdapter(card, callback)); }
Source:
<code>private boolean tryBuildPage() { if (pageBuilder.isEmpty()) { return false; } <START> if (finished || pageBuilder.isFull()) { <END> buildPage(); return true; } return false; }</code><technical_language>consult finished here? BTW this false this method is called. However, if consulted finishing good (you produce single-row pages for page of input)</technical_language>

Target:
private boolean tryBuildPage() { if (pageBuilder.isFull()) { buildPage(); return true; } return false; }
Source:
<code>public Object visit(BBOX filter, Object extraData) { BoundingBox boundaries = filter.getBounds(); CoordinateReferenceSystem crs = boundaries.getCoordinateReferenceSystem(); if (crs == null) return super.visit(filter, extraData); PropertyName propertyName = null; if (filter.getExpression1() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression1(); } else if (filter.getExpression2() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression2(); } <START> CoordinateReferenceSystem targetCrs = this.targetCrs; <END> if (targetCrs == null) { targetCrs = findPropertyCRS(propertyName); } if (crs != null && targetCrs != null && !CRS.equalsIgnoreMetadata(crs, targetCrs)) { ReferencedEnvelope envelope = ReferencedEnvelope.reference(boundaries); try { envelope = envelope.transform(targetCrs, true); } catch (TransformException e) { throw new RuntimeException(e); } catch (FactoryException e) { throw new RuntimeException(e); } boundaries = envelope; } return getFactory(extraData).bbox(propertyName, boundaries); }</code><technical_language>BBOX specific, sense move this findPropertyCRS instead, geometry literals other comparisons get reprojected well</technical_language>

Target:
public Object visit(BBOX filter, Object extraData) { BoundingBox boundaries = filter.getBounds(); CoordinateReferenceSystem crs = boundaries.getCoordinateReferenceSystem(); if (crs == null) return super.visit(filter, extraData); PropertyName propertyName = null; if (filter.getExpression1() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression1(); } else if (filter.getExpression2() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression2(); } CoordinateReferenceSystem targetCrs = findPropertyCRS(propertyName); if (crs != null && targetCrs != null && !CRS.equalsIgnoreMetadata(crs, targetCrs)) { ReferencedEnvelope envelope = ReferencedEnvelope.reference(boundaries); try { envelope = envelope.transform(targetCrs, true); } catch (TransformException e) { throw new RuntimeException(e); } catch (FactoryException e) { throw new RuntimeException(e); } boundaries = envelope; } return getFactory(extraData).bbox(propertyName, boundaries); }
Source:
<code>private boolean isSelected() { if (selection.choice.get() == this) { return true; } else { if (selection.choice.compareAndSet(null, this)) { selection.unsubscribeOthers(this); return true; } else { <START> unsubscribe(); <END> selection.unsubscribeLosers(); return false; } } }</code><technical_language>unsubscribe(); is redundant unsubscribeLosers call it. LGTM if removing this line</technical_language>

Target:
private boolean isSelected() { if (selection.choice.get() == this) { return true; } else { if (selection.choice.compareAndSet(null, this)) { selection.unsubscribeOthers(this); return true; } else { selection.unsubscribeLosers(); return false; } } }
Source:
<code>private void setupMock() throws Exception { IConfigUtilsInterface confInstance = new DefaultValuesConfigUtil(); Config.setConfigUtils(confInstance); <START> when(wrapper.getServerKeyFingerprint(serverName)).thenReturn(fingerPrint); <END> }</code><technical_language>executeQueryCommand, creating a new instance of VdsInstallerSSH. this mocking help</technical_language>

Target:
private void setupMock() throws Exception { query = spy(new GetServerFingerprintQuery<ServerParameters>(new ServerParameters(serverName))); IConfigUtilsInterface confInstance = new DefaultValuesConfigUtil(); Config.setConfigUtils(confInstance); when(query.getServerFingerprint(serverName)).thenReturn(fingerPrint); }
Source:
<code>public String getName() throws IOException { String title = selectSingleValue(getPom(), "/project/name"); if (title == null) { title = artifactId; } else { title = StringUtils.removeStart(title.trim(), "Jenkins "); title = StringUtils.removeStart(title, "Hudson "); title = StringUtils.removeEnd(title, " for Jenkins"); title = StringUtils.removeEnd(title, " Plugin"); title = StringUtils.removeEnd(title, " plugin"); title = StringUtils.removeEnd(title, " Plug-In"); title = StringUtils.removeEnd(title, " Plug-in"); title = StringUtils.removeEnd(title, " plug-in"); <START> title = StringUtils.removeEnd(title, " Jenkins"); <END> } return title; }</code><technical_language>Dunno from, in list @orrc is in middle column (seems is here) : - ClearCase UCM **Plugin!** - Computer-queue**-plugin** - leiningen**-plugin** - Cucumber json test reporting**.** (dot listing a bit weird) - Inedo BuildMaster plugin for Jenkins**.** - Mail Commander **Plugin for Jenkins-ci** - Maven Metadata **Plugin for Jenkins CI server** - PVCS SCM **plugin for Hudson** - Seapine Surround SCM **- Jenkins Plugin** (after removal of Jenkins Plugin, remains Seapine Surround SCM - ) - HudsonWindmill**Plugin**</technical_language>

Target:
public String getName() throws IOException { String title = selectSingleValue(getPom(), "/project/name"); if (title == null) { title = artifactId; } else { title = simplifyPluginName(title); } return title; }
Source:
<code>public boolean setEndOffsets( final String id, final Map<Integer, Long> endOffsets, final boolean finalize ) { log.debug("SetEndOffsets task[%s] endOffsets[%s] finalize[%s]", id, endOffsets, finalize); try { final FullResponseHolder response = submitJsonRequest( id, HttpMethod.POST, "offsets/end", StringUtils.format("finish=%s", finalize), serialize(endOffsets), true ); return isSuccess(response); } catch (NoTaskLocationException e) { return false; } catch (IOException e) { <START> throw Throwables.propagate(e); <END> } }</code><technical_language>sense allow method throw IOException</technical_language>

Target:
public boolean setEndOffsets( final String id, final Map<Integer, Long> endOffsets, final boolean finalize ) throws IOException { log.debug("SetEndOffsets task[%s] endOffsets[%s] finalize[%s]", id, endOffsets, finalize); try { final FullResponseHolder response = submitJsonRequest( id, HttpMethod.POST, "offsets/end", StringUtils.format("finish=%s", finalize), serialize(endOffsets), true ); return isSuccess(response); } catch (NoTaskLocationException e) { return false; } }
Source:
<code>public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (selection == null || part instanceof GenericHistoryView) { return; } IStructuredSelection structuredSelection = SelectionUtils .getStructuredSelection(selection); System.out.println("selectionChanged[" + part + "]: " <START> + structuredSelection.size()); <END> if (structuredSelection.isEmpty()) { return; } setSelection(structuredSelection); }</code><technical_language>This debug/test output removed :-)</technical_language>

Target:
public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (selection == null || part instanceof GenericHistoryView) { return; } IStructuredSelection structuredSelection = SelectionUtils .getStructuredSelection(selection); if (structuredSelection.isEmpty()) { return; } setSelection(structuredSelection); }
Source:
<code>private int possibleLongJvmPauseDuration(CheckpointMetricsTracker tracker) { if (pauseDetectorEnabled) { if (tracker.lockWaitDuration() + tracker.lockHoldDuration() > longJvmPauseThreshold) { long now = System.currentTimeMillis(); long wakeUpTime = pauseDetector.getLastWakeUpTime(); Map<Long, Long> pauseEvents = pauseDetector.longPauseEvents(); <START> for(Long eventTime : pauseEvents.keySet()) { <END> if(tracker.checkpointStartTime() < eventTime) return pauseEvents.get(eventTime).intValue(); } if(now - wakeUpTime > longJvmPauseThreshold) return (int)(now - wakeUpTime); } } return -1; }</code><technical_language>more clear TreeMap methods here</technical_language>

Target:
private long possibleLongJvmPauseDuration(CheckpointMetricsTracker tracker) { if (LongJVMPauseDetector.enabled()) { if (tracker.lockWaitDuration() + tracker.lockHoldDuration() > longJvmPauseThreshold) { long now = System.currentTimeMillis(); long wakeUpTime = pauseDetector.getLastWakeUpTime(); IgniteBiTuple<Long, Long> lastLongPause = pauseDetector.getLastLongPause(); if (lastLongPause != null && tracker.checkpointStartTime() < lastLongPause.get1()) return lastLongPause.get2(); if (now - wakeUpTime > longJvmPauseThreshold) return now - wakeUpTime; } } return -1L; }
Source:
<code>protected void finalize() throws IOException { if (guard != null) { guard.warnIfOpen(); } if (fd != <START> null) <END> close(); }</code><technical_language>this is addition close() for readability</technical_language>

Target:
protected void finalize() throws IOException { if (guard != null) { guard.warnIfOpen(); } if (fd != null) close(); END Android-changed: Integrate upstream fix to DatagramChannelImpl's }
Source:
<code>protected boolean checkContinuationAccountsForNewSubAccounts(MaintenanceDocument maintenanceDocument) { SubAccountGlobal subAccountGlobal = (SubAccountGlobal) maintenanceDocument.getNewMaintainableObject().getBusinessObject(); subAccountGlobal.getSubAccountGlobalNewAccountDetails().stream() <START> .forEach(this::updateDetailToUseContinuationAccountIfNecessary); <END> return true; }</code><technical_language>Is .stream() needed getSubAccountGlobalNewAccountDetails() returns a List</technical_language>

Target:
protected boolean checkContinuationAccountsForNewSubAccounts(MaintenanceDocument maintenanceDocument) { SubAccountGlobal subAccountGlobal = (SubAccountGlobal) maintenanceDocument.getNewMaintainableObject().getBusinessObject(); subAccountGlobal.getSubAccountGlobalNewAccountDetails() .forEach(this::updateDetailToUseContinuationAccountIfNecessary); return true; }
Source:
<code><START> boolean hasChanged() { <END> return configFile.lastModified() != lastModified; }</code><technical_language>mark lastModified volatile, this method synchronized ensure caller sees correct version of lastModified read() call</technical_language>

Target:
synchronized boolean hasChanged() { return configFile.lastModified() != lastModified; }
Source:
<code>public static EhcacheEntityResponse decode(byte[] payload) { ByteBuffer buffer = ByteBuffer.wrap(payload); byte opCode = buffer.get(); byte[] payArr = new byte[buffer.remaining()]; buffer.get(payArr); switch (opCode) { case 0: return EhcacheEntityResponse.success(); case 1: Exception exception = (Exception)LifeCycleOpCodec.unmarshall(payArr); return EhcacheEntityResponse.failure(exception); case 2: return EhcacheEntityResponse.response(ChainCodec.decode(payArr)); default: <START> throw new UnsupportedOperationException("The operation is not supported"); <END> } }</code><technical_language>please report unsupported opCode in exception's message</technical_language>

Target:
public static EhcacheEntityResponse decode(byte[] payload) { ByteBuffer buffer = ByteBuffer.wrap(payload); byte opCode = buffer.get(); EhcacheEntityResponse.Type type = EhcacheEntityResponse.Type.responseType(opCode); byte[] payArr = new byte[buffer.remaining()]; buffer.get(payArr); switch (type) { case SUCCESS: return EhcacheEntityResponse.success(); case FAILURE: Exception exception = (Exception)LifeCycleOpCodec.unmarshall(payArr); return EhcacheEntityResponse.failure(exception); case GET_RESPONSE: return EhcacheEntityResponse.response(ChainCodec.decode(payArr)); default: throw new UnsupportedOperationException("The operation is not supported with opCode : " + opCode); } }
Source:
<code><START> void updateMaxResolution(QueuedStreamContext context, long newMaxResolution) { <END> if (newMaxResolution != Address.MAX &&context.maxResolution < newMaxResolution) { context.maxResolution = newMaxResolution; log.trace("Read_Fill_Queue[{}] maxResolution set to {}", context.maxResolution); } }</code><technical_language>please reformat code</technical_language>

Target:
void updateMaxResolution(QueuedStreamContext context, long newMaxResolution) { if (newMaxResolution != Address.MAX && context.maxResolution < newMaxResolution) { context.maxResolution = newMaxResolution; log.trace("updateMaxResolution: maxResolution set to {}", context.maxResolution); } }
Source:
<code>public static void putObject_test15() throws Exception { if (!mintEnv) { System.out.println("Test: putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse) using SSE_KMS."); } long startTime = System.currentTimeMillis(); ServerSideEncryption sse = ServerSideEncryption.withManagedKeys("key-id",null); try { String objectName = getRandomName(); try (final InputStream is = new ContentInputStream(1 * MB)) { client.putObject(bucketName, objectName, is, 1 * MB, sse); } client.removeObject(bucketName, objectName); mintSuccessLog("putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse)", <START> "size: 13 MB", startTime); <END> } catch (Exception e) { mintFailedLog("putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse)", "size: 13 MB", startTime, null, e.toString() + " >>> " + Arrays.toString(e.getStackTrace())); throw e; } }</code><technical_language>Size is 1 MB, please update</technical_language>

Target:
public static void putObject_test15() throws Exception { if (!mintEnv) { System.out.println("Test: putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse) using SSE_KMS."); } long startTime = System.currentTimeMillis(); Map<String,String> myContext = new HashMap<>(); myContext.put("key1","value1"); String keyId = ""; keyId = System.getenv("MINT_KEY_ID"); if (keyId.equals("")) { mintIgnoredLog("getBucketPolicy(String bucketName)", null, startTime); } ServerSideEncryption sse = ServerSideEncryption.withManagedKeys("keyId", myContext); try { String objectName = getRandomName(); try (final InputStream is = new ContentInputStream(1 * MB)) { client.putObject(bucketName, objectName, is, 1 * MB, sse); } client.removeObject(bucketName, objectName); mintSuccessLog("putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse) using SSE_KMS.", "size: 1 MB", startTime); } catch (Exception e) { mintFailedLog("putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse) using SSE_KMS.", "size: 1 MB", startTime, null, e.toString() + " >>> " + Arrays.toString(e.getStackTrace())); throw e; } }
Source:
<code>public void setup() { mUiModeManagerShadow = shadowOf((UiModeManager) mContext.getSystemService(UI_MODE_SERVICE)); mUiModeManagerShadow.currentModeType = UI_MODE_TYPE_NORMAL; mDisplayManager = (DisplayManager) mContext.getSystemService(DISPLAY_SERVICE); mWindowManager = (WindowManager) mContext.getSystemService(WINDOW_SERVICE); mDefaultDisplay = mWindowManager.getDefaultDisplay(); ShadowSystemProperties.reset(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { ShadowSystemProperties.override( "sys.display-size", String.format("%dx%d", DISPLAY_WIDTH_VENDOR, DISPLAY_HEIGHT_VENDOR)); } else { ShadowSystemProperties.override( "vendor.display-size", <START> String.format("%dx%d", DISPLAY_WIDTH_VENDOR, DISPLAY_HEIGHT_VENDOR)); <END> } }</code><technical_language>values here? validate pulling right setting right version</technical_language>

Target:
public void setup() { mUiModeManagerShadow = shadowOf((UiModeManager) mContext.getSystemService(UI_MODE_SERVICE)); mUiModeManagerShadow.currentModeType = UI_MODE_TYPE_NORMAL; mDisplayManager = (DisplayManager) mContext.getSystemService(DISPLAY_SERVICE); mWindowManager = (WindowManager) mContext.getSystemService(WINDOW_SERVICE); mDefaultDisplay = mWindowManager.getDefaultDisplay(); ShadowSystemProperties.reset(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { ShadowSystemProperties.override( "sys.display-size", String.format("%dx%d", DISPLAY_WIDTH_VENDOR, DISPLAY_HEIGHT_VENDOR)); } else { ShadowSystemProperties.override( "vendor.display-size", String.format("%dx%d", DISPLAY_WIDTH_VENDOR_P, DISPLAY_HEIGHT_VENDOR_P)); } }