auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Object perform(InvocationContext ctx) throws Throwable { if (valueMatcher == ValueMatcher.MATCH_NEVER) { successful = false; return null; } MVCCEntry e = (MVCCEntry) ctx.lookupEntry(key); if (e == null) { throw new IllegalStateException("Not wrapped"); } Object prevValue = e.getValue(); if (!valueMatcher.matches(prevValue, null, value, valueEquivalence)) { successful = false; return prevValue; } else if (hasFlag(Flag.COMMAND_RETRY) && putIfAbsent) { <START> e.setValue(null); <END> } return performPut(e, ctx); }</code><technical_language>This right..</technical_language>

Target:
public Object perform(InvocationContext ctx) throws Throwable { if (valueMatcher == ValueMatcher.MATCH_NEVER) { successful = false; return null; } MVCCEntry<Object, Object> e = (MVCCEntry) ctx.lookupEntry(key); if (e == null) { throw new IllegalStateException("Not wrapped"); } Object prevValue = e.getValue(); if (!valueMatcher.matches(prevValue, null, value, valueEquivalence)) { successful = false; return prevValue; } return performPut(e, ctx); }
Source:
<code>public Map<String, Map<String, String>> readContainerLocality() { Map<String, Map<String, String>> allMappings = new HashMap<>(); metadataStore.all().forEach((containerId, valueBytes) -> { if (valueBytes != null) { String locationId = valueSerde.fromBytes(valueBytes); <START> if (StringUtils.isNotBlank(locationId)) { <END> Map<String, String> values = new HashMap<>(); values.put(SetContainerHostMapping.HOST_KEY, locationId); allMappings.put(containerId, values); } } }); if (LOG.isDebugEnabled()) { for (Map.Entry<String, Map<String, String>> entry : allMappings.entrySet()) { LOG.debug(String.format("Locality for container %s: %s", entry.getKey(), entry.getValue())); } } return Collections.unmodifiableMap(allMappings); }</code><technical_language>appears invoking StringUtils.isNotBlank immediately <serde>.fromBytes(). Is create a Util wrapper for serde call this method there. check so: String locationId = new MySerdeWrapper(valueSerde).fromBytes(valueBytes); public class MySerdeWrapper { public Deserializer deserializer; public MySerdeWrapper(Deserializer deserializer) { this.deserializer = deserializer; } public Optional<String> fromBytes(byte[] bytes) { return StringUtils.isNotBlank(deserializer.fromBytes(bytes)) ? Optional.of(deserializer.fromBytes(bytes)) : Optional.empty(); } }</technical_language>

Target:
public Map<String, Map<String, String>> readContainerLocality() { Map<String, Map<String, String>> allMappings = new HashMap<>(); metadataStore.all().forEach((containerId, valueBytes) -> { if (valueBytes != null) { String locationId = valueSerde.fromBytes(valueBytes); Map<String, String> values = new HashMap<>(); values.put(SetContainerHostMapping.HOST_KEY, locationId); allMappings.put(containerId, values); } }); if (LOG.isDebugEnabled()) { for (Map.Entry<String, Map<String, String>> entry : allMappings.entrySet()) { LOG.debug(String.format("Locality for container %s: %s", entry.getKey(), entry.getValue())); } } return Collections.unmodifiableMap(allMappings); }
Source:
<code>public FirmwareInfo getFirmwareDeviceList(@Scope(OAuthScope.ADMINISTRATION_READ) final AccessToken accessToken, @QueryParam("firmware_version") final Long firmwareVersion) { if(firmwareVersion == null) { LOGGER.error("Missing firmwareVersion parameter"); throw new WebApplicationException(Response.Status.BAD_REQUEST); } final Jedis jedis = jedisPool.getResource(); final String fwVersion = firmwareVersion.toString(); Set<String> allFWDevices = new HashSet<>(); try { <START> allFWDevices = jedis.zrange(fwVersion, 0L, 100L); <END> } catch (Exception e) { LOGGER.error("Failed retrieving firmware device count.", e.getMessage()); } finally { jedisPool.returnResource(jedis); } return new FirmwareInfo(fwVersion, allFWDevices); }</code><technical_language>do 0L, 100L represent</technical_language>

Target:
public FirmwareInfo getFirmwareDeviceList(@Scope(OAuthScope.ADMINISTRATION_READ) final AccessToken accessToken, @QueryParam("firmware_version") final Long firmwareVersion) { if(firmwareVersion == null) { LOGGER.error("Missing firmwareVersion parameter"); throw new WebApplicationException(Response.Status.BAD_REQUEST); } final Jedis jedis = jedisPool.getResource(); final String fwVersion = firmwareVersion.toString(); Set<String> allFWDevices = new HashSet<>(); try { allFWDevices = jedis.zrevrange(fwVersion, 0, -1); } catch (Exception e) { LOGGER.error("Failed retrieving firmware device count.", e.getMessage()); } finally { jedisPool.returnResource(jedis); } return new FirmwareInfo(fwVersion, allFWDevices); }
Source:
<code><START> public float[][] initDist(String fromWhat) { <END> float[][] distArr = new float[size][size]; if (fromWhat.equals("water")) { for (int width = 0; width < size; width++) { for (int height = 0; height < size; height++) { float heightFactor = heightmap[height][width] - 1; if (heightFactor < 0) { distArr[height][width] = 0; } else { distArr[height][width] = size; } } } } else if (fromWhat.equals("poles")) { for (int width = 0; width < size; width++) { for (int height = 0; height < size; height++) { if (height == 0) { distArr[height][width] = 0; } else { distArr[height][width] = size; } } } } else if (fromWhat.equals("equator")) { for (int width = 0; width < size; width++) { for (int height = 0; height < size; height++) { if (height == size / 2) { distArr[height][width] = 0; } else { distArr[height][width] = size; } } } } return distArr; }</code><technical_language>this refactoring split individual methods for "fromWhat" value? avoid if (which alternatively turned a switch)</technical_language>

Target:
public float[][] initDist(String fromWhat) { float[][] distArr = new float[size][size]; switch(fromWhat) { case "water": distanceFromWater(distArr); break; case "poles": distanceFromPoles(distArr); break; case "equator": distanceFromEquator(distArr); break; } return distArr; }
Source:
<code>public void getOrganization() throws Exception { final String login = "github"; final Github github = RtOrganizationsITCase.github(); final Organizations orgs = github.users().self().organizations(); <START> final Organization org = orgs.get(login); <END> MatcherAssert.assertThat(org.login(), Matchers.equalTo(login)); }</code><technical_language>A lot of one-time variables created. Please, this manual fix <LINK_0></technical_language>

Target:
public void getOrganization() throws Exception { final String login = "github"; final Organization org = github() .users().self().organizations().get(login); MatcherAssert.assertThat(org.login(), Matchers.equalTo(login)); }
Source:
<code>public void onCurrentThemeFetched(ThemeStore.OnCurrentThemeFetched event) { if (event.isError()) { AppLog.e(T.THEMES, "Error fetching current theme: " + event.error.message); ToastUtils.showToast(this, R.string.theme_fetch_failed, ToastUtils.Duration.SHORT); if (mCurrentTheme != null && mThemeBrowserFragment != null) { if (mThemeBrowserFragment.getCurrentThemeTextView() != null) { mThemeBrowserFragment.getCurrentThemeTextView().setText(mCurrentTheme.getName()); mThemeBrowserFragment.setCurrentThemeId(mCurrentTheme.getThemeId()); } } } else { AppLog.d(T.THEMES, "Current Theme fetch successful!"); mCurrentTheme = event.theme; if (mThemeBrowserFragment != null) { if (mThemeBrowserFragment.getCurrentThemeTextView() != null) { mThemeBrowserFragment.getCurrentThemeTextView().setText(mCurrentTheme.getName()); mThemeBrowserFragment.setCurrentThemeId(mCurrentTheme.getThemeId()); } } <START> if (mThemeSearchFragment != null && mThemeSearchFragment.isVisible()) { <END> mThemeSearchFragment.setRefreshing(false); } } }</code><technical_language>I reviewed implementation of this yet, do get onCurrentThemeFetched callback search fragment? a bit interesting onThemesSearched is expect this code</technical_language>

Target:
public void onCurrentThemeFetched(ThemeStore.OnCurrentThemeFetched event) { if (event.isError()) { AppLog.e(T.THEMES, "Error fetching current theme: " + event.error.message); ToastUtils.showToast(this, R.string.theme_fetch_failed, ToastUtils.Duration.SHORT); if (mCurrentTheme != null && mThemeBrowserFragment != null) { if (mThemeBrowserFragment.getCurrentThemeTextView() != null) { mThemeBrowserFragment.getCurrentThemeTextView().setText(mCurrentTheme.getName()); mThemeBrowserFragment.setCurrentThemeId(mCurrentTheme.getThemeId()); } } } else { AppLog.d(T.THEMES, "Current Theme fetch successful!"); mCurrentTheme = mThemeStore.getActiveThemeForSite(event.site); AppLog.d(T.THEMES, "Current theme is " + mCurrentTheme.getName()); updateCurrentThemeView(); if (mThemeSearchFragment != null && mThemeSearchFragment.isVisible()) { mThemeSearchFragment.setRefreshing(false); } } }
Source:
<code>public static boolean updateServiceUrl(String serviceName, String url) throws Exception { String sHomeCommunityId = HELPER.getHomeCommunityFromPropFile(); OrganizationType newOrganization = getInstance().getOrganization(sHomeCommunityId); if (null == newOrganization) { return false; } EndpointConfigurationType endpointUrl = HELPER.getEndPointConfigBasedOnSpecVersion( HELPER.getServiceEndpointType(newOrganization, serviceName), NhincConstants.ADAPTER_API_LEVEL.LEVEL_a0.name()); endpointUrl.setUrl(url); ExchangeInfoType exchangeInfo = getExchangeInfo(); <START> List<OrganizationType> organizations = HELPER.getOrganizationTypeBy(exchangeInfo); <END> OrganizationType oldOrganization = HELPER.findOrganizationTypeBy(organizations, sHomeCommunityId); if (null == oldOrganization) { return false; } organizations.remove(oldOrganization); organizations.add(newOrganization); getExchangeInfoDAO().saveExchangeInfo(exchangeInfo); return true; }</code><technical_language>List<OrganizationType> getAllOrganizations() method AbstractExchangeManager here</technical_language>

Target:
public boolean updateServiceUrl(String serviceName, String url) throws Exception { if (null == exInfo) { loadExchangeInfo(); } OrganizationType updateOrganization = getOrganization(HELPER.getHomeCommunityFromPropFile()); if (null == updateOrganization) { return false; } EndpointConfigurationType endpointUrl = HELPER.getEndPointConfigBasedOnSpecVersion( HELPER.getServiceEndpointType(updateOrganization, serviceName), NhincConstants.ADAPTER_API_LEVEL.LEVEL_a0.name()); endpointUrl.setUrl(url); getExchangeInfoDAO().saveExchangeInfo(exInfo); return true; }
Source:
<code>public void andThenSingleError() { TestSubscriber<String> ts = new TestSubscriber<String>(0); final AtomicBoolean hasRun = new AtomicBoolean(false); final Exception e = new Exception(); <START> Completable.create(new CompletableOnSubscribe() { <END> @Override public void call(CompletableSubscriber cs) { cs.onError(e); } }) .andThen(Single.<String>create(new Single.OnSubscribe<String>() { @Override public void call(SingleSubscriber<? super String> s) { hasRun.set(true); s.onSuccess("foo"); } })) .subscribe(ts); ts.assertNoValues(); ts.assertError(e); ts.assertUnsubscribed(); Assert.assertFalse("Should not have subscribed to single when completable errors", hasRun.get()); }</code><technical_language>Completable.error(e)</technical_language>

Target:
public void andThenSingleError() { TestSubscriber<String> ts = new TestSubscriber<String>(0); final AtomicBoolean hasRun = new AtomicBoolean(false); final Exception e = new Exception(); Completable.error(e) .andThen(Single.<String>create(new Single.OnSubscribe<String>() { @Override public void call(SingleSubscriber<? super String> s) { hasRun.set(true); s.onSuccess("foo"); } })) .subscribe(ts); ts.assertNoValues(); ts.assertError(e); ts.assertUnsubscribed(); Assert.assertFalse("Should not have subscribed to single when completable errors", hasRun.get()); }
Source:
<code>private Map<String, List<Object>> toStreamLineEvents(Map<FieldName, ?> predScores) { Map<String, List<Object>> streamsToEvents = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>(); <START> predScores.forEach((k, v) -> resultMap.put(k.getValue(), v)); <END> for (Stream stream : outputStreams) { streamsToEvents.put(stream.getId(), Arrays.asList(new StreamlineEventImpl(resultMap, modelId))); } return streamsToEvents; }</code><technical_language>@csivaguru I this is accurate. Please implementation of scoredTuplePerStream in super class. account outputFields predictedFields. Furthermore, I need EvaluatorUtil.decode(targetValue) account for cases values wrapped in complex objects maps. means mimic is done in superclass toValuesMap(), in for loop bellow</technical_language>

Target:
private Map<String, List<Object>> toStreamLineEvents(Map<FieldName, ?> predScores) { Map<String, List<Object>> streamsToEvents = new HashMap<>(); final Map<String, Object> scoredVals = new HashMap<>(); for (FieldName predictedField : getPredictedFields()) { Object targetValue = predScores.get(predictedField); scoredVals.put(predictedField.getValue(), EvaluatorUtil.decode(targetValue)); } for (FieldName outputField : getOutputFields()) { Object targetValue = predScores.get(outputField); scoredVals.put(outputField.getValue(), EvaluatorUtil.decode(targetValue)); }; for (Stream stream : outputStreams) { streamsToEvents.put(stream.getId(), Arrays.asList(new StreamlineEventImpl(scoredVals, modelId))); } return streamsToEvents; }
Source:
<code>private void updateMemoryUsage() { long memorySize = pageBuilder.getRetainedSizeInBytes(); for (Aggregator aggregator : aggregates) { memorySize += aggregator.getEstimatedSize(); } if (step.isOutputPartial()) { systemMemoryContext.setBytes(memorySize); } else { userMemoryContext.setBytes(memorySize); <START> } <END> }</code><technical_language>account form previous page</technical_language>

Target:
private void updateMemoryUsage() { long memorySize = pageBuilder.getRetainedSizeInBytes(); for (Page output : outputPages) { memorySize += output.getRetainedSizeInBytes(); } for (Aggregator aggregator : aggregates) { memorySize += aggregator.getEstimatedSize(); } if (currentGroup != null) { memorySize += currentGroup.getRetainedSizeInBytes(); } if (step.isOutputPartial()) { systemMemoryContext.setBytes(memorySize); } else { userMemoryContext.setBytes(memorySize); } }
Source:
<code>public void testCommandLine() throws IOException { final File tnCoverageFile = LOG2_TN_COVERAGE_FILE; final File snpFile = ALLELIC_COUNTS_FILE; final File outputSegmentFile = createTempFile("segments", ".seg"); final int initialNumCRStates = 10; final int initialNumAFStates = 10; final String[] arguments = { "-" + ExomeStandardArgumentDefinitions.TANGENT_NORMALIZED_COUNTS_FILE_SHORT_NAME, tnCoverageFile.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.TUMOR_ALLELIC_COUNTS_FILE_SHORT_NAME, snpFile.getAbsolutePath(), "-" + PerformJointSegmentation.INITIAL_NUM_COPY_RATIO_STATES_SHORT_NAME, Integer.toString(initialNumCRStates), "-" + PerformJointSegmentation.INITIAL_NUM_ALLELE_FRACTION_STATES_SHORT_NAME, Integer.toString(initialNumAFStates), <START> "-" + ExomeStandardArgumentDefinitions.SEGMENT_FILE_SHORT_NAME, outputSegmentFile.getAbsolutePath(), <END> }; runCommandLine(arguments); final List<ACNVModeledSegment> segments = SegmentUtils.readACNVModeledSegmentFile(outputSegmentFile); }</code><technical_language>Extra trailing comma</technical_language>

Target:
public void testCommandLine() throws IOException { final File tnCoverageFile = LOG2_TN_COVERAGE_FILE; final File snpFile = ALLELIC_COUNTS_FILE; final File outputSegmentFile = createTempFile("segments", ".seg"); final int initialNumCRStates = 3; final int initialNumAFStates = 3; final String[] arguments = { "-" + ExomeStandardArgumentDefinitions.TANGENT_NORMALIZED_COUNTS_FILE_SHORT_NAME, tnCoverageFile.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.TUMOR_ALLELIC_COUNTS_FILE_SHORT_NAME, snpFile.getAbsolutePath(), "-" + PerformJointSegmentation.INITIAL_NUM_COPY_RATIO_STATES_SHORT_NAME, Integer.toString(initialNumCRStates), "-" + PerformJointSegmentation.INITIAL_NUM_ALLELE_FRACTION_STATES_SHORT_NAME, Integer.toString(initialNumAFStates), "-" + ExomeStandardArgumentDefinitions.SEGMENT_FILE_SHORT_NAME, outputSegmentFile.getAbsolutePath() }; runCommandLine(arguments); final List<ACNVModeledSegment> segments = SegmentUtils.readACNVModeledSegmentFile(outputSegmentFile); }
Source:
<code>public void testNullInCommand() { ProcessBuilder pb = new ProcessBuilder("command", "with\u0000inside"); try { pb.start(); fail(); } <START> catch(IOException expected) <END> }</code><technical_language>this a exception \u0000 ? (i.e, "command with.." exist..) for avoidance of doubt, a command exist</technical_language>

Target:
public void testNullInCommand() { ProcessBuilder pb = new ProcessBuilder("ls", "with\u0000inside"); try { pb.start(); fail(); } catch(IOException expected) }
Source:
<code>private List<String> parseFieldDescription(String fieldDescription) { if (fieldDescription == null || fieldDescription.equals("")) { throw new IllegalArgumentException("Invalid query: field name is empty"); } int lastDotIndex = fieldDescription.lastIndexOf("."); if (lastDotIndex == fieldDescription.length() - 1) { throw new IllegalArgumentException("Invalid query: field name must not end with a period ('.')"); } if (lastDotIndex > -1) { return Arrays.asList(FIELD_SEPARATOR.split(fieldDescription)); } else { <START> ArrayList<String> result = new ArrayList<>(1); <END> result.add(fieldDescription); return result; } }</code><technical_language>Is return Collections.singletonList(fieldDescription) here? this mutable</technical_language>

Target:
private List<String> parseFieldDescription(String fieldDescription) { if (fieldDescription == null || fieldDescription.equals("")) { throw new IllegalArgumentException("Invalid query: field name is empty"); } int lastDotIndex = fieldDescription.lastIndexOf("."); if (lastDotIndex == fieldDescription.length() - 1) { throw new IllegalArgumentException("Invalid query: field name must not end with a period ('.')"); } if (lastDotIndex > -1) { return Arrays.asList(FIELD_SEPARATOR.split(fieldDescription)); } else { return Collections.singletonList(fieldDescription); } }
Source:
<code>public SimpleCertificateResponseMessageType deleteTemporaryKeystore( DeleteTemporaryKeystoreRequestMessageType request) { File deleteFile = new File(FILE_JKS_GATEWAY_NEW); if (deleteFile.exists() && deleteFile.delete()) { <START> return buildSimpleResponse(true, "gateway-new delete successful."); <END> } return buildSimpleResponse(false, "gateway-new doesn't exist."); }</code><technical_language>temp certificate here</technical_language>

Target:
public SimpleCertificateResponseMessageType deleteTemporaryKeystore( DeleteTemporaryKeystoreRequestMessageType request) { File deleteFile = new File(FILE_JKS_GATEWAY_NEW); if (deleteFile.exists() && deleteFile.delete()) { return buildSimpleResponse(true, "Temporary Keystore delete successful."); } return buildSimpleResponse(false, "Temporary Keystore doesn't exist."); }
Source:
<code>public Converter getConverter() { if (clazz == char.class) { if (fieldIfPresent != null) { <START> return new PrimitiveConverters.CharFieldSettingConverter(parentContainerIfPresent, fieldIfPresent); <END> } return new PrimitiveConverters.CharConverter(); } else if (clazz == Character.class) { if (fieldIfPresent != null) { return new PrimitiveConverters.CharRefFieldSettingConverter(parentContainerIfPresent, fieldIfPresent); } } else if (clazz == short.class) { if (fieldIfPresent != null) { return new PrimitiveConverters.ShortFieldSettingConverter(parentContainerIfPresent, fieldIfPresent); } return new PrimitiveConverters.ShortConverter(); } else if (clazz == Short.class) { if (fieldIfPresent != null) { return new PrimitiveConverters.ShortRefFieldSettingConverter(parentContainerIfPresent, fieldIfPresent); } } else if (clazz == String.class) { if (fieldIfPresent != null) { return new PrimitiveConverters.StringFieldSettingConverter(parentContainerIfPresent, fieldIfPresent); } return new PrimitiveConverters.StringConverter(); } else if (clazz.isEnum()) { if (fieldIfPresent != null) { return new PrimitiveConverters.EnumFieldSettingConverter( clazz, parentContainerIfPresent, fieldIfPresent ); } return new PrimitiveConverters.EnumConverter(clazz); } else if (clazz == byte.class) { if (fieldIfPresent != null) { return new PrimitiveConverters.ByteFieldSettingConverter(parentContainerIfPresent, fieldIfPresent); } return new PrimitiveConverters.ByteConverter(); } else if (clazz == Byte.class) { if (fieldIfPresent != null) { return new PrimitiveConverters.ByteRefFieldSettingConverter(parentContainerIfPresent, fieldIfPresent); } } if (fieldIfPresent != null) { return new PrimitiveConverters.RefFieldSettingConverter(parentContainerIfPresent, fieldIfPresent); } return new PrimitiveConverters.PrimitivePojoConverter(); }</code><technical_language>ibid</technical_language>

Target:
public Converter getConverter() { if(fieldIfPresent != null) { if(fieldIfPresent.getType().isEnum()) { return new PrimitiveConverters.EnumFieldSettingConverter(fieldIfPresent.getType(), parentContainerIfPresent, fieldIfPresent); } try { Constructor converterConstructor = typeToFieldSettingConverters.get(fieldIfPresent.getType()); if(converterConstructor == null) { return new PrimitiveConverters.RefFieldSettingConverter(parentContainerIfPresent, fieldIfPresent); } return (Converter) converterConstructor.newInstance(parentContainerIfPresent, fieldIfPresent); } catch (Exception e) { throw new RuntimeException(e); } } else { if(clazz.isEnum()) { return new PrimitiveConverters.EnumConverter(clazz); } Converter converter = typeToConverters.get(clazz); if(converter == null) { converter = new PrimitiveConverters.PrimitivePojoConverter(); } return converter; } }
Source:
<code><START> private void cancelRxCommands() { <END> for (CommandHandle commandHandle : fRxCommands.values()) { if (commandHandle.getRequestMonitor() == null) continue; commandHandle.getRequestMonitor().setStatus(genStatus( "Connection is shut down")); commandHandle.getRequestMonitor().done(); } fRxCommands.clear(); }</code><technical_language>safer this method synchronized</technical_language>

Target:
private synchronized void cancelRxCommands() { for (CommandHandle commandHandle : fRxCommands.values()) { if (commandHandle.getRequestMonitor() == null) continue; commandHandle.getRequestMonitor().setStatus(genStatus( "Connection is shut down")); commandHandle.getRequestMonitor().done(); } fRxCommands.clear(); }
Source:
<code>public void createPartControl(Composite parent) { super.createPartControl(parent); createActions(); configureToolBar(getViewSite().getActionBars().getToolBarManager()); IConsole[] consoles = getConsoleManager().getConsoles(); consolesAdded(consoles); getConsoleManager().addConsoleListener(this); <START> getViewSite().getActionBars().updateActionBars(); <END> initPageSwitcher(); }</code><technical_language>need register get IPartListener2 events getViewSite().getPage().addPartListener((IPartListener2)this);</technical_language>

Target:
public void createPartControl(Composite parent) { super.createPartControl(parent); createActions(); configureToolBar(getViewSite().getActionBars().getToolBarManager()); IConsole[] consoles = getConsoleManager().getConsoles(); consolesAdded(consoles); getConsoleManager().addConsoleListener(this); getViewSite().getPage().addPartListener((IPartListener2) this); getViewSite().getActionBars().updateActionBars(); initPageSwitcher(); }
Source:
<code>public Object[] getElements(Object inputElement) { if (inputElement instanceof IBuild) { return getChildren(inputElement); } <START> if (inputElement instanceof String) { <END> return new Object[] { inputElement }; } return NO_ELEMENTS; }</code><technical_language>remore this case</technical_language>

Target:
public Object[] getElements(Object inputElement) { if (inputElement instanceof IBuild) { return getChildren(inputElement); } return NO_ELEMENTS; }
Source:
<code>public void shouldDecomposeListWithNonEmptyTail() { <START> final List<Option<? extends Number>> numberOptionList = List.of(Option.some(1), Option.some(2.0)); <END> final String actual = Match(numberOptionList).of( Case($Cons($Some($(1)), $Cons($Some($(2.0)), $())), (x, xs) -> { final Some<? extends Number> head = x; final List<Some<? extends Number>> tail = xs; return head + "::" + tail; }) ); assertThat(actual).isEqualTo("Some(1)::List(Some(2.0))"); }</code><technical_language>I of added ? extends build currently breaks. compile jdk9 otherwise? Another fix List.<Option<Number>> of(Option.some(1), Option.some(2.0));</technical_language>

Target:
public void shouldDecomposeListWithNonEmptyTail() { final List<Option<Number>> numberOptionList = List.of(Option.some(1), Option.some(2.0)); final String actual = Match(numberOptionList).of( Case($Cons($Some($(1)), $Cons($Some($(2.0)), $())), (Some<Number> x, List<Option<Number>> xs) -> { final Some<Number> head = x; final List<Option<Number>> tail = xs; return head + "::" + tail; }) ); assertThat(actual).isEqualTo("Some(1)::List(Some(2.0))"); }
Source:
<code>protected JdbcDeserializationConverter createInternalConverter(LogicalType type) { switch (type.getTypeRoot()) { case NULL: return v -> null; case BOOLEAN: <START> return v -> (boolean) v; <END> case TINYINT: return v -> (byte) v; case SMALLINT: return v -> (Integer.valueOf(v.toString())).shortValue(); case INTEGER: case INTERVAL_YEAR_MONTH: return v -> (int) v; case BIGINT: case INTERVAL_DAY_TIME: return v -> (long) v; case DATE: return v -> (int) (((Date) v).toLocalDate().toEpochDay()); case TIME_WITHOUT_TIME_ZONE: return v -> ((Time) v).toLocalTime().toSecondOfDay() * 1000; case TIMESTAMP_WITH_TIME_ZONE: case TIMESTAMP_WITHOUT_TIME_ZONE: return v -> TimestampData.fromTimestamp((Timestamp) v); case FLOAT: return v -> (float) v; case DOUBLE: return v -> (double) v; case CHAR: case VARCHAR: return v -> StringData.fromString((String) v); case BINARY: case VARBINARY: return v -> (byte[]) v; case DECIMAL: final int precision = ((DecimalType) type).getPrecision(); final int scale = ((DecimalType) type).getScale(); return v -> DecimalData.fromBigDecimal((BigDecimal) v, precision, scale); case ARRAY: final JdbcDeserializationConverter arrayConverter = createToInternalArrayConverter((ArrayType) type); return v -> arrayConverter.deserialize(v); case ROW: case MAP: case MULTISET: case RAW: default: throw new UnsupportedOperationException("Not support to parse type: " + type); } }</code><technical_language>need hard unboxing here. boxing GenericRowData later</technical_language>

Target:
protected JdbcDeserializationConverter createInternalConverter(LogicalType type) { switch (type.getTypeRoot()) { case NULL: return v -> null; case BOOLEAN: case TINYINT: case FLOAT: case DOUBLE: case INTEGER: case INTERVAL_YEAR_MONTH: case BIGINT: case INTERVAL_DAY_TIME: return v -> v; case SMALLINT: return v -> (Integer.valueOf(v.toString())).shortValue(); case DATE: return v -> (int) (((Date) v).toLocalDate().toEpochDay()); case TIME_WITHOUT_TIME_ZONE: return v -> (int) (((Time) v).toLocalTime().toNanoOfDay() / 1_000_000L); case TIMESTAMP_WITH_TIME_ZONE: case TIMESTAMP_WITHOUT_TIME_ZONE: return v -> TimestampData.fromTimestamp((Timestamp) v); case CHAR: case VARCHAR: return v -> StringData.fromString((String) v); case BINARY: case VARBINARY: return v -> (byte[]) v; case DECIMAL: final int precision = ((DecimalType) type).getPrecision(); final int scale = ((DecimalType) type).getScale(); return v -> DecimalData.fromBigDecimal((BigDecimal) v, precision, scale); case ARRAY: case ROW: case MAP: case MULTISET: case RAW: default: throw new UnsupportedOperationException("Unsupported type:" + type); } }
Source:
<code>protected KijiMapCellIterator(String family, HBaseKijiRowData rowdata) throws IOException { mFamily = family; mColumnNameTranslator = new ColumnNameTranslator(rowdata.mTableLayout); mDecoder = rowdata.getDecoder(family, null); KijiDataRequest.Column columnRequest = rowdata.mDataRequest.getColumn(family, null); mMaxVersions = columnRequest.getMaxVersions(); <START> mKVs = rowdata.mResult.list().iterator(); <END> mNumVersions = mKVs.hasNext() ? mMaxVersions : 0; }</code><technical_language>I realize Result.list() creates entire list of KeyValue Result. Result.raw() direct access internal KeyValue[] instead</technical_language>

Target:
protected KijiMapCellIterator(String family, HBaseKijiRowData rowdata) throws IOException { mFamily = family; mColumnNameTranslator = new ColumnNameTranslator(rowdata.mTableLayout); mDecoder = rowdata.getDecoder(family, null); KijiDataRequest.Column columnRequest = rowdata.mDataRequest.getColumn(family, null); mMaxVersions = columnRequest.getMaxVersions(); mKVs = new ArrayIterator(rowdata.mResult.raw()); mNumVersions = mKVs.hasNext() ? mMaxVersions : 0; }
Source:
<code>public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final CpioArchiveEntry other = (CpioArchiveEntry) obj; if (name == null) { return other.name == null; <START> } else return name.equals(other.name); <END> }</code><technical_language>please add braces for else block</technical_language>

Target:
public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final CpioArchiveEntry other = (CpioArchiveEntry) obj; if (name == null) { return other.name == null; } else { return name.equals(other.name); } }
Source:
<code>public static IntervalList fromPath(final Path path) { <START> final BufferedReader reader = IOUtil.openFileForBufferedReading(path); <END> final IntervalList list = fromReader(reader); try { reader.close(); } catch (final IOException e) { throw new SAMException(String.format("Failed to close file %s after reading", path)); } return list; }</code><technical_language>want more ugly path.toUri().toString() path.toString() drop scheme</technical_language>

Target:
public static IntervalList fromPath(final Path path) { final BufferedReader reader = IOUtil.openFileForBufferedReading(path); final IntervalList list = fromReader(reader); try { reader.close(); } catch (final IOException e) { throw new SAMException(String.format("Failed to close file %s after reading", path.toUri().toString())); } return list; }
Source:
<code>private boolean internalValidateAndSetQuota() { <START> if ((isInternalExecution() && !isQuotaInternalDependent()) || !isQuotaDependant()) { <END> return true; } QuotaConsumptionParametersWrapper quotaConsumptionParametersWrapper = new QuotaConsumptionParametersWrapper(this, getReturnValue().getCanDoActionMessages()); quotaConsumptionParametersWrapper.setParameters(getQuotaConsumptionParameters()); List<QuotaConsumptionParameter> quotaParams = quotaConsumptionParametersWrapper.getParameters(); if (quotaParams == null) { throw new InvalidQuotaParametersException("Command: " + this.getClass().getName() + ". No Quota parameters available."); } if (quotaParams.isEmpty()) { return true; } if (getStoragePool() == null) { throw new InvalidQuotaParametersException("Command: " + this.getClass().getName() + ". Storage pool is not available for quota calculation. "); } boolean result = getQuotaManager().consume(quotaConsumptionParametersWrapper); setQuotaChanged(result); return result; }</code><technical_language>change this 'if', "isInternal" part of isQuotaDependant</technical_language>

Target:
private boolean internalValidateAndSetQuota() { if (!isQuotaDependant()) { return true; } QuotaConsumptionParametersWrapper quotaConsumptionParametersWrapper = new QuotaConsumptionParametersWrapper(this, getReturnValue().getCanDoActionMessages()); quotaConsumptionParametersWrapper.setParameters(getQuotaConsumptionParameters()); List<QuotaConsumptionParameter> quotaParams = quotaConsumptionParametersWrapper.getParameters(); if (quotaParams == null) { throw new InvalidQuotaParametersException("Command: " + this.getClass().getName() + ". No Quota parameters available."); } if (quotaParams.isEmpty()) { return true; } if (getStoragePool() == null) { throw new InvalidQuotaParametersException("Command: " + this.getClass().getName() + ". Storage pool is not available for quota calculation. "); } boolean result = getQuotaManager().consume(quotaConsumptionParametersWrapper); setQuotaChanged(result); return result; }
Source:
<code>public DataRegistration.Builder key(Key<?> key, Key<?>... others) { this.keys.add(key); <START> this.keys.addAll(Arrays.asList(others)); <END> return this; }</code><technical_language>Collections#addAll</technical_language>

Target:
public DataRegistration.Builder key(Key<?> key, Key<?>... others) { this.keys.add(key); Collections.addAll(this.keys, others); return this; }
Source:
<code>private static void logJSError(WebDriver driver){ if (Global.JS_ERROR_ENABLED){ JavascriptExecutor js = (JavascriptExecutor) driver; <START> ArrayList<String> error = (ArrayList<String>) js.executeScript("return window.JSErrorCollector_errors.pump()"); <END> if (!error.isEmpty()) { StringBuilder builder = new StringBuilder(); builder.append("<tr class=\"error\"><td>click</td><td>"+error+"</td><td> <br/> &nbsp;</td></tr>"); CommonUtils.appendTextToFile(logPath, builder.toString()); } } }</code><technical_language>break line</technical_language>

Target:
private static void logJSError(WebDriver driver){ if (Global.JS_ERROR_ENABLED){ JavascriptExecutor js = (JavascriptExecutor) driver; ArrayList<String> error = (ArrayList<String>) js.executeScript( "return window.JSErrorCollector_errors.pump()" ); if (!error.isEmpty()) { StringBuilder builder = new StringBuilder(); builder.append( "<tr class=\"error\">" + "<td>click</td>" + "<td>"+error+"</td>" + "<td> <br/> &nbsp;</td></tr>"); CommonUtils.appendTextToFile(logPath, builder.toString()); } } }
Source:
<code>public static void unregisterLoggingContext() { MDC.remove(SESSIONID_LOG_KEY); MDC.remove(QUERYID_LOG_KEY); MDC.remove(OPERATIONLOG_LEVEL_KEY); l4j.info("Unregistered logging context."); <START> if (MDC.get(OPERATIONLOG_LEVEL_KEY) != null) { <END> throw new RuntimeException("Keys removal failed from thread context MDC"); } }</code><technical_language>do need this check</technical_language>

Target:
public static void unregisterLoggingContext() { MDC.remove(SESSIONID_LOG_KEY); MDC.remove(QUERYID_LOG_KEY); MDC.remove(OPERATIONLOG_LEVEL_KEY); l4j.info("Unregistered logging context."); }
Source:
<code>static String safeName(String name) { if (name == null) { return null; } boolean prevCharIsUnderscore = false; <START> StringBuilder safeNameBuilder = new StringBuilder(); <END> for (char nameChar : name.toCharArray()) { boolean isUnsafeChar = !(Character.isLetterOrDigit(nameChar) || nameChar == ':' || nameChar == '_'); if ((isUnsafeChar || nameChar == '_') && !prevCharIsUnderscore) { safeNameBuilder.append("_"); prevCharIsUnderscore = true; } else if (nameChar == '_' || isUnsafeChar) { continue; } else { safeNameBuilder.append(nameChar); prevCharIsUnderscore = false; } } return safeNameBuilder.toString(); }</code><technical_language>provide a capacity here, a more efficient</technical_language>

Target:
static String safeName(String name) { if (name == null) { return null; } boolean prevCharIsUnderscore = false; StringBuilder safeNameBuilder = new StringBuilder(name.length()); for (char nameChar : name.toCharArray()) { boolean isUnsafeChar = !(Character.isLetterOrDigit(nameChar) || nameChar == ':' || nameChar == '_'); if ((isUnsafeChar || nameChar == '_')) { if (prevCharIsUnderscore) { continue; } else { safeNameBuilder.append("_"); prevCharIsUnderscore = true; } } else { safeNameBuilder.append(nameChar); prevCharIsUnderscore = false; } } return safeNameBuilder.toString(); }
Source:
<code>private boolean isInitBooleanFalse(LiteralTree initTree) { <START> if (initTree.symbolType().isPrimitive(Primitives.BOOLEAN) && !Boolean.parseBoolean(initTree.value())) { <END> return true; } return false; }</code><technical_language>I pretty this if(cond) true else false refactored ;) check if dealing a boolean literal is is(Tree.Kind.BOOLEAN_LITERAL) need trigger semantic for this</technical_language>

Target:
private static boolean isInitBooleanFalse(LiteralTree initTree) { return initTree.is(Tree.Kind.BOOLEAN_LITERAL) && !Boolean.parseBoolean(initTree.value()); }
Source:
<code>void writeWithThrowable(StringBuilder buf, Throwable t) { if (t != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); buf.append(sw.toString()); <START> pw.close(); <END> } System.out.println(buf.toString()); }</code><technical_language>try-with-resources ensure resource is closed</technical_language>

Target:
void writeWithThrowable(StringBuilder buf, Throwable t) { if (t != null) { StringWriter sw = new StringWriter(); try (PrintWriter pw = new PrintWriter(sw)) { t.printStackTrace(pw); buf.append(sw.toString()); } } System.out.println(buf.toString()); }
Source:
<code>public PeriodicMeterReadsResponse getPeriodicMeterReadsResponse( @OrganisationIdentification final String organisationIdentification, @RequestPayload final PeriodicMeterReadsAsyncRequest request) throws OsgpException { LOGGER.debug("Incoming PeriodicMeterReadsAsyncRequest for meter: {}.", request.getDeviceIdentification()); PeriodicMeterReadsResponse response = null; try { final MeterResponseData meterResponseData = this.monitoringService .dequeuePeriodicMeterReadsResponse(request.getCorrelationUid()); <START> if (OsgpResultType.NOT_OK == OsgpResultType.fromValue(meterResponseData.getResultType().getValue())) { <END> if (meterResponseData.getMessageData() instanceof String) { throw new TechnicalException(ComponentType.WS_SMART_METERING, (String) meterResponseData.getMessageData(), null); } else { throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred retrieving the periodic meter reads.", null); } } response = this.monitoringMapper.map(meterResponseData.getMessageData(), com.alliander.osgp.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsResponse.class); } catch (final Exception e) { this.handleRetrieveException(e, request, organisationIdentification); } return response; }</code><technical_language>This OsgpResultType + instance of getMessageData is repeated a lot. instance type error message differtent. this is put in a method classtype error message passed parameters</technical_language>

Target:
public PeriodicMeterReadsResponse getPeriodicMeterReadsResponse( @OrganisationIdentification final String organisationIdentification, @RequestPayload final PeriodicMeterReadsAsyncRequest request) throws OsgpException { LOGGER.debug("Incoming PeriodicMeterReadsAsyncRequest for meter: {}.", request.getDeviceIdentification()); PeriodicMeterReadsResponse response = null; try { final MeterResponseData meterResponseData = this.monitoringService .dequeuePeriodicMeterReadsResponse(request.getCorrelationUid()); this.throwExceptionIfResultNotOk(meterResponseData, "retrieving the periodic meter reads"); response = this.monitoringMapper.map(meterResponseData.getMessageData(), com.alliander.osgp.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsResponse.class); } catch (final Exception e) { this.handleRetrieveException(e, request, organisationIdentification); } return response; }
Source:
<code>private static EdgeType resolveIRQ(int vec) { EdgeType ret = EdgeType.UNKNOWN; <START> switch (vec) { <END> case 0: ret = EdgeType.INTERRUPTED; break; case 19: case 23: ret = EdgeType.USER_INPUT; break; default: ret = EdgeType.UNKNOWN; break; } return ret; }</code><technical_language>timer irq zero is a constant. However, other values vary retreived lttng_statedump_interrupt events. For now, variable IRQ numbers removed switch case, represent USER_INPUT depending computer. This fix is left for future work a todo item added</technical_language>

Target:
private static EdgeType resolveIRQ(int vec) { EdgeType ret = EdgeType.UNKNOWN; switch (vec) { case IRQ_TIMER: ret = EdgeType.INTERRUPTED; break; default: ret = EdgeType.UNKNOWN; break; } return ret; }
Source:
<code>public void checkShareWorkspaceTab() { workspaceShare.waitMemberNameInShareList(systemAdminName); assertEquals(workspaceShare.getMemberPermissions(systemAdminName), ADMIN_PERMISSIONS); <START> workspaceShare.clickOnMemberCheckbox(systemAdminName); <END> assertTrue(workspaceShare.isMemberCheckedInList(systemAdminName)); workspaceShare.clickOnMemberCheckbox(systemAdminName); assertFalse(workspaceShare.isMemberCheckedInList(systemAdminName)); workspaceShare.clickOnBulk(); assertTrue(workspaceShare.isMemberCheckedInList(systemAdminName)); workspaceShare.clickOnBulk(); assertFalse(workspaceShare.isMemberCheckedInList(systemAdminName)); }</code><technical_language>a separate test checkSelectingMemberByCheckbox, IMHO I prefer specialized tests generalized ones</technical_language>

Target:
public void checkShareWorkspaceTab() { workspaceShare.waitMemberNameInShareList(systemAdminName); assertEquals(workspaceShare.getMemberPermissions(systemAdminName), ADMIN_PERMISSIONS); }
Source:
<code>public void convert(JsonElement value, ColumnVector vect, int row) { if (value == null || value.isJsonNull()) { vect.noNulls = false; vect.isNull[row] = true; } else { MapColumnVector vector = (MapColumnVector) vect; JsonObject obj = value.getAsJsonObject(); Set<String> keySet = obj.keySet(); vector.lengths[row] = obj.size(); vector.offsets[row] = row > 0 ? vector.offsets[row - 1] + vector.lengths[row - 1] : 0; <START> vector.keys.ensureSize(keySet.size(), true); <END> int i = 0; for (String key : obj.keySet()) { childrenConverters[0].convert(new JsonPrimitive(key), vector.keys, (int) vector.offsets[row] + i); childrenConverters[1].convert(obj.get(key), vector.values, (int) vector.offsets[row] + i); i++; } } }</code><technical_language>Waiting for investigation</technical_language>

Target:
public void convert(JsonElement value, ColumnVector vect, int row) { if (value == null || value.isJsonNull()) { vect.noNulls = false; vect.isNull[row] = true; } else { MapColumnVector vector = (MapColumnVector) vect; JsonObject obj = value.getAsJsonObject(); vector.lengths[row] = obj.size(); vector.offsets[row] = row > 0 ? vector.offsets[row - 1] + vector.lengths[row - 1] : 0; vector.keys.ensureSize((int) vector.offsets[row] + obj.size(), true); vector.values.ensureSize((int) vector.offsets[row] + obj.size(), true); int i = 0; for (String key : obj.keySet()) { childrenConverters[0].convert(new JsonPrimitive(key), vector.keys, (int) vector.offsets[row] + i); childrenConverters[1].convert(obj.get(key), vector.values, (int) vector.offsets[row] + i); i++; } } }
Source:
<code>protected void initButtons(IObservableList list) { initAddButton(addButton, list); initRemoveButton(removeButton, list); initUpButton(upButton, list); initDownButton(downButton, list); getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { final boolean emptySelection = event.getSelection().isEmpty(); final boolean enabledElement = getVElement().isEffectivelyEnabled(); final boolean enable = !emptySelection && enabledElement; if (removeButton != null) { removeButton.setEnabled(enable); } if (upButton != null) { <START> upButton.setEnabled(enable); <END> } if (downButton != null) { downButton.setEnabled(enable); } } }); }</code><technical_language>disable button, if selected index is 0 move</technical_language>

Target:
protected void initButtons(IObservableList list) { initAddButton(addButton, list); initRemoveButton(removeButton, list); initUpButton(upButton, list); initDownButton(downButton, list); getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { updateButtonEnabling(); } }); updateButtons(); }
Source:
<code><START> protected MemcachedClientCallback createMemcachedClientCallback() { <END> return new MemcachedClientCallback() { @Override public byte[] get(final String key) throws IOException { return _memcached.get(_memcachedNodesManager.getStorageKeyFormat().format( key )); } }; }</code><technical_language>MemcachedClientCallback renamed StorageClientCallback</technical_language>

Target:
protected MemcachedClientCallback createMemcachedClientCallback() { return new MemcachedClientCallback() { @Override public byte[] get(final String key) { return _memcached.get(_memcachedNodesManager.getStorageKeyFormat().format( key )); } }; }
Source:
<code>private static void calculatePLIndexToAlleleIndices(final int altAlleles, final int ploidy, final List<List<Integer>> anyploidPLIndexToAlleleIndices, final List<Integer> genotype) { for (int a=0; a <= altAlleles; a++) { final List<Integer> gt = new ArrayList<Integer>(Arrays.asList(a)); gt.addAll(genotype); if ( ploidy == 1 ) <START> anyploidPLIndexToAlleleIndices.add(gt); <END> else if ( ploidy > 1 ) calculatePLIndexToAlleleIndices(a, ploidy-1, anyploidPLIndexToAlleleIndices, gt); } }</code><technical_language>sorry, missed this before: multiple lines, please braces: if () { ... } else { .. }</technical_language>

Target:
private static void calculatePLIndexToAlleleIndices(final int altAlleles, final int ploidy, final List<List<Integer>> anyploidPLIndexToAlleleIndices, final List<Integer> genotype) { for (int a=0; a <= altAlleles; a++) { final List<Integer> gt = new ArrayList<Integer>(Arrays.asList(a)); gt.addAll(genotype); if ( ploidy == 1 ) { anyploidPLIndexToAlleleIndices.add(gt); } else if ( ploidy > 1 ) { calculatePLIndexToAlleleIndices(a, ploidy - 1, anyploidPLIndexToAlleleIndices, gt); } } }
Source:
<code>public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) { final boolean checkRequest = !onlyCheckPostRequest || ContextHelper.isPost(context); if (checkRequest) { final String parameterToken = context.getRequestParameter(parameterName).orElse(null); final String headerToken = context.getRequestHeader(headerName).orElse(null); final Optional<String> sessionToken = context.getSessionStore().get(context, Pac4jConstants.CSRF_TOKEN); <START> return sessionToken.isPresent() && (sessionToken.get().equals(parameterToken) || sessionToken.get().equals(headerToken)); <END> } else { return true; } }</code><technical_language>I prefer a map boolean a orElse(false)</technical_language>

Target:
public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) { final boolean checkRequest = !onlyCheckPostRequest || ContextHelper.isPost(context); if (checkRequest) { final Optional<String> parameterToken = context.getRequestParameter(parameterName); final Optional<String> headerToken = context.getRequestHeader(headerName); final Optional<String> sessionToken = context.getSessionStore().get(context, Pac4jConstants.CSRF_TOKEN); return sessionToken.map( sessionTokenValue -> parameterToken.map( pt -> sessionToken.equals(pt)).orElse(false) || headerToken.map( ht -> sessionToken.equals(ht)).orElse(false) ).orElse(false); } else { return true; } }
Source:
<code>public String resolve(PartyContact contact) { <START> return getResolver(contact.getClass()).getPresentationValue(contact); <END> }</code><technical_language>Calling getResolver(contact.getClass()) result in a null return value. This checked underlying map contains</technical_language>

Target:
public String resolve(PartyContact contact) { ContactResolver contactResolver = getResolver(contact.getClass()); return contactResolver != null ? contactResolver.getPresentationValue(contact) : contact.getPresentationValue(); }