auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static DigestSource pbkDf2() { return (value, salt) -> { if (salt == null || salt.length == 0) { throw new IllegalArgumentException("Cannot use pbkDf2 with empty or null salt."); } try { KeySpec spec = new PBEKeySpec(value.toCharArray(), salt, 65536, 256); SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); final byte[] bytes = factory.generateSecret(spec).getEncoded(); return EncodingUtils.BASE64_ENCODER.apply(bytes); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { <START> throw new IllegalStateException("Unable digest value.", e); <END> } }; }</code><technical_language>"Unable digest value"</technical_language>

Target:
public static DigestSource pbkDf2() { return (value, salt) -> { if (salt == null || salt.length == 0) { throw new IllegalArgumentException("Cannot use pbkDf2 with empty or null salt."); } try { KeySpec spec = new PBEKeySpec(value.toCharArray(), salt, 65536, 256); SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); final byte[] bytes = factory.generateSecret(spec).getEncoded(); return EncodingUtils.BASE64_ENCODER.apply(bytes); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { throw new IllegalStateException("Unable to digest value.", e); } }; }
Source:
<code>private static String canonicalize(String s) { return <START> s.toLowerCase(Locale.US); <END> }</code><technical_language>Wrong round</technical_language>

Target:
private static String canonicalize(String s) { return s.toLowerCase(Locale.ROOT); }
Source:
<code>protected void setActionMessageParameters() { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__HOT_PLUG); addCanDoActionMessage(VdcBllMessages.VAR__TYPE__VM_DISK); <START> if (getDiskAlias() != null) { <END> addCanDoActionMessage(String.format("$%1$s %2$s", "diskAliases", getDiskAlias())); } }</code><technical_language>IIUC, getDiskAlias() null. is a disk (in case alias), isn't, in getDiskAlias() throw a NullPointerException. check if (getDisk() != null)</technical_language>

Target:
protected void setActionMessageParameters() { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__HOT_PLUG); addCanDoActionMessage(VdcBllMessages.VAR__TYPE__VM_DISK); if (getDisk() != null) { addCanDoActionMessage(String.format("$%1$s %2$s", "diskAliases", getDiskAlias())); } }
Source:
<code>public StorageDomain mapRow(final ResultSet rs, final int rowNum) throws SQLException { final StorageDomain entity = new StorageDomain(); entity.setId(getGuidDefaultEmpty(rs, "id")); entity.setStorage(rs.getString("storage")); entity.setStorageName(rs.getString("storage_name")); entity.setDescription(rs.getString("storage_description")); entity.setStoragePoolId(getGuid(rs, "storage_pool_id")); entity.setComment(rs.getString("storage_comment")); entity.setStorageType(StorageType.forValue(rs.getInt("storage_type"))); entity.setStoragePoolName(rs.getString("storage_pool_name")); entity.setStorageDomainType(StorageDomainType.forValue(rs.getInt("storage_domain_type"))); entity.setStorageFormat(StorageFormatType.forValue(rs.getString("storage_domain_format_type"))); entity.setAvailableDiskSize((Integer) rs.getObject("available_disk_size")); entity.setUsedDiskSize((Integer) rs.getObject("used_disk_size")); <START> entity.setCommittedDiskSize(rs.getInt("actual_images_size")); <END> entity.setCommittedDiskSize(rs.getInt("commited_disk_size")); entity.setStatus(StorageDomainStatus.forValue(rs.getInt("status"))); entity.setStorageDomainSharedStatus( StorageDomainSharedStatus.forValue(rs.getInt("storage_domain_shared_status"))); entity.setAutoRecoverable(rs.getBoolean("recoverable")); entity.setLastTimeUsedAsMaster(rs.getLong("last_time_used_as_master")); return entity; }</code><technical_language>This entity.setActualImagesSize</technical_language>

Target:
public StorageDomain mapRow(final ResultSet rs, final int rowNum) throws SQLException { final StorageDomain entity = new StorageDomain(); entity.setId(getGuidDefaultEmpty(rs, "id")); entity.setStorage(rs.getString("storage")); entity.setStorageName(rs.getString("storage_name")); entity.setDescription(rs.getString("storage_description")); entity.setStoragePoolId(getGuid(rs, "storage_pool_id")); entity.setComment(rs.getString("storage_comment")); entity.setStorageType(StorageType.forValue(rs.getInt("storage_type"))); entity.setStoragePoolName(rs.getString("storage_pool_name")); entity.setStorageDomainType(StorageDomainType.forValue(rs.getInt("storage_domain_type"))); entity.setStorageFormat(StorageFormatType.forValue(rs.getString("storage_domain_format_type"))); entity.setAvailableDiskSize((Integer) rs.getObject("available_disk_size")); entity.setUsedDiskSize((Integer) rs.getObject("used_disk_size")); entity.setActualImagesSize(rs.getInt("actual_images_size")); entity.setCommittedDiskSize(rs.getInt("commited_disk_size")); entity.setStatus(StorageDomainStatus.forValue(rs.getInt("status"))); entity.setStorageDomainSharedStatus( StorageDomainSharedStatus.forValue(rs.getInt("storage_domain_shared_status"))); entity.setAutoRecoverable(rs.getBoolean("recoverable")); entity.setLastTimeUsedAsMaster(rs.getLong("last_time_used_as_master")); return entity; }
Source:
<code>public static Enumeration listRoots() { <START> return new Vector().elements(); <END> }</code><technical_language>print a _non implemented_ message too</technical_language>

Target:
public static Enumeration listRoots() { System.out.println("FileSystemRegistry::listRoots() not implemented."); return new Vector().elements(); }
Source:
<code>public static void main(String[] args) { SearchIndexAsyncClient searchClient = new SearchIndexClientBuilder() .endpoint(ENDPOINT) .credential(new SearchApiKeyCredential(API_KEY)) .indexName(INDEX_NAME) .buildAsyncClient(); ObjectMapper objectMapper = new ObjectMapper(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(TimeZone.getDefault()); objectMapper.setDateFormat(df); objectMapper.registerModule(new JavaTimeModule()); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); SearchPagedFlux results = searchClient.search("searchText"); results .subscribe(item -> { <START> Document document = new Document(item.getDocument()); <END> Hotel hotel = objectMapper.convertValue(document, Hotel.class); System.out.println("Hotel " + hotel.getHotelId()); }); results.blockLast(); }</code><technical_language>depend for user experience</technical_language>

Target:
public static void main(String[] args) { SearchIndexAsyncClient searchClient = new SearchIndexClientBuilder() .endpoint(ENDPOINT) .credential(new SearchApiKeyCredential(API_KEY)) .indexName(INDEX_NAME) .buildAsyncClient(); ObjectMapper objectMapper = new ObjectMapper(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(TimeZone.getDefault()); objectMapper.setDateFormat(df); objectMapper.registerModule(new JavaTimeModule()); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); SearchPagedFlux results = searchClient.search("searchText"); results .subscribe(item -> { SearchDocument searchDocument = item.getDocument(); Hotel hotel = objectMapper.convertValue(searchDocument, Hotel.class); System.out.println("Hotel " + hotel.getHotelId()); }); results.blockLast(); }
Source:
<code>public void loadTrace(ITmfTrace trace) { cancelUpdate(); <START> clearStyles(); <END> super.loadTrace(trace); initializeDataProvider(); }</code><technical_language>order of colors is changed switching a trace</technical_language>

Target:
public void loadTrace(ITmfTrace trace) { clearStyles(); super.loadTrace(trace); initializeDataProvider(); }
Source:
<code>public static Correlation copyFrom(ICorrelation source) { if (source == null) { return null; } Correlation correlation = new Correlation(); correlation.setState(source.getState()); correlation.setPath(source.getPath()); <START> correlation.getCueiCollection().addAll(MutableCollections.copyListFromNullable(source.getCueiCollection())); <END> correlation.setCmin(source.getCmin()); correlation.setCmax(source.getCmax()); correlation.setCtime(source.getCtime()); return correlation; }</code><technical_language>need copyListFromNullable() a new list in this object. method is meant for fields initialized creates a new list. Double check if this is done in other JAXB objects</technical_language>

Target:
public static Correlation copyFrom(ICorrelation source) { if (source == null) { return null; } Correlation correlation = new Correlation(); correlation.setState(source.getState()); correlation.setPath(source.getPath()); correlation.getCueiCollection().addAll(source.getCueiCollection()); correlation.setCmin(source.getCmin()); correlation.setCmax(source.getCmax()); correlation.setCtime(source.getCtime()); return correlation; }
Source:
<code>public void reportMeterWithDisabledAttributes() throws Exception { Set<MetricAttribute> disabledMetricAttributes = EnumSet.of(MetricAttribute.M15_RATE, MetricAttribute.M5_RATE, MetricAttribute.COUNT); final ConsoleReporter customReporter = ConsoleReporter.forRegistry(registry) .outputTo(output) .formattedFor(Locale.US) .withClock(clock) <START> .formattedFor(TimeZone.getTimeZone("PST")) <END> .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .filter(MetricFilter.ALL) .disabledMetricAttributes(disabledMetricAttributes) .build(); final Meter meter = mock(Meter.class); when(meter.getCount()).thenReturn(1L); when(meter.getMeanRate()).thenReturn(2.0); when(meter.getOneMinuteRate()).thenReturn(3.0); when(meter.getFiveMinuteRate()).thenReturn(4.0); when(meter.getFifteenMinuteRate()).thenReturn(5.0); customReporter.report(this.<Gauge>map(), this.<Counter>map(), this.<Histogram>map(), map("test.meter", meter), this.<Timer>map()); assertThat(consoleOutput()) .isEqualTo(lines( "3/17/13 6:04:36 PM =============================================================", "", "-- Meters ----------------------------------------------------------------------", "test.meter", " mean rate = 2.00 events/second", " 1-minute rate = 3.00 events/second", "", "" )); }</code><technical_language>I guess extract timezone a variable, tests timezone</technical_language>

Target:
public void reportMeterWithDisabledAttributes() throws Exception { Set<MetricAttribute> disabledMetricAttributes = EnumSet.of(MetricAttribute.M15_RATE, MetricAttribute.M5_RATE, MetricAttribute.COUNT); final ConsoleReporter customReporter = ConsoleReporter.forRegistry(registry) .outputTo(output) .formattedFor(locale) .withClock(clock) .formattedFor(timeZone) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .filter(MetricFilter.ALL) .disabledMetricAttributes(disabledMetricAttributes) .build(); final Meter meter = mock(Meter.class); when(meter.getCount()).thenReturn(1L); when(meter.getMeanRate()).thenReturn(2.0); when(meter.getOneMinuteRate()).thenReturn(3.0); when(meter.getFiveMinuteRate()).thenReturn(4.0); when(meter.getFifteenMinuteRate()).thenReturn(5.0); customReporter.report(this.<Gauge>map(), this.<Counter>map(), this.<Histogram>map(), map("test.meter", meter), this.<Timer>map()); assertThat(consoleOutput()) .isEqualTo(lines( "3/17/13 6:04:36 PM =============================================================", "", "-- Meters ----------------------------------------------------------------------", "test.meter", " mean rate = 2.00 events/second", " 1-minute rate = 3.00 events/second", "", "" )); }
Source:
<code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.account_setup_basics); mEmailView = (EditText)findViewById(R.id.account_email); mPasswordView = (EditText)findViewById(R.id.account_password); mNextButton = (Button)findViewById(R.id.next); mManualSetupButton = (Button)findViewById(R.id.manual_setup); mShowPassword = (CheckBox) findViewById(R.id.show_password); <START> mShowPassword.setOnCheckedChangeListener(new OnCheckedChangeListener() { <END> @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { mPasswordView.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); } else { mPasswordView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } } }); mNextButton.setOnClickListener(this); mManualSetupButton.setOnClickListener(this); mEmailView.addTextChangedListener(this); mPasswordView.addTextChangedListener(this); }</code><technical_language>Please spaces for indentation</technical_language>

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.account_setup_basics); mEmailView = (EditText) findViewById(R.id.account_email); mPasswordView = (EditText) findViewById(R.id.account_password); mNextButton = (Button) findViewById(R.id.next); mManualSetupButton = (Button) findViewById(R.id.manual_setup); CheckBox showPassword = (CheckBox) findViewById(R.id.show_password); showPassword.setOnCheckedChangeListener (new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { mPasswordView .setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); } else { mPasswordView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } } }); mNextButton.setOnClickListener(this); mManualSetupButton.setOnClickListener(this); mEmailView.addTextChangedListener(this); mPasswordView.addTextChangedListener(this); }
Source:
<code>public void createPartControl(Composite parent) { GridLayout topLayout = new GridLayout(); GridData data = new GridData(); topLayout.numColumns = 1; topLayout.verticalSpacing = 10; parent.setLayout(topLayout); parent.setLayoutData(data); parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); fText = new Text(parent,SWT.READ_ONLY|SWT.WRAP); <START> data = new GridData(GridData.FILL_HORIZONTAL); <END> data.grabExcessHorizontalSpace = true; fText.setLayoutData(data); fText.setForeground(new Color(fText.getDisplay(), 0, 0, 0)); fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); if (getEditorInput() != null) { setInput(getEditorInput()); } createButtons(parent); Dialog.applyDialogFont(parent); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugHelpContextIds.NO_SOURCE_EDITOR); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICDebugHelpContextIds.SOURCE_NOT_FOUND); }</code><technical_language>existed in CommonSourceNotFoundEditor, some whitespace errors. This line next indented spaces instead of tabs</technical_language>

Target:
public void createPartControl(Composite parent) { GridLayout topLayout = new GridLayout(); GridData data = new GridData(); topLayout.numColumns = 1; topLayout.verticalSpacing = 10; parent.setLayout(topLayout); parent.setLayoutData(data); parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); fText = new Text(parent, SWT.READ_ONLY | SWT.WRAP); data = new GridData(GridData.FILL_HORIZONTAL); data.grabExcessHorizontalSpace = true; fText.setLayoutData(data); fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK)); fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); if (getEditorInput() != null) { setInput(getEditorInput()); } createButtons(parent); Dialog.applyDialogFont(parent); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICDebugHelpContextIds.SOURCE_NOT_FOUND); }
Source:
<code>protected void initFile(String id) throws FormatException, IOException { super.initFile(id); xmlId = id; store = makeFilterMetadata(); in = new RandomAccessInputStream(xmlId); in.setEncoding("ASCII"); DefaultHandler handler = new BDVXMLHandler(); <START> try { <END> RandomAccessInputStream s = new RandomAccessInputStream(id); XMLTools.parseXML(s, handler); s.close(); } catch (IOException e) { throw new FormatException("Malformed XML", e); } store.setXMLAnnotationValue(bdvxml, 0); String xml_id = MetadataTools.createLSID("XMLAnnotation", 0); store.setXMLAnnotationID(xml_id, 0); initializeJHDFService(h5Id); parseStructure(); if (seriesCount <= 2 && getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { parseROIs(0); } }</code><technical_language>This leak, change recommended try (RandomAccessInputStream s = new RandomAccessInputStream(id)) { XMLTools.parseXML(s, handler); } catch (IOException e) { throw new FormatException("Malformed XML", e); }</technical_language>

Target:
protected void initFile(String id) throws FormatException, IOException { super.initFile(id); if (checkSuffix(id, "h5")) { id = fetchXMLId(); } store = makeFilterMetadata(); in = new RandomAccessInputStream(id); in.setEncoding("ASCII"); DefaultHandler handler = new BDVXMLHandler(); try (RandomAccessInputStream s = new RandomAccessInputStream(id)) { XMLTools.parseXML(s, handler); } catch (IOException e) { throw new FormatException("Malformed XML", e); } if (StringUtils.isEmpty(h5Id)) { throw new FormatException("Could not find H5 file location in XML"); } store.setXMLAnnotationValue(bdvxml, 0); String xml_id = MetadataTools.createLSID("XMLAnnotation", 0); store.setXMLAnnotationID(xml_id, 0); initializeJHDFService(h5Id); parseStructure(); if (seriesCount <= 2 && getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { parseROIs(0); } }
Source:
<code>public boolean isExpired() { if (getTimeToLiveInMs() != Utils.Infinite_TTL && <START> SystemTime.getInstance().milliseconds() > getTimeToLiveInMs()) { <END> return true; } return false; }</code><technical_language>This infinite time</technical_language>

Target:
public boolean isExpired() { if (getTimeToLiveInMs() != Utils.Infinite_Time && SystemTime.getInstance().milliseconds() > getTimeToLiveInMs()) { return true; } return false; }
Source:
<code>public String getQueryKeywordsForInfo() { char delimiter = ','; StringBuffer keywords = new StringBuffer(); <START> if (q != null && q.isInfoInQuery) { <END> for (String keyword : q.infoValues) { keywords.append(keyword).append(delimiter); } if (keywords.length() > 0) { keywords.deleteCharAt(keywords.length() - 1); } } return keywords.toString(); }</code><technical_language>If a if (q == null || !q.isInfoInQuery) { return "";} avoid indenting 'happy path'</technical_language>

Target:
public String getQueryKeywordsForInfo() { if (q == null || !q.isInfoInQuery) { return ""; } char delimiter = ','; StringBuffer keywords = new StringBuffer(); for (String keyword : q.infoValues) { keywords.append(keyword).append(delimiter); } if (keywords.length() > 0) { keywords.deleteCharAt(keywords.length() - 1); } return keywords.toString(); }
Source:
<code>protected SslContextFactory getSSLContext( Map args) { try { String privateKeyPassword; privateKeyPassword = Option.HTTPS_PRIVATE_KEY_PASSWORD.get(args, keystorePassword); KeyManagerFactory kmf = KeyManagerFactory.getInstance( Option.HTTPS_KEY_MANAGER_TYPE.get( args)); kmf.init(keystore, keystorePassword.toCharArray()); Logger.log(Logger.FULL_DEBUG, SSL_RESOURCES, "HttpsListener.KeyCount", keystore.size() + ""); for ( Enumeration e = keystore.aliases(); e.hasMoreElements();) { String alias = (String) e.nextElement(); Logger.log(Logger.FULL_DEBUG, SSL_RESOURCES, "HttpsListener.KeyFound", alias, keystore.getCertificate(alias) + ""); } SslContextFactory.Server ssl = new SslContextFactory.Server(); ssl.setKeyStore(keystore); ssl.setKeyStorePassword(keystorePassword); ssl.setKeyManagerPassword(privateKeyPassword); ssl.setKeyManagerFactoryAlgorithm(Option.HTTPS_KEY_MANAGER_TYPE.get(args)); ssl.setCertAlias(Option.HTTPS_CERTIFICATE_ALIAS.get(args)); ssl.setExcludeProtocols("SSLv3", "SSLv2", "SSLv2Hello"); String excludeCiphers = Option.HTTPS_EXCLUDE_CIPHER_SUITES.get(args); if(excludeCiphers!=null&&excludeCiphers.length()>0) { String[] cipherSuites = excludeCiphers.split(","); ssl.setExcludeCipherSuites(cipherSuites); } Logger.log( Logger.INFO, SSL_RESOURCES, "HttpsListener.ExcludeCiphers", Arrays.asList(ssl.getExcludeCipherSuites())); ssl.setNeedClientAuth(Option.HTTPS_VERIFY_CLIENT.get(args)); return ssl; <START> } catch (Exception err) { <END> throw new WinstoneException(SSL_RESOURCES .getString("HttpsListener.ErrorGettingContext"), err); } }</code><technical_language>this change</technical_language>

Target:
protected SslContextFactory getSSLContext( Map args) { try { String privateKeyPassword; privateKeyPassword = Option.HTTPS_PRIVATE_KEY_PASSWORD.get(args, keystorePassword); KeyManagerFactory kmf = KeyManagerFactory.getInstance( Option.HTTPS_KEY_MANAGER_TYPE.get( args)); kmf.init(keystore, keystorePassword.toCharArray()); Logger.log(Logger.FULL_DEBUG, SSL_RESOURCES, "HttpsListener.KeyCount", keystore.size() + ""); for ( Enumeration e = keystore.aliases(); e.hasMoreElements();) { String alias = (String) e.nextElement(); Logger.log(Logger.FULL_DEBUG, SSL_RESOURCES, "HttpsListener.KeyFound", alias, keystore.getCertificate(alias) + ""); } SslContextFactory ssl = new SslContextFactory.Server(); ssl.setKeyStore(keystore); ssl.setKeyStorePassword(keystorePassword); ssl.setKeyManagerPassword(privateKeyPassword); ssl.setKeyManagerFactoryAlgorithm(Option.HTTPS_KEY_MANAGER_TYPE.get(args)); ssl.setCertAlias(Option.HTTPS_CERTIFICATE_ALIAS.get(args)); ssl.setExcludeProtocols("SSLv3", "SSLv2", "SSLv2Hello"); String excludeCiphers = Option.HTTPS_EXCLUDE_CIPHER_SUITES.get(args); if(excludeCiphers!=null&&excludeCiphers.length()>0) { String[] cipherSuites = excludeCiphers.split(","); ssl.setExcludeCipherSuites(cipherSuites); } Logger.log( Logger.INFO, SSL_RESOURCES, "HttpsListener.ExcludeCiphers", Arrays.asList(ssl.getExcludeCipherSuites())); ssl.setNeedClientAuth(Option.HTTPS_VERIFY_CLIENT.get(args)); return ssl; } catch (Exception err) { throw new WinstoneException(SSL_RESOURCES .getString("HttpsListener.ErrorGettingContext"), err); } }
Source:
<code>public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(RuntimeEnvironment.application); mLifecycleOwner = () -> mLifecycle; mLifecycle = new Lifecycle(mLifecycleOwner); when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager); when(mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)) .thenReturn(mSubscriptionManager); List<SubscriptionInfo> list = new ArrayList<SubscriptionInfo>(); list.add(new <START> SubscriptionInfo(subid_1, "", <END> 0, "", "", 0, 0, "", 0, null, "0", "0", "", false, null, null)); list.add(new SubscriptionInfo(subid_2, "", 1, "", "", 0, 0, "", 0, null, "0", "0", "", false, null, null)); when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(list); when(mTelephonyManager.getNetworkOperatorName(eq(SUBID_1))).thenReturn(TEST_CARRIER_NAME1); when(mTelephonyManager.getNetworkOperatorName(eq(SUBID_2))).thenReturn(TEST_CARRIER_NAME2); }</code><technical_language>I this is a typo of SUBID_1</technical_language>

Target:
public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(RuntimeEnvironment.application); mLifecycleOwner = () -> mLifecycle; mLifecycle = new Lifecycle(mLifecycleOwner); when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager); when(mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)) .thenReturn(mSubscriptionManager); List<SubscriptionInfo> list = new ArrayList<SubscriptionInfo>(); list.add(new SubscriptionInfo(SUBID_1, "", 0, "", "", 0, 0, "", 0, null, "0", "0", "", false, null, null)); list.add(new SubscriptionInfo(SUBID_2, "", 1, "", "", 0, 0, "", 0, null, "0", "0", "", false, null, null)); when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(list); when(mTelephonyManager.getNetworkOperatorName(eq(SUBID_1))).thenReturn(TEST_CARRIER_NAME1); when(mTelephonyManager.getNetworkOperatorName(eq(SUBID_2))).thenReturn(TEST_CARRIER_NAME2); }
Source:
<code>private void copyDiskDevicesFromTemplate() { <START> Guid templateId = getParameters().getVmStaticData().getVmtGuid(); <END> List<VmDevice> disks = DbFacade.getInstance().getVmDeviceDao().getVmDeviceByVmIdAndType(templateId, VmDeviceGeneralType.DISK); VmDeviceUtils.copyVmDevices( templateId, getVmId(), getVm(), getVm().getStaticData(), true, disks, getSrcDeviceIdToTargetDeviceIdMapping(), false, false, false, false, false ); }</code><technical_language>please getVmtGuid</technical_language>

Target:
private void copyDiskDevicesFromTemplate() { List<VmDevice> disks = DbFacade.getInstance().getVmDeviceDao().getVmDeviceByVmIdAndType(getVmTemplateId(), VmDeviceGeneralType.DISK); VmDeviceUtils.copyVmDevices( getVmTemplateId(), getVmId(), getVm(), getVm().getStaticData(), true, disks, getSrcDeviceIdToTargetDeviceIdMapping(), false, false, false, false, false ); }
Source:
<code>static int compare(Row row, String aggregationName, Number value) { Object metricValueObj = row.getRaw(aggregationName); if (metricValueObj != null) { if (metricValueObj instanceof Long) { long l = ((Long) metricValueObj).longValue(); return Longs.compare(l, value.longValue()); } else if (metricValueObj instanceof String) { String metricValueStr = (String) metricValueObj; <START> if (!metricValueStr.contains(".")) { <END> long l = row.getLongMetric(aggregationName); return Longs.compare(l, value.longValue()); } } } float f = row.getFloatMetric(aggregationName); return Floats.compare(f, value.floatValue()); }</code><technical_language>1E10 is a valid float representation, right</technical_language>

Target:
static int compare(Row row, String aggregationName, Number value) { Object metricValueObj = row.getRaw(aggregationName); if (metricValueObj != null) { if (metricValueObj instanceof Long) { long l = ((Long) metricValueObj).longValue(); return Longs.compare(l, value.longValue()); } else if (metricValueObj instanceof String) { String metricValueStr = (String) metricValueObj; if (LONG_PAT.matcher(metricValueStr).matches()) { long l = row.getLongMetric(aggregationName); return Longs.compare(l, value.longValue()); } } } float f = row.getFloatMetric(aggregationName); return Floats.compare(f, value.floatValue()); }
Source:
<code>public void testStressLargeNumberOfLiveInstances() throws Exception { int concurrencyLevel = 100; String testCluster = "testStressUniqueInstanceNames"; ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newCachedThreadPool(); ZkClient zkClient = new ZkClient(_zkConnectionString); <START> long duration = WAIT_DURATION_FOR_ZK_MS * 5; <END> for (int i = 0; i < concurrencyLevel; i++) { Runnable task = () -> { try { Coordinator instance = createCoordinator(_zkConnectionString, testCluster); instance.start(); Thread.sleep(duration); instance.stop(); } catch (Exception ex) { LOG.error("Failed to launch coordinator", ex); Assert.fail(); } }; executor.execute(task); } Thread.sleep(duration); List<String> instances = zkClient.getChildren(KeyBuilder.liveInstances(testCluster)); List<String> sortedList = new ArrayList<>(instances); Collections.sort(sortedList); LOG.info(String.format("Live instances %s", sortedList)); Assert.assertEquals(instances.size(), concurrencyLevel, String.format("Live instances %s", sortedList)); zkClient.close(); }</code><technical_language>this is changing 5 seconds 5 minutes</technical_language>

Target:
public void testStressLargeNumberOfLiveInstances() throws Exception { int concurrencyLevel = 100; String testCluster = "testStressUniqueInstanceNames"; ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newCachedThreadPool(); ZkClient zkClient = new ZkClient(_zkConnectionString); long duration = Duration.ofSeconds(10).toMillis(); for (int i = 0; i < concurrencyLevel; i++) { Runnable task = () -> { try { Coordinator instance = createCoordinator(_zkConnectionString, testCluster); instance.start(); Thread.sleep(duration); instance.stop(); } catch (Exception ex) { LOG.error("Failed to launch coordinator", ex); Assert.fail(); } }; executor.execute(task); } Thread.sleep(duration); List<String> instances = zkClient.getChildren(KeyBuilder.liveInstances(testCluster)); List<String> sortedList = new ArrayList<>(instances); Collections.sort(sortedList); LOG.info(String.format("Live instances %s", sortedList)); Assert.assertEquals(instances.size(), concurrencyLevel, String.format("Live instances %s", sortedList)); zkClient.close(); }
Source:
<code>public void testRangeRequestStitchDifferentSizedBlobsSegments() throws Exception { if (metadataContentVersion > 2) { for (int i = 0; i < NUM_STITCHED_CHUNKS; i++) { <START> testGetSuccessStitch(chunkSize * 6 + 11, new GetBlobOptionsBuilder().blobSegment(i) <END> .range(ByteRanges.fromOffsetRange(0, chunkSize / NUM_STITCHED_CHUNKS)) .build()); testGetSuccessStitch(chunkSize * 6 + 11, new GetBlobOptionsBuilder().blobSegment(i) .range(ByteRanges.fromOffsetRange(chunkSize / NUM_STITCHED_CHUNKS / 2, chunkSize / NUM_STITCHED_CHUNKS)) .build()); testGetSuccessStitch(chunkSize * 6 + 11, new GetBlobOptionsBuilder().blobSegment(i) .range(ByteRanges.fromOffsetRange(5, chunkSize / NUM_STITCHED_CHUNKS - 5)) .build()); testGetSuccessStitch(chunkSize * 6 + 11, new GetBlobOptionsBuilder().blobSegment(i).range(ByteRanges.fromOffsetRange(0, 0)).build()); } } else { router = getNonBlockingRouter(); router.close(); } }</code><technical_language>If blob size in test case, set blobSize variable use</technical_language>

Target:
public void testRangeRequestStitchDifferentSizedBlobsSegments() throws Exception { if (metadataContentVersion > MessageFormatRecord.Metadata_Content_Version_V2) { for (int i = 0; i < NUM_STITCHED_CHUNKS; i++) { testGetSuccessStitch(LARGE_BLOB_SIZE, new GetBlobOptionsBuilder().blobSegment(i) .range(ByteRanges.fromOffsetRange(0, CHUNK_SIZE / NUM_STITCHED_CHUNKS)) .build()); testGetSuccessStitch(LARGE_BLOB_SIZE, new GetBlobOptionsBuilder().blobSegment(i) .range(ByteRanges.fromOffsetRange(CHUNK_SIZE / NUM_STITCHED_CHUNKS / 2, CHUNK_SIZE / NUM_STITCHED_CHUNKS)) .build()); testGetSuccessStitch(LARGE_BLOB_SIZE, new GetBlobOptionsBuilder().blobSegment(i) .range(ByteRanges.fromOffsetRange(5, CHUNK_SIZE / NUM_STITCHED_CHUNKS - 5)) .build()); testGetSuccessStitch(LARGE_BLOB_SIZE, new GetBlobOptionsBuilder().blobSegment(i).range(ByteRanges.fromOffsetRange(0, 0)).build()); } } else { router = getNonBlockingRouter(); router.close(); } }
Source:
<code>public void initialize() { for (SensorMotor motor : motors) { <START> if (motor instanceof VelocitySensorMotor) { <END> ((VelocitySensorMotor) motor).set(speed); } } }</code><technical_language>if this true</technical_language>

Target:
public void initialize() { for (SensorMotor motor : motors) { if (motor instanceof VelocitySensorMotor) { ((VelocitySensorMotor) motor).set(speed); } else if (motor instanceof PositionSensorMotor) { ((PositionSensorMotor) motor).setPosition(position); } } }
Source:
<code>public List<Project> getProjectsByFilter(final int pageNumber,final int pageSize, final Map<ProgramFilters, Object> filters) throws MiddlewareException { try { Criteria criteria = this.getSession().createCriteria(Project.class); <START> for (Map.Entry<ProgramFilters, Object> entry : filters.entrySet()) { <END> ProgramFilters filter = entry.getKey(); Object value = entry.getValue(); criteria.add(Restrictions.eq(filter.getStatement(), value)); } int start = pageSize * (pageNumber - 1); int numOfRows = pageSize; criteria.setFirstResult(start); criteria.setMaxResults(numOfRows); return criteria.list(); } catch (HibernateException e) { throw new MiddlewareException( "Error in getProjectsByFilter(start=" + pageNumber + ", numOfRows=" + pageSize + "): " + e.getMessage(), e); } }</code><technical_language>add final criteria, filter, entry</technical_language>

Target:
public List<Project> getProjectsByFilter(final int pageNumber,final int pageSize, final Map<ProgramFilters, Object> filters) throws MiddlewareException { try { final Criteria criteria = this.getSession().createCriteria(Project.class); for (Map.Entry<ProgramFilters, Object> entry : filters.entrySet()) { final ProgramFilters filter = entry.getKey(); final Object value = entry.getValue(); criteria.add(Restrictions.eq(filter.getStatement(), value)); } final int start = pageSize * (pageNumber - 1); final int numOfRows = pageSize; criteria.setFirstResult(start); criteria.setMaxResults(numOfRows); return criteria.list(); } catch (HibernateException e) { throw new MiddlewareException( "Error in getProjectsByFilter(start=" + pageNumber + ", numOfRows=" + pageSize + "): " + e.getMessage(), e); } }
Source:
<code><START> public void testGetRefsByPrefixes() throws IOException { <END> List<Ref> refs = db.getRefDatabase().getRefsByPrefix("refs/heads/p", "refs/tags/A"); assertEquals(3, refs.size()); checkContainsRef(refs, db.exactRef("refs/heads/prefix/a")); checkContainsRef(refs, db.exactRef("refs/heads/pa")); checkContainsRef(refs, db.exactRef("refs/tags/A")); }</code><technical_language>A more cases discussed review: * a test for getRefsByPrefix()? * ordering of result? defined, this assertArrayEquals? * overlapping prefixes</technical_language>

Target:
public void testGetRefsByPrefixes() throws IOException { List<Ref> refs = db.getRefDatabase().getRefsByPrefix(); assertEquals(0, refs.size()); refs = db.getRefDatabase().getRefsByPrefix("refs/heads/p", "refs/tags/A"); assertEquals(3, refs.size()); checkContainsRef(refs, db.exactRef("refs/heads/prefix/a")); checkContainsRef(refs, db.exactRef("refs/heads/pa")); checkContainsRef(refs, db.exactRef("refs/tags/A")); }
Source:
<code>private boolean isManagementNetworkChanged(){ String mgmtNetworkName = managementNetworkUtil.getManagementNetwork(getVds().getVdsGroupId()).getName(); <START> for (VdsNetworkInterface modifiedNic : getModifiedInterfaces()) { <END> if (mgmtNetworkName.equals(modifiedNic.getNetworkName())){ return true; } } for (VdsNetworkInterface bond : getBonds()) { if (mgmtNetworkName.equals(bond.getNetworkName())){ return true; } } return false; }</code><technical_language>'modifiedInterfaces' existing nics label changes. list check is 'getNetworks()'</technical_language>

Target:
private boolean isManagementNetworkChanged(){ String mgmtNetworkName = managementNetworkUtil.getManagementNetwork(getVds().getVdsGroupId()).getName(); for (Network netowrk : getNetworks()) { if (mgmtNetworkName.equals(netowrk.getName())){ return true; } } for (VdsNetworkInterface bond : getBonds()) { if (mgmtNetworkName.equals(bond.getNetworkName())){ return true; } } return false; }
Source:
<code>private void populateInitialFromUri(BasicBrooklynCatalog catalog, String catalogUrl, PopulateMode mode) { log.debug("Loading initial catalog from {}", catalogUrl); Exception problem = null; Object result = null; String contents = null; try { contents = new ResourceUtils(this).getResourceAsString(catalogUrl); } catch (Exception e) { Exceptions.propagateIfFatal(e); if (problem==null) problem = e; } if (contents!=null && (mode==PopulateMode.YAML || mode==PopulateMode.AUTODETECT)) { try { catalog.reset(MutableList.<CatalogItem<?,?>>of()); result = catalog.addItems(contents); } catch (Exception e) { Exceptions.propagateIfFatal(e); if (problem==null) problem = e; } } if (result==null && contents!=null && (mode==PopulateMode.XML || mode==PopulateMode.AUTODETECT)) { <START> problem = populateInitialFromUriXml(catalog, catalogUrl, problem, contents); <END> } if (result!=null) { log.debug("Loaded initial catalog from {}: {}", catalogUrl, result); } if (problem!=null) { log.warn("Error importing catalog from " + catalogUrl + ": " + problem, problem); } }</code><technical_language>Minor preference: I code clearer if try-catch in this method (similar YAML code above), passing problem in a parameter in method call here</technical_language>

Target:
private void populateInitialFromUri(BasicBrooklynCatalog catalog, String catalogUrl, PopulateMode mode) { log.debug("Loading initial catalog from {}", catalogUrl); Exception problem = null; Object result = null; String contents = null; try { contents = new ResourceUtils(this).getResourceAsString(catalogUrl); } catch (Exception e) { Exceptions.propagateIfFatal(e); if (problem==null) problem = e; } if (contents!=null && (mode==PopulateMode.YAML || mode==PopulateMode.AUTODETECT)) { try { catalog.reset(MutableList.<CatalogItem<?,?>>of()); result = catalog.addItems(contents); } catch (Exception e) { Exceptions.propagateIfFatal(e); if (problem==null) problem = e; } } if (result==null && contents!=null && (mode==PopulateMode.XML || mode==PopulateMode.AUTODETECT)) { try { populateInitialFromUriXml(catalog, catalogUrl, contents); problem = null; } catch (Exception e) { Exceptions.propagateIfFatal(e); if (problem==null) problem = e; } } if (result!=null) { log.debug("Loaded initial catalog from {}: {}", catalogUrl, result); } if (problem!=null) { log.warn("Error importing catalog from " + catalogUrl + ": " + problem, problem); } }
Source:
<code>public ConstructorIO(String apiToken, String apiKey, boolean isHTTPS, String host, String constructorToken) { this.apiToken = apiToken; this.apiKey = apiKey; this.host = host; this.version = this.getVersion(); if (host == null) { this.host = "ac.cnstrc.com"; } if (isHTTPS) { this.protocol = "https"; } else { this.protocol = "http"; } <START> if (constructorToken != null) { <END> this.constructorToken = constructorToken; } this.credentials = "Basic " + Base64.getEncoder().encodeToString((this.apiToken + ":").getBytes()); }</code><technical_language>I check is redundant. If null, set null is setting it</technical_language>

Target:
public ConstructorIO(String apiToken, String apiKey, boolean isHTTPS, String host, String constructorToken) { this.apiToken = apiToken; this.apiKey = apiKey; this.host = host; this.version = this.getVersion(); if (host == null) { this.host = "ac.cnstrc.com"; } if (isHTTPS) { this.protocol = "https"; } else { this.protocol = "http"; } this.constructorToken = constructorToken; this.credentials = "Basic " + Base64.getEncoder().encodeToString((this.apiToken + ":").getBytes()); }
Source:
<code>public void endElement(String uri, String localName, String qName) { if (strings != null && strings[0] != null && qName.equals(nodeName)) { <START> list.add(strings); <END> strings = null; } }</code><technical_language>strings != null && strings[0] != null && qName.equals(nodeName) this check is duplicated (see previous method)</technical_language>

Target:
public void endElement(String uri, String localName, String qName) { if (singleCheckNameList != null && qName.equals(NODE_NAME)) { checkNamesList.add(singleCheckNameList); singleCheckNameList = null; } }
Source:
<code>public OffHeapLoadingCache( @JsonProperty("maxStoreSize") double maxStoreSize, @JsonProperty("maxEntriesSize") long maxEntriesSize, @JsonProperty("expireAfterWrite") long expireAfterWrite, @JsonProperty("expireAfterAccess") long expireAfterAccess ) { this.maxStoreSize = maxStoreSize; this.maxEntriesSize = maxEntriesSize; this.expireAfterWrite = expireAfterWrite; this.expireAfterAccess = expireAfterAccess; this.cache = DB.createHashMap(name) .expireStoreSize(this.maxStoreSize) .expireAfterWrite(this.expireAfterWrite, TimeUnit.MILLISECONDS) .expireAfterAccess(this.expireAfterAccess, TimeUnit.MILLISECONDS) .expireMaxSize(this.maxEntriesSize) .make(); cache.modificationListenerAdd(new Bind.MapListener<K, V>() { @Override public void update(K key, V oldVal, V newVal) { if (oldVal != null && newVal == null) { evictionCount.getAndIncrement(); } } }); <START> this.isClosed.compareAndSet(true, false); <END> }</code><technical_language>set</technical_language>

Target:
public OffHeapLoadingCache( @JsonProperty("maxStoreSize") double maxStoreSize, @JsonProperty("maxEntriesSize") long maxEntriesSize, @JsonProperty("expireAfterWrite") long expireAfterWrite, @JsonProperty("expireAfterAccess") long expireAfterAccess ) { this.maxStoreSize = maxStoreSize; this.maxEntriesSize = maxEntriesSize; this.expireAfterWrite = expireAfterWrite; this.expireAfterAccess = expireAfterAccess; this.cache = DB.createHashMap(name) .expireStoreSize(this.maxStoreSize) .expireAfterWrite(this.expireAfterWrite, TimeUnit.MILLISECONDS) .expireAfterAccess(this.expireAfterAccess, TimeUnit.MILLISECONDS) .expireMaxSize(this.maxEntriesSize) .make(); cache.modificationListenerAdd(new Bind.MapListener<K, V>() { @Override public void update(K key, V oldVal, V newVal) { if (oldVal != null && newVal == null) { evictionCount.getAndIncrement(); } } }); this.closed.set(false); }
Source:
<code>public void generatedVersion1ShouldDecodeLegacyFormat() { final LegacySubscriptionInfoSerde info = new LegacySubscriptionInfoSerde( 1, LATEST_SUPPORTED_VERSION, processId, ACTIVE_TASKS, STANDBY_TASKS, "localhost:80", null ); final ByteBuffer buffer = info.encode(); buffer.rewind(); final SubscriptionInfo decoded = SubscriptionInfo.decode(buffer); assertEquals(1, decoded.version()); assertEquals(SubscriptionInfo.UNKNOWN, decoded.latestSupportedVersion()); assertEquals(processId, decoded.processId()); assertEquals(ACTIVE_TASKS, decoded.prevTasks()); <START> assertEquals(STANDBY_TASKS, decoded.standbyTasks()); <END> assertNull(decoded.userEndPoint()); }</code><technical_language>Q: do pass in null in some other cases pass in TASK_LAGS</technical_language>

Target:
public void generatedVersion1ShouldDecodeLegacyFormat() { final LegacySubscriptionInfoSerde info = new LegacySubscriptionInfoSerde( 1, LATEST_SUPPORTED_VERSION, processId, ACTIVE_TASKS, STANDBY_TASKS, "localhost:80" ); final ByteBuffer buffer = info.encode(); buffer.rewind(); final SubscriptionInfo decoded = SubscriptionInfo.decode(buffer); assertEquals(1, decoded.version()); assertEquals(SubscriptionInfo.UNKNOWN, decoded.latestSupportedVersion()); assertEquals(processId, decoded.processId()); assertEquals(ACTIVE_TASKS, decoded.prevTasks()); assertEquals(STANDBY_TASKS, decoded.standbyTasks()); assertNull(decoded.userEndPoint()); }
Source:
<code>public RespondingGatewayPRPAIN201306UV02ResponseType respondingGatewayPRPAIN201305UV02(PRPAIN201305UV02 pdRequest, AssertionType assertion, NhinTargetCommunitiesType targetCommunities) { LOG.debug("Begin respondingGatewayPRPAIN201305UV02"); RespondingGatewayPRPAIN201306UV02ResponseType response = null; try { String url = getEndpointURL(); if (pdRequest == null) { LOG.error("PRPAIN201305UV02 was null"); } else if (assertion == null) { LOG.error("AssertionType was null"); } else if (targetCommunities == null) { LOG.error("NhinTargetCommunitiesType was null"); } else { RespondingGatewayPRPAIN201305UV02RequestType request = new RespondingGatewayPRPAIN201305UV02RequestType(); request.setPRPAIN201305UV02(pdRequest); request.setAssertion(assertion); request.setNhinTargetCommunities(targetCommunities); response = (RespondingGatewayPRPAIN201306UV02ResponseType) getClient(url, assertion).invokePort( EntityPatientDiscoverySecuredPortType.class, "respondingGatewayPRPAIN201305UV02", request); } } catch (Exception ex) { <START> LOG.error("Error calling respondingGatewayPRPAIN201305UV02: " + ex.getMessage(), ex); <END> } LOG.debug("End respondingGatewayPRPAIN201305UV02"); return response; }</code><technical_language>missing log's parameter</technical_language>

Target:
public RespondingGatewayPRPAIN201306UV02ResponseType respondingGatewayPRPAIN201305UV02(PRPAIN201305UV02 pdRequest, AssertionType assertion, NhinTargetCommunitiesType targetCommunities) { LOG.debug("Begin respondingGatewayPRPAIN201305UV02"); RespondingGatewayPRPAIN201306UV02ResponseType response = null; try { String url = getEndpointURL(); if (pdRequest == null) { LOG.error("PRPAIN201305UV02 was null"); } else if (assertion == null) { LOG.error("AssertionType was null"); } else if (targetCommunities == null) { LOG.error("NhinTargetCommunitiesType was null"); } else { RespondingGatewayPRPAIN201305UV02RequestType request = new RespondingGatewayPRPAIN201305UV02RequestType(); request.setPRPAIN201305UV02(pdRequest); request.setAssertion(assertion); request.setNhinTargetCommunities(targetCommunities); response = (RespondingGatewayPRPAIN201306UV02ResponseType) getClient(url, assertion).invokePort( EntityPatientDiscoverySecuredPortType.class, "respondingGatewayPRPAIN201305UV02", request); } } catch (Exception ex) { LOG.error("Error calling respondingGatewayPRPAIN201305UV02: " , ex.getMessage(), ex); } LOG.debug("End respondingGatewayPRPAIN201305UV02"); return response; }
Source:
<code>public void put(String URL, String key, String value) { if (parseMap.containsKey(URL)) { parseMap.get(URL).getMetadata().addValue(key, value); } else { <START> ParseData parse = ParseData.empty; <END> parse.put(key, value); parseMap.put(URL, parse); } }</code><technical_language>'ParseData.empty' immutable</technical_language>

Target:
public void put(String URL, String key, String value) { if (parseMap.containsKey(URL)) { parseMap.get(URL).getMetadata().addValue(key, value); } else { ParseData parse = new ParseData(); parse.put(key, value); parseMap.put(URL, parse); } }
Source:
<code>public void exportMultipleNatTables( final ILayerExporter exporter, final Map<String, NatTable> natTablesMap) { final OutputStream outputStream = exporter.getOutputStream(this.shell); if (outputStream == null) { return; } Runnable exportRunnable = new Runnable() { @Override public void run() { try { exporter.exportBegin(outputStream); for (String name : natTablesMap.keySet()) { NatTable natTable = natTablesMap.get(name); exportLayer(exporter, outputStream, name, natTable, natTable.getConfigRegistry()); } exporter.exportEnd(outputStream); } catch (IOException e) { throw new RuntimeException("Failed to export.", e); } finally { try { outputStream.close(); } catch (IOException e) { log.error("Failed to close the output stream", e); } } <START> if (NatExporter.this.open) { openExport(exporter); } <END> } }; if (this.shell != null) { this.shell.getDisplay().asyncExec(exportRunnable); } else { exportRunnable.run(); } }</code><technical_language>sense move this check openExport method in general</technical_language>

Target:
public void exportMultipleNatTables( final ILayerExporter exporter, final Map<String, NatTable> natTablesMap) { final OutputStream outputStream = exporter.getOutputStream(this.shell); if (outputStream == null) { return; } Runnable exportRunnable = new Runnable() { @Override public void run() { try { exporter.exportBegin(outputStream); for (String name : natTablesMap.keySet()) { NatTable natTable = natTablesMap.get(name); exportLayer(exporter, outputStream, name, natTable, natTable.getConfigRegistry()); } exporter.exportEnd(outputStream); } catch (IOException e) { throw new RuntimeException("Failed to export.", e); } finally { try { outputStream.close(); } catch (IOException e) { log.error("Failed to close the output stream", e); } } if (NatExporter.this.openResult) { openExport(exporter); } } }; if (this.shell != null) { this.shell.getDisplay().asyncExec(exportRunnable); } else { exportRunnable.run(); } }
Source:
<code>private static void convertAAAProfilesResult(AsyncQuery aQuery) { aQuery.converterCallback = new IAsyncConverter() { @Override public Object Convert(Object source, AsyncQuery _asyncQuery) { List<String> results = new ArrayList<String>(); for (ProfileEntry profileEntry : source != null ? (Collection<ProfileEntry>) source : new <START> ArrayList<ProfileEntry>()) <END> { results.add(profileEntry.getProfile()); } return results; } }; }</code><technical_language>Backend return null, do need a null check for source</technical_language>

Target:
private static void convertAAAProfilesResult(AsyncQuery aQuery) { aQuery.converterCallback = new IAsyncConverter() { @Override public Object Convert(Object source, AsyncQuery _asyncQuery) { List<String> results = new ArrayList<String>(); for (ProfileEntry profileEntry : (Collection<ProfileEntry>) source) { results.add(profileEntry.getProfile()); } return results; } }; }