auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public float getMin() { if (dataPoints.size() == 0) { <START> return 0; <END> } float smallestValue = dataPoints.get(0).floatValue(); for (int i = 1; i < dataPoints.size(); i++) { if (dataPoints.get(i).floatValue() < smallestValue) { smallestValue = dataPoints.get(i).floatValue(); } } return smallestValue; }</code><technical_language>largestAbsDeviation negative? clear if absoluteDeviation is assigned output of Math.abs()</technical_language>

Target:
public double getMin() { if (dataPoints.size() == 0) { return 0; } double smallestValue = dataPoints.get(0).doubleValue(); for (int i = 1; i < dataPoints.size(); i++) { if (dataPoints.get(i).doubleValue() < smallestValue) { smallestValue = dataPoints.get(i).doubleValue(); } } return smallestValue; }
Source:
<code>public boolean isEnabled(final String serviceId) { checkNotNull(serviceId); if ("wms".equalsIgnoreCase(serviceId)) { return isWMSCEnabled(); } if ("wmts".equalsIgnoreCase(serviceId)) { <START> throw new ServiceException("To check if WMTS service is enable or disable use service info."); <END> } if ("tms".equalsIgnoreCase(serviceId)) { return isTMSEnabled(); } return true; }</code><technical_language>ServiceExceptions for OGC errors, this is internal programming error instead no? moved check for WMTS enabled a normal ServiceInfo, this check anymore, right</technical_language>

Target:
public boolean isEnabled(final String serviceId) { checkNotNull(serviceId); if ("wms".equalsIgnoreCase(serviceId)) { return isWMSCEnabled(); } if ("wmts".equalsIgnoreCase(serviceId)) { throw new RuntimeException("To check if WMTS service is enable or disable use service info."); } if ("tms".equalsIgnoreCase(serviceId)) { return isTMSEnabled(); } return true; }
Source:
<code>public String getUsage() { StringBuilder sb = new StringBuilder(); sb.append("Usage: convert_type_ids -[P|U]\n"); sb.append("Synopsis:\n"); sb.append("This command will convert local type ids to remote type ids and vice versa (if needed to go back)\n"); <START> sb.append("When ran without the [P] option, it only prints the numbers of rows in each table.\n"); <END> sb.append("When ran with the [P] option, it converts the database putting remote_ids in for local_ids\n"); sb.append("When ran with the [U] (undo) option, it converts the database putting back local_ids in for remotes\n"); sb.append("Options:\n"); sb.append("\tP: Convert the database\n"); sb.append("\tU: Unconvert the database\n"); return sb.toString(); }</code><technical_language>read ran -P -U options ... If options ..</technical_language>

Target:
public String getUsage() { StringBuilder sb = new StringBuilder(); sb.append("Usage: convert_type_ids -[P|U]\n"); sb.append("Synopsis:\n"); sb.append("This command will convert local type ids to remote type ids and vice versa (if needed to go back)\n"); sb.append("When ran without the -P or -U option, it only prints the numbers of rows in each table.\n"); sb.append("When ran with the -P option, it converts the database putting remote_ids in for local_ids\n"); sb.append("When ran with the -U (undo) option, it converts the database putting back local_ids in for remotes\n"); sb.append("Options:\n"); sb.append("\tP: Convert the database\n"); sb.append("\tU: Unconvert the database\n"); return sb.toString(); }
Source:
<code>public void increment(long amount) { long now = System.currentTimeMillis(); <START> long ellapsedTime = now - buckets.get().getTimestamp(); <END> long currentBucketKey = TimeUnit.SECONDS.convert(ellapsedTime, TimeUnit.MILLISECONDS); incrementBucket(currentBucketKey, amount); trimBuckets(currentBucketKey); }</code><technical_language>s/ellapsed/elapsed/</technical_language>

Target:
public void increment(long amount) { long now = System.currentTimeMillis() / 1000L; int index = (int) now % numBuckets; buckets.get().addAndGet(index, amount); }
Source:
<code>private void addCurrencyPairMetadata( Map<CurrencyPair, CurrencyPairMetaData> pairs, CurrencyPair pair, CurrencyPairMetaData pairMetadata) { CurrencyPairMetaData baseMetaData = pairs.get(pair); BigDecimal maxAmount = baseMetaData == null ? pairMetadata.getMaximumAmount() : baseMetaData.getMaximumAmount(); pairs.put( pair, new CurrencyPairMetaData( pairMetadata.getTradingFee(), pairMetadata.getMinimumAmount(), maxAmount, pairMetadata.getPriceScale(), <START> null)); <END> }</code><technical_language>builder</technical_language>

Target:
private void addCurrencyPairMetadata( Map<CurrencyPair, CurrencyPairMetaData> pairs, CurrencyPair pair, CurrencyPairMetaData pairMetadata) { CurrencyPairMetaData baseMetaData = pairs.get(pair); BigDecimal maxAmount = baseMetaData == null ? pairMetadata.getMaximumAmount() : baseMetaData.getMaximumAmount(); pairs.put( pair, new CurrencyPairMetaData.Builder() .tradingFee(pairMetadata.getTradingFee()) .minimumAmount(pairMetadata.getMinimumAmount()) .maximumAmount(maxAmount) .priceScale(pairMetadata.getPriceScale()) .build()); }
Source:
<code>public Optional<QueryId> chooseQueryToKill(List<QueryMemoryInfo> queries, List<MemoryInfo> nodes) { Map<QueryId, Long> memoryReservationOnBlockedNodes = new HashMap<>(); for (MemoryInfo node : nodes) { MemoryPoolInfo generalPool = node.getPools().get(GENERAL_POOL); if (generalPool == null) { continue; } if (generalPool.getFreeBytes() + generalPool.getReservedRevocableBytes() > 0) { continue; } Map<QueryId, Long> queryMemoryReservations = generalPool.getQueryMemoryReservations(); for (Map.Entry<QueryId, Long> query : queryMemoryReservations.entrySet()) { QueryId queryId = query.getKey(); long memoryReservation = query.getValue(); memoryReservationOnBlockedNodes.compute(queryId, (id, oldValue) -> oldValue == null ? memoryReservation : oldValue + memoryReservation); } } QueryId biggestQuery = null; long maxMemory = 0; <START> for (Map.Entry<QueryId, Long> query : memoryReservationOnBlockedNodes.entrySet()) { <END> long bytesUsed = query.getValue(); if (bytesUsed > maxMemory) { biggestQuery = query.getKey(); maxMemory = bytesUsed; } } return Optional.ofNullable(biggestQuery); }</code><technical_language>I is a stream form for this... stream entries, get max a custom ordering of entry.getValue</technical_language>

Target:
public Optional<QueryId> chooseQueryToKill(List<QueryMemoryInfo> queries, List<MemoryInfo> nodes) { Map<QueryId, Long> memoryReservationOnBlockedNodes = new HashMap<>(); for (MemoryInfo node : nodes) { MemoryPoolInfo generalPool = node.getPools().get(GENERAL_POOL); if (generalPool == null) { continue; } if (generalPool.getFreeBytes() + generalPool.getReservedRevocableBytes() > 0) { continue; } Map<QueryId, Long> queryMemoryReservations = generalPool.getQueryMemoryReservations(); queryMemoryReservations.forEach((queryId, memoryReservation) -> { memoryReservationOnBlockedNodes.compute(queryId, (id, oldValue) -> oldValue == null ? memoryReservation : oldValue + memoryReservation); }); } return memoryReservationOnBlockedNodes.entrySet().stream() .max(comparingLong(Map.Entry::getValue)) .map(Map.Entry::getKey); }
Source:
<code>private static boolean isLowMemoryDevice(ActivityManager activityManager) { <START> return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT <END> && activityManager.isLowRamDevice(); }</code><technical_language>some problems shortcutting Build.VERSION before</technical_language>

Target:
private static boolean isLowMemoryDevice(ActivityManager activityManager) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return activityManager.isLowRamDevice(); } else { return false; } }
Source:
<code>private Object toPrestoValue(Object tpcdsValue, Type type) { if (type instanceof VarcharType) { return Slices.utf8Slice((String) tpcdsValue); } else if (type instanceof CharType) { return trimSpacesAndTruncateToLength(Slices.utf8Slice((String) tpcdsValue), type); } <START> else if (type.equals(BIGINT) || type.equals(INTEGER) || type.equals(DATE) || type instanceof DecimalType) { <END> return ((Number) tpcdsValue).longValue(); } else if (type.equals(DOUBLE)) { return ((Number) tpcdsValue).doubleValue(); } else if (type.equals(TimeType.TIME)) { return ((Number) tpcdsValue).longValue(); } throw new IllegalArgumentException("unsupported column type " + type); }</code><technical_language>s/type instanceof DecimalType/(type instanceof DecimalType isShortDecimal....)</technical_language>

Target:
private Object toPrestoValue(Object tpcdsValue, Type type) { if (type instanceof VarcharType) { return Slices.utf8Slice((String) tpcdsValue); } else if (type instanceof CharType) { return trimSpacesAndTruncateToLength(Slices.utf8Slice((String) tpcdsValue), type); } else if (type.equals(BIGINT) || type.equals(INTEGER) || type.equals(DATE) || (type instanceof DecimalType && isShortDecimal(type))) { return ((Number) tpcdsValue).longValue(); } else if (type.equals(DOUBLE)) { return ((Number) tpcdsValue).doubleValue(); } else if (type.equals(TimeType.TIME)) { return ((Number) tpcdsValue).longValue(); } throw new IllegalArgumentException("unsupported column type " + type); }
Source:
<code>public Range(long rangeStart, long rangeEnd) { this.rangeStart = rangeStart; this.rangeEnd = rangeEnd; long numberOfMacsLong = (rangeEnd - rangeStart) + 1; if (numberOfMacsLong > Integer.MAX_VALUE) { throw new IllegalArgumentException(); <START> } <END> int numberOfMacs = (int) numberOfMacsLong; this.availableMacsCount = numberOfMacs; this.usedMacs = new BitSet(numberOfMacs); }</code><technical_language>this class resides in bll apache assertion: org.apache.commons.lang.Validate.isTrue(numberOfMacsLong > Integer.MAX_VALUE, "Range big", numberOfMacsLong);</technical_language>

Target:
public Range(long rangeStart, long rangeEnd) { this.rangeStart = rangeStart; this.rangeEnd = rangeEnd; long numberOfMacsLong = (rangeEnd - rangeStart) + 1; Validate.isTrue(numberOfMacsLong <= Integer.MAX_VALUE, String.format("Range too big; Range shouldn't be bigger than %1$s, but passed one " + "contains %2$s elements.", Integer.MAX_VALUE, numberOfMacsLong)); int numberOfMacs = (int) numberOfMacsLong; this.availableMacsCount = numberOfMacs; this.usedMacs = new BitSet(numberOfMacs); }
Source:
<code>protected Package definePackage(final String name, final String specTitle, final String specVersion, final String specVendor, final String implTitle, final String implVersion, final String implVendor, final URL sealBase) throws IllegalArgumentException { ThreadLocal<Boolean> suppressor = GET_PACKAGE_SUPPRESSOR; suppressor.set(Boolean.TRUE); try { Package existing = packages.get(name); if (existing != null) { return existing; } Package pkg; try { pkg = super.definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); } catch (final IllegalArgumentException iae) { pkg = super.getPackage(name); <START> } <END> existing = packages.putIfAbsent(name, pkg); return existing != null ? existing : pkg; } finally { suppressor.remove(); } }</code><technical_language>this occur? Is this new in Java 9</technical_language>

Target:
protected Package definePackage(final String name, final String specTitle, final String specVersion, final String specVendor, final String implTitle, final String implVersion, final String implVendor, final URL sealBase) throws IllegalArgumentException { ThreadLocal<Boolean> suppressor = GET_PACKAGE_SUPPRESSOR; suppressor.set(Boolean.TRUE); try { Package existing = packages.get(name); if (existing != null) { return existing; } Package pkg; try { pkg = super.definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); } catch (final IllegalArgumentException iae) { pkg = super.getPackage(name); if (pkg == null) throw iae; } existing = packages.putIfAbsent(name, pkg); return existing != null ? existing : pkg; } finally { suppressor.remove(); } }
Source:
<code>public void setReverseDirection(boolean reverseDirection) { if (getReverseDirection() != reverseDirection) { <START> for (CustomEncoder encoder : encoders) { <END> encoder.setReverseDirection(!encoder.getReverseDirection()); } } this.reverseDirection = reverseDirection; }</code><technical_language>Enhanced for loop</technical_language>

Target:
public void setReverseDirection(boolean reverseDirection) { if (getReverseDirection() != reverseDirection) { encoders[0].setReverseDirection(!encoders[0].getReverseDirection()); encoders[1].setReverseDirection(!encoders[1].getReverseDirection()); } this.reverseDirection = reverseDirection; }
Source:
<code>public void testNullRepositoryTest() { <START> assertEquals(null, new NullRepository().fetchInstallableApplications()); <END> }</code><technical_language>want assertNull</technical_language>

Target:
public void testNullRepositoryTest() { assertEquals(new RepositoryDTO.Builder().build(), new NullRepository().fetchInstallableApplications()); }
Source:
<code><START> private void resetValidationState() { <END> getOrCreateComponentModel().validFileType = true; getOrCreateComponentModel().validFileSize = true; }</code><technical_language>Dont do this, for performance working model changing more is get hold locally change values model</technical_language>

Target:
private void resetValidationState() { final FileWidgetModel componentModel = getComponentModel(); if (!componentModel.validFileSize || !componentModel.validFileType) { final FileWidgetModel userModel = getOrCreateComponentModel(); userModel.validFileType = true; userModel.validFileSize = true; } }
Source:
<code><START> protected @Nullable IAnalysisModule findSegmentProviderAnalysis(@NonNull ITmfTrace trace) { <END> return TmfTraceUtils.getAnalysisModuleOfClass(trace, SystemCallLatencyAnalysis.class, checkNotNull(SystemCallLatencyAnalysis.ID)); }</code><technical_language>this return a ISegmentStoreProvider</technical_language>

Target:
protected @Nullable ISegmentStoreProvider findSegmentProviderAnalysis(@NonNull ITmfTrace trace) { return TmfTraceUtils.getAnalysisModuleOfClass(trace, SystemCallLatencyAnalysis.class, SystemCallLatencyAnalysis.ID); }
Source:
<code>protected String[] tableTypes( DatabaseMetaData metadata, Set<String> types ) throws SQLException { Set<String> uppercaseTypes = new HashSet<>(); for (String type : types) { if (type != null) { <START> uppercaseTypes.add(type.toUpperCase()); <END> } } Set<String> matchingTableTypes = new HashSet<>(); try (ResultSet rs = metadata.getTableTypes()) { while (rs.next()) { String tableType = rs.getString(1); if (tableType != null && uppercaseTypes.contains(tableType.toUpperCase())) { matchingTableTypes.add(tableType); } } } return matchingTableTypes.toArray(new String[matchingTableTypes.size()]); }</code><technical_language>toUpperCase(Locale.ROOT)</technical_language>

Target:
protected String[] tableTypes( DatabaseMetaData metadata, Set<String> types ) throws SQLException { Set<String> uppercaseTypes = new HashSet<>(); for (String type : types) { if (type != null) { uppercaseTypes.add(type.toUpperCase(Locale.ROOT)); } } Set<String> matchingTableTypes = new HashSet<>(); try (ResultSet rs = metadata.getTableTypes()) { while (rs.next()) { String tableType = rs.getString(1); if (tableType != null && uppercaseTypes.contains(tableType.toUpperCase(Locale.ROOT))) { matchingTableTypes.add(tableType); } } } return matchingTableTypes.toArray(new String[matchingTableTypes.size()]); }
Source:
<code>protected void onInit() { super.onInit(); <START> this.createGroup(); <END> this.listenMessage(); }</code><technical_language>need this. methods call, do need properties access. Travis report for failed Checkstyle. check build locally: gradlew clean :spring-integration-redis:check</technical_language>

Target:
protected void onInit() { super.onInit(); registerListener(); }
Source:
<code>public void sendRawPdu(SmsTracker[] trackers) { int error = RESULT_ERROR_NONE; PackageInfo appInfo = null; if (mSmsSendDisabled) { Rlog.e(TAG, "Device does not support sending sms."); error = RESULT_ERROR_NO_SERVICE; } else { for (SmsTracker tracker : trackers) { if (tracker.getData().get(MAP_KEY_PDU) == null) { Rlog.e(TAG, "Empty PDU"); error = RESULT_ERROR_NULL_PDU; break; } } if (error == RESULT_ERROR_NONE) { PackageManager pm = mContext.getPackageManager(); String[] packageNames = pm.getPackagesForUid(Binder.getCallingUid()); if (packageNames == null || packageNames.length == 0) { Rlog.e(TAG, "Can't get calling app package name: refusing to send SMS"); error = RESULT_ERROR_GENERIC_FAILURE; } else { try { appInfo = pm.getPackageInfoAsUser( packageNames[0], PackageManager.GET_SIGNATURES, trackers[0].mUserId); } catch (PackageManager.NameNotFoundException e) { Rlog.e(TAG, "Can't get calling app package info: refusing to send SMS"); error = RESULT_ERROR_GENERIC_FAILURE; } } } } if (error != RESULT_ERROR_NONE) { <START> for (SmsTracker tracker : trackers) { tracker.onFailed(mContext, error, 0 ); } <END> return; } if (checkDestination(trackers)) { if (!mSmsDispatchersController .getUsageMonitor() .check(appInfo.packageName, trackers.length)) { sendMessage(obtainMessage(EVENT_SEND_LIMIT_REACHED_CONFIRMATION, trackers)); return; } for (SmsTracker tracker : trackers) { sendSms(tracker); } } if (PhoneNumberUtils.isLocalEmergencyNumber(mContext, trackers[0].mDestAddress)) { new AsyncEmergencyContactNotifier(mContext).execute(); } }</code><technical_language>create a helper function for this takes in trackers, error errorCode done in multiple places</technical_language>

Target:
public void sendRawPdu(SmsTracker[] trackers) { int error = RESULT_ERROR_NONE; PackageInfo appInfo = null; if (mSmsSendDisabled) { Rlog.e(TAG, "Device does not support sending sms."); error = RESULT_ERROR_NO_SERVICE; } else { for (SmsTracker tracker : trackers) { if (tracker.getData().get(MAP_KEY_PDU) == null) { Rlog.e(TAG, "Empty PDU"); error = RESULT_ERROR_NULL_PDU; break; } } if (error == RESULT_ERROR_NONE) { PackageManager pm = mContext.getPackageManager(); try { appInfo = pm.getPackageInfoAsUser( trackers[0].getAppPackageName(), PackageManager.GET_SIGNATURES, trackers[0].mUserId); } catch (PackageManager.NameNotFoundException e) { Rlog.e(TAG, "Can't get calling app package info: refusing to send SMS"); error = RESULT_ERROR_GENERIC_FAILURE; } } } if (error != RESULT_ERROR_NONE) { handleSmsTrackersFailure(trackers, error, 0 ); return; } if (checkDestination(trackers)) { if (!mSmsDispatchersController .getUsageMonitor() .check(appInfo.packageName, trackers.length)) { sendMessage(obtainMessage(EVENT_SEND_LIMIT_REACHED_CONFIRMATION, trackers)); return; } for (SmsTracker tracker : trackers) { sendSms(tracker); } } if (PhoneNumberUtils.isLocalEmergencyNumber(mContext, trackers[0].mDestAddress)) { new AsyncEmergencyContactNotifier(mContext).execute(); } }
Source:
<code>private ActivityManager.RunningAppProcessInfo getRemoteProcessInfo() { ActivityManager manager = (ActivityManager)getContext().getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> processInfoList = manager.getRunningAppProcesses(); for (ActivityManager.RunningAppProcessInfo info : processInfoList) { <START> if (info.processName.equals(getContext().getPackageName() + ":remote")) { <END> return info; } } return null; }</code><technical_language>extract ":remote" named static variable. "REMOTE_PROCESS_NAME"</technical_language>

Target:
private ActivityManager.RunningAppProcessInfo getRemoteProcessInfo() { ActivityManager manager = (ActivityManager)getContext().getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> processInfoList = manager.getRunningAppProcesses(); for (ActivityManager.RunningAppProcessInfo info : processInfoList) { if (info.processName.equals(getContext().getPackageName() + REMOTE_PROCESS_POSTFIX)) { return info; } } return null; }
Source:
<code>public static void main(String[] args) { Random rnd = new Random(); String[] eventTypes = new String[64]; <START> try (FileOutputStream fos = new FileOutputStream("/home/ematkho/nexusTrace")) { <END> for (int i = 0; i < 64; i++) { eventTypes[i] = new String("Event " + i); } for (int i = 0; i < 64; i++) { fos.write(eventTypes[i].getBytes()); if (i != 63) { fos.write(','); } else { fos.write('\n'); } } int timestamp = 500 + rnd.nextInt(500); for (int i = 0; i < 400000; i++) { timestamp = timestamp + rnd.nextInt(50) + 1; int data = rnd.nextInt(); fos.write(intToByteArray(timestamp)); fos.write(intToByteArray(data)); if (i % 10000 == 0 && i != 0) { System.out.print('.'); } } } catch (IOException e) { e.printStackTrace(); } }</code><technical_language>get user.home directory properties instead</technical_language>

Target:
public static void main(String[] args) { Random rnd = new Random(); String[] eventTypes = new String[64]; final String fileLoc = System.getProperty("user.home") + File.separator + "nexusTrace"; try (FileOutputStream fos = new FileOutputStream(fileLoc)) { for (int i = 0; i < 64; i++) { eventTypes[i] = new String("Event " + i); } for (int i = 0; i < 64; i++) { fos.write(eventTypes[i].getBytes()); if (i != 63) { fos.write(','); } else { fos.write('\n'); } } int timestamp = 500 + rnd.nextInt(500); for (int i = 0; i < 400000; i++) { timestamp = timestamp + rnd.nextInt(50) + 1; int data = rnd.nextInt(); fos.write(intToByteArray(timestamp)); fos.write(intToByteArray(data)); if (i % 10000 == 0 && i != 0) { System.out.print('.'); } } System.out.print('\n'); System.out.println("Trace written to : " + fileLoc); } catch (IOException e) { e.printStackTrace(); } }
Source:
<code>private String parseExpectedSessionId(Object data) { if (data == null) { return null; } ZNRecord record; try { <START> record = (ZNRecord) data; <END> } catch (ClassCastException e) { LOG.debug("Failed to parse expected session id!", e); return null; } if (record.getSimpleField(MSG_ID_ATTRIBUTE) != null) { return record.getSimpleField(MSG_SRC_SESSION_ID_ATTRIBUTE); } return null; }</code><technical_language>"data instanceof Message" simpler here</technical_language>

Target:
private String parseExpectedSessionId(Object data) { if (!(data instanceof SessionAwareZNRecord)) { return null; } return ((SessionAwareZNRecord) data).getExpectedSessionId(); }
Source:
<code>public FactoryDto createFactory(@NotNull final Map<String, String> factoryParameters) throws BadRequestException, ServerException { String devfileLocation = factoryParameters.get(URL_PARAMETER_NAME); FileContentProvider contentProvider = <START> devfileLocation == null <END> ? new FetchNotSupportedProvider(LOCAL_FILES_REFERENCES_ARE_NOT_SUPPORTED) : new URLFileContentProvider(URI.create(devfileLocation), urlFetcher); return urlFactoryBuilder .createFactoryFromDevfile(devfileLocation, contentProvider) .orElse(null); }</code><technical_language>null ? I mean, if is null, is reason construct providers</technical_language>

Target:
public FactoryDto createFactory(@NotNull final Map<String, String> factoryParameters) throws BadRequestException, ServerException { String devfileLocation = factoryParameters.get(URL_PARAMETER_NAME); return urlFactoryBuilder .createFactoryFromDevfile( devfileLocation, new URLFileContentProvider(URI.create(devfileLocation), urlFetcher)) .orElse(null); }
Source:
<code>public Object getDescriptor() { final List<Tad> elements = CollectionUtil.newArrayList(); final Tad sensorName = new Tad(); sensorName.setName(SENSOR_NAME); sensorName.setId(SENSOR_NAME); sensorName.setDescription(SENSOR_NAME); sensorName.setType(Tscalar.STRING); sensorName.setRequired(true); sensorName.setDefault("TEMPERATURE"); addOptions(sensorName, SensorName.values()); <START> final Tad XdkAddress = new Tad(); <END> XdkAddress.setName(XDK_ADDRESS); XdkAddress.setId(XDK_ADDRESS); XdkAddress.setDescription(XDK_ADDRESS); XdkAddress.setType(Tscalar.STRING); XdkAddress.setRequired(true); XdkAddress.setDefault("AA:BB:CC:DD:EE:FF"); elements.add(XdkAddress); elements.add(sensorName); return elements; }</code><technical_language>XdkAddress xdkAddress</technical_language>

Target:
public Object getDescriptor() { final List<Tad> elements = CollectionUtil.newArrayList(); final Tad sensorName = new Tad(); sensorName.setName(SENSOR_NAME); sensorName.setId(SENSOR_NAME); sensorName.setDescription(SENSOR_NAME); sensorName.setType(Tscalar.STRING); sensorName.setRequired(true); sensorName.setDefault("TEMPERATURE"); addOptions(sensorName, SensorName.values()); final Tad xdkAddress = new Tad(); xdkAddress.setName(XDK_ADDRESS); xdkAddress.setId(XDK_ADDRESS); xdkAddress.setDescription(XDK_ADDRESS); xdkAddress.setType(Tscalar.STRING); xdkAddress.setRequired(true); xdkAddress.setDefault("AA:BB:CC:DD:EE:FF"); elements.add(xdkAddress); elements.add(sensorName); return elements; }
Source:
<code>public void authoriseCharge() { addGatewayAccount(ImmutableMap.of("stripe_account_id", STRIPE_ACCOUNT_ID)); String externalChargeId = addCharge(); given().port(testContext.getPort()) .contentType(JSON) .body(validAuthorisationDetails) .post(authoriseChargeUrlFor(externalChargeId)) .then() .body("status", Matchers.is(AUTHORISATION_SUCCESS.toString())) .statusCode(200); verify(postRequestedFor(urlEqualTo("/v1/tokens")) .withHeader("Content-Type", equalTo(APPLICATION_FORM_URLENCODED)) .withRequestBody(matching(constructExpectedRequestBody()))); verify(postRequestedFor(urlEqualTo("/v1/charges")) <START> .withHeader("Content-Type", equalTo(APPLICATION_JSON))); <END> List<LoggedRequest> requests = findAll(postRequestedFor(urlMatching("/v1/charges"))); assertThat(requests).hasSize(1); assertThat(requests.get(0).getBodyAsString()).isEqualTo(stripeAuthoriseJsonPayload()); }</code><technical_language>above, Content-Type APPLICATION_FORM_URLENCODED</technical_language>

Target:
public void authoriseCharge() { addGatewayAccount(ImmutableMap.of("stripe_account_id", STRIPE_ACCOUNT_ID)); String externalChargeId = addCharge(); given().port(testContext.getPort()) .contentType(JSON) .body(validAuthorisationDetails) .post(authoriseChargeUrlFor(externalChargeId)) .then() .body("status", Matchers.is(AUTHORISATION_SUCCESS.toString())) .statusCode(200); verify(postRequestedFor(urlEqualTo("/v1/tokens")) .withHeader("Content-Type", equalTo(APPLICATION_FORM_URLENCODED)) .withRequestBody(matching(constructExpectedRequestBody()))); verify(postRequestedFor(urlEqualTo("/v1/charges")) .withHeader("Content-Type", equalTo(APPLICATION_FORM_URLENCODED))); List<LoggedRequest> requests = findAll(postRequestedFor(urlMatching("/v1/charges"))); assertThat(requests).hasSize(1); assertThat(requests.get(0).getBodyAsString()).isEqualTo(stripeAuthoriseJsonPayload()); }
Source:
<code>public void testManualNullMetadataBasedRule() throws InterruptedException { RetentionRule testRule = createManualMetadataBasedRuleMillis("dc:expired", 500L); Calendar haldSecond = Calendar.getInstance(); <START> haldSecond.add(Calendar.MILLISECOND, -1000); <END> file = session.saveDocument(file); file = service.attachRule(file, testRule, session); assertTrue(file.isRecord()); assertFalse(session.isUnderRetentionOrLegalHold(file.getRef())); }</code><technical_language>createManualMetadataBasedRuleMillis("dc:expired", 500L); -> reateManualMetadataBasedRuleMillis("dc:expired", 500); .... -1000); -> -1_000);</technical_language>

Target:
public void testManualNullMetadataBasedRule() { RetentionRule testRule = createManualMetadataBasedRuleMillis("dc:expired", 500); Calendar minusOneSecond = Calendar.getInstance(); minusOneSecond.add(Calendar.MILLISECOND, -1000); file = session.saveDocument(file); file = service.attachRule(file, testRule, session); assertTrue(file.isRecord()); assertFalse(session.isUnderRetentionOrLegalHold(file.getRef())); }
Source:
<code>public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op, SubmissionStepConfig stepConf) throws Exception { if (op.getPath().endsWith(LICENSE_STEP_OPERATION_ENTRY)) { PatchOperation<String> patchOperation = new PatchOperationFactory() .instanceOf(LICENSE_STEP_OPERATION_ENTRY, op.getOp()); patchOperation.perform(context, currentRequest, source, op); } else { <START> throw new UnprocessableEntityException("This path : " + op.getPath() + " can not to be replaced"); <END> } }</code><technical_language>If I understand correctly, I this "The path" + op.getPath() + " patched"</technical_language>

Target:
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op, SubmissionStepConfig stepConf) throws Exception { if (op.getPath().endsWith(LICENSE_STEP_OPERATION_ENTRY)) { PatchOperation<String> patchOperation = new PatchOperationFactory() .instanceOf(LICENSE_STEP_OPERATION_ENTRY, op.getOp()); patchOperation.perform(context, currentRequest, source, op); } else { throw new UnprocessableEntityException("The path " + op.getPath() + " cannot be patched"); } }
Source:
<code>public DruidStatement( final String connectionId, final int statementId, final Map<String, Object> queryContext, final Runnable onClose ) { this.connectionId = Preconditions.checkNotNull(connectionId, "connectionId"); this.statementId = statementId; this.queryContext = queryContext == null ? ImmutableMap.of() : queryContext; this.onClose = Preconditions.checkNotNull(onClose, "onClose"); <START> this.yielderOpenCloseExecutor = Executors.newSingleThreadExecutor(); <END> }</code><technical_language>Give this a name, Execs.singleThreaded(name) (a) naming simpler, (b) thread is a daemon thread</technical_language>

Target:
public DruidStatement( final String connectionId, final int statementId, final Map<String, Object> queryContext, final Runnable onClose ) { this.connectionId = Preconditions.checkNotNull(connectionId, "connectionId"); this.statementId = statementId; this.queryContext = queryContext == null ? ImmutableMap.of() : queryContext; this.onClose = Preconditions.checkNotNull(onClose, "onClose"); this.yielderOpenCloseExecutor = Execs.singleThreaded( String.format("JDBCYielderOpenCloseExecutor-connection-%s-statement-%d", connectionId, statementId) ); }
Source:
<code>public feign.Response execute(Request request, Request.Options _options) throws IOException { com.palantir.dialogue.Request.Builder builder = com.palantir.dialogue.Request.builder().body(requestBody(request)); request.headers().forEach((headerName, values) -> { if (includeRequestHeader(headerName)) { builder.putAllHeaderParams(headerName, values); } }); try { Response response = clients.block(clients.call( channel, new FeignRequestEndpoint(request), builder.build(), IdentityDeserializer.INSTANCE)); return feign.Response.create( response.code(), null, <START> Multimaps.asMap((Multimap<String, String>) response.headers()), <END> new DialogueResponseBody(response)); } catch (UncheckedExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof IOException) { throw (IOException) cause; } throw e; } }</code><technical_language>casting here? do response.headers().asMap()</technical_language>

Target:
public feign.Response execute(Request request, Request.Options _options) throws IOException { com.palantir.dialogue.Request.Builder builder = com.palantir.dialogue.Request.builder().body(requestBody(request)); request.headers().forEach((headerName, values) -> { if (includeRequestHeader(headerName)) { builder.putAllHeaderParams(headerName, values); } }); try { return runtime.clients() .block(runtime.clients() .call( channel, new FeignRequestEndpoint(request), builder.build(), FeignResponseDeserializer.INSTANCE)); } catch (UncheckedExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof IOException) { throw (IOException) cause; } throw e; } }
Source:
<code>public void reasonPhraseIsOptional() { Response response = Response.builder() .status(200) .reason(null) <START> .headers(Collections.<String, Collection<String>>emptyMap()) <END> .body(new byte[0]) .build(); assertThat(response.reason()).isNull(); assertThat(response.toString()).isEqualTo("HTTP/1.1 200\n\n"); }</code><technical_language>initialize builder.headers emptyMap clear some of this c&p</technical_language>

Target:
public void reasonPhraseIsOptional() { Response response = Response.builder() .status(200) .headers(Collections.<String, Collection<String>>emptyMap()) .body(new byte[0]) .build(); assertThat(response.reason()).isNull(); assertThat(response.toString()).isEqualTo("HTTP/1.1 200\n\n"); }
Source:
<code>private List<CourseAttributes> extractArchivedCourses( List<CourseDetailsBundle> courseBundles) { ArrayList<CourseAttributes> archivedCourses = new ArrayList<CourseAttributes>(); for (CourseDetailsBundle courseBundle : courseBundles) { CourseAttributes course = courseBundle.course; InstructorAttributes curInstructor = logic.getInstructorForGoogleId(course.id, account.googleId); boolean isCourseArchived = (curInstructor.isArchived != null)? curInstructor.isArchived : <START> course.isArchived; <END> if (isCourseArchived) { archivedCourses.add(course); } } return archivedCourses; }</code><technical_language>condition duplicated again</technical_language>

Target:
private List<CourseAttributes> extractArchivedCourses( List<CourseDetailsBundle> courseBundles) { ArrayList<CourseAttributes> archivedCourses = new ArrayList<CourseAttributes>(); for (CourseDetailsBundle courseBundle : courseBundles) { CourseAttributes course = courseBundle.course; InstructorAttributes curInstructor = logic.getInstructorForGoogleId(course.id, account.googleId); if (logic.isCourseArchived(course.id, curInstructor.googleId)) { archivedCourses.add(course); } } return archivedCourses; }
Source:
<code>public void shouldBeAuthorizedToSetLegalHold() throws LoginException { ACP acp = new ACPImpl(); ACE allowLegalHold = new ACE("user", RetentionConstants.MANAGE_LEGAL_HOLD_PERMISSION, true); ACL acl = new ACLImpl(); acl.setACEs(new ACE[] { allowLegalHold }); acp.addACL(acl); file.setACP(acp, true); file = session.saveDocument(file); try (CloseableCoreSession userSession = CoreInstance.openCoreSession(session.getRepositoryName(), "user")) { userSession.makeRecord(file.getRef()); userSession.setLegalHold(file.getRef(), true, null); <START> } <END> }</code><technical_language>throw LoginException is needed tests methods</technical_language>

Target:
public void shouldBeAuthorizedToSetLegalHold() { ACP acp = new ACPImpl(); ACE allowLegalHold = new ACE("user", RetentionConstants.MANAGE_LEGAL_HOLD_PERMISSION, true); ACL acl = new ACLImpl(); acl.setACEs(new ACE[] { allowLegalHold }); acp.addACL(acl); file.setACP(acp, true); file = session.saveDocument(file); try (CloseableCoreSession userSession = CoreInstance.openCoreSession(session.getRepositoryName(), "user")) { userSession.makeRecord(file.getRef()); userSession.setLegalHold(file.getRef(), true, null); } }
Source:
<code>public IssueChangeNotification setProject(ComponentDto project) { <START> return setProject(project.getKey(), project.longName(), project.getBranch(), project.getRootUuid()); <END> }</code><technical_language>![MINOR](<LINK_2> 'Severity: MINOR') Remove this of "getRootUuid"; is deprecated. [![rule](<LINK_1>](<LINK_0></technical_language>

Target:
public IssueChangeNotification setProject(ComponentDto project) { return setProject(project.getKey(), project.name(), project.getBranch(), project.uuid()); }
Source:
<code>private List<String> toPartitionValues(Page partitionColumns, int position) { ImmutableList.Builder<String> partitionValues = ImmutableList.builder(); for (int field = 0; field < partitionColumns.getChannelCount(); field++) { Object value = getField(partitionColumnTypes.get(field), partitionColumns.getBlock(field), position); if (value == null) { partitionValues.add(HIVE_DEFAULT_DYNAMIC_PARTITION); } else { String valueString = value.toString(); if (!CharMatcher.inRange((char) 0x20, (char) 0x7E).matchesAllOf(valueString)) { <START> throw new PrestoException(HIVE_INVALID_PARTITION_VALUE, "\"" + valueString + "\" contains characters not in the range of 0x20 - 0x7E"); <END> } partitionValues.add(valueString); } } return partitionValues.build(); }</code><technical_language>Error message need mention partition key Hive. Users generally error code. is important error message provides user enough information</technical_language>

Target:
private List<String> toPartitionValues(Page partitionColumns, int position) { ImmutableList.Builder<String> partitionValues = ImmutableList.builder(); for (int field = 0; field < partitionColumns.getChannelCount(); field++) { Object value = getField(partitionColumnTypes.get(field), partitionColumns.getBlock(field), position); if (value == null) { partitionValues.add(HIVE_DEFAULT_DYNAMIC_PARTITION); } else { String valueString = value.toString(); if (!CharMatcher.inRange((char) 0x20, (char) 0x7E).matchesAllOf(valueString)) { throw new PrestoException( HIVE_INVALID_PARTITION_VALUE, format("Cannot use %s as value of a partition column in Hive. Partition keys in Hive can only contain characters in the range of 0x20 - 0x7E.", valueString)); } partitionValues.add(valueString); } } return partitionValues.build(); }
Source:
<code>public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) { checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName()); SortNode sortNode = (SortNode) node; <START> for (int i = 0; i < orderBy.size(); ++i) { <END> Ordering ordering = orderBy.get(i); Symbol symbol = Symbol.from(symbolAliases.get(ordering.getField())); OrderingScheme orderingScheme = sortNode.getOrderingScheme(); if (!symbol.equals(orderingScheme.getOrderBy().get(i))) { return NO_MATCH; } if (!ordering.getSortOrder().equals(orderingScheme.getOrdering(symbol))) { return NO_MATCH; } } return MatchResult.match(); }</code><technical_language>I merge this commit previous some abstraction for this check instead of simple copying code</technical_language>

Target:
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) { checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName()); SortNode sortNode = (SortNode) node; if (!orderingSchemeMatches(orderBy, sortNode.getOrderingScheme(), symbolAliases)) { return NO_MATCH; } return MatchResult.match(); }
Source:
<code>public void serialize(T record, DataOutputView target) throws IOException { SimpleVersionedSerializer<T> serializer = getSerializer(); <START> target.writeInt(serializer.getVersion()); <END> byte[] serializedRecord = serializer.serialize(record); target.writeInt(serializedRecord.length); target.write(serializedRecord); }</code><technical_language>Do need write version of serializer? If I mistaken for network transfer work a single version of serializer</technical_language>

Target:
public void serialize(T record, DataOutputView target) throws IOException { SimpleVersionedSerializer<T> serializer = getSerializer(); SimpleVersionedSerialization.writeVersionAndSerialize(serializer, record, target); }
Source:
<code>private void assertSchema(ParquetMetadata parquetMetadata) { List<Type> fields = parquetMetadata.getFileMetaData().getSchema().getFields(); assertEquals(2, fields.size()); Type stringField = fields.get(0); <START> assertEquals("s", stringField.getName()); <END> assertEquals(PrimitiveType.PrimitiveTypeName.BINARY, stringField.asPrimitiveType().getPrimitiveTypeName()); assertEquals(OriginalType.UTF8, stringField.getOriginalType()); Type binaryField = fields.get(1); assertEquals("b", binaryField.getName()); assertEquals(PrimitiveType.PrimitiveTypeName.BINARY, binaryField.asPrimitiveType().getPrimitiveTypeName()); assertNull(binaryField.getOriginalType()); }</code><technical_language>add ID this type instead of verifying field individually</technical_language>

Target:
private void assertSchema(ParquetMetadata parquetMetadata) { List<Type> fields = parquetMetadata.getFileMetaData().getSchema().getFields(); assertEquals(2, fields.size()); assertEquals(Types.required(PrimitiveType.PrimitiveTypeName.BINARY).id(1).named("s"), fields.get(0)); assertEquals(OriginalType.UTF8, fields.get(0).getOriginalType()); assertEquals(Types.required(PrimitiveType.PrimitiveTypeName.BINARY).id(2).named("b"), fields.get(1)); assertNull(fields.get(1).getOriginalType()); }
Source:
<code>public void setUp() { MockitoAnnotations.initMocks(this); FakeFeatureFactory.setupForTest(mContext); mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext); mFragment = spy(new TestFragment()); <START> mFragment.onAttach(ShadowApplication.getInstance().getApplicationContext()); <END> doReturn(mActivity).when(mFragment).getActivity(); Resources res = application.getResources(); theme = res.newTheme(); doReturn(res).when(mFragment).getResources(); when(mFragment.getActivity().getTheme()).thenReturn(theme); when(mFragment.getActivity().getIntent()).thenReturn(intent); when(mFragment.getActivity().getResources()).thenReturn(res); when(mFragment.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager); }</code><technical_language>application instead. 3 context (mock mContext, context ShadowApplication, context RuntimeEnvironment. Please try consolidate</technical_language>

Target:
public void setUp() { MockitoAnnotations.initMocks(this); mFragment = spy(new TestFragment()); mFragment.onAttach(application); doReturn(mActivity).when(mFragment).getActivity(); Resources res = application.getResources(); doReturn(res).when(mFragment).getResources(); when(mActivity.getTheme()).thenReturn(res.newTheme()); when(mActivity.getIntent()).thenReturn(mIntent); when(mActivity.getResources()).thenReturn(res); when(mFragment.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager); }
Source:
<code>public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html; charset=utf-8"); response.setStatus(HttpServletResponse.SC_OK); <START> PrintWriter writer = response.getWriter(); <END> if (CurrentSimulator.isRunning() == true) writer.println(RaoRuntime.getCurrentTime()); else writer.println("Модель не запущена"); baseRequest.setHandled(true); }</code><technical_language>IWriter writer = response.getWriter();</technical_language>

Target:
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("application/json; charset=utf-8"); response.setStatus(HttpServletResponse.SC_OK); JsonObject result = new JsonObject(); PrintWriter writer = response.getWriter(); if (CurrentSimulator.isRunning() == true) { result.addProperty("currentTime", RaoRuntime.getCurrentTime()); writer.println(result); } else { result.addProperty("modelState", "Модель не запущена"); writer.println(result); } baseRequest.setHandled(true); }
Source:
<code>public static ImmutableMap<Long, String> getBlobChecksumMap(final Headers headers) { if (headers.keys() == null) { return ImmutableMap.of(); } final ImmutableMap.Builder<Long, String> builder = ImmutableMap.builder(); <START> for (final String key : headers.keys()) { <END> if (key.startsWith(BLOB_CHECKSUM_HEADER)) { builder.put(getOffsetFromHeaderKey(key), getBlobChecksumValue(key, headers)); } } return builder.build(); }</code><technical_language>update this to: java headers.keys() .stream() .filter(key -> key.startsWith(BLOB_CHECKSUM_HEADER)) .foreach(key -> builder.put(getOffsetFromHeaderKey(key), getBlobChecksumValue(key, headers)));</technical_language>

Target:
public static ImmutableMap<Long, String> getBlobChecksumMap(final Headers headers) { if (headers.keys() == null) { return ImmutableMap.of(); } final ImmutableMap.Builder<Long, String> builder = ImmutableMap.builder(); headers.keys().stream() .filter(key -> key.startsWith(BLOB_CHECKSUM_HEADER)) .forEach(key -> builder.put(getOffsetFromHeaderKey(key), getBlobChecksumValue(key, headers))); return builder.build(); }
Source:
<code>public static void main(String[] args) throws Exception { <START> SpringApplication.run(ZipkinStreamServerApplication.class, "--debug"); <END> }</code><technical_language>careful</technical_language>

Target:
public static void main(String[] args) throws Exception { SpringApplication.run(ZipkinStreamServerApplication.class, args); }
Source:
<code>public static void markLastJobAsFailed(JobRepository jobRepository, String jobName, JobParameters jobParameters) throws NoPreviousJobExecution { JobExecution lastJobExecution = jobRepository.getLastJobExecution(jobName, jobParameters); if (lastJobExecution == null) { <START> throw new NoPreviousJobExecution(jobName, jobParameters); <END> } Date currentTime = new Date(); lastJobExecution.setEndTime(currentTime); lastJobExecution.setStatus(BatchStatus.FAILED); lastJobExecution.setExitStatus( lastJobExecution.getExitStatus().replaceExitCode("FAILED").addExitDescription("Manually " + "failed job") ); jobRepository.update(lastJobExecution); for (StepExecution stepExecution : lastJobExecution.getStepExecutions()) { stepExecution.setEndTime(currentTime); stepExecution.setStatus(BatchStatus.FAILED); stepExecution.setExitStatus(lastJobExecution.getExitStatus().replaceExitCode("FAILED")); jobRepository.update(stepExecution); } }</code><technical_language>need throw exception? log a warning? potential errors slip</technical_language>

Target:
public static void markLastJobAsFailed(JobRepository jobRepository, String jobName, JobParameters jobParameters) throws NoPreviousJobExecutionException { JobExecution lastJobExecution = jobRepository.getLastJobExecution(jobName, jobParameters); if (lastJobExecution == null) { throw new NoPreviousJobExecutionException(jobName, jobParameters); } Date currentTime = new Date(); lastJobExecution.setEndTime(currentTime); lastJobExecution.setStatus(BatchStatus.FAILED); lastJobExecution.setExitStatus( lastJobExecution.getExitStatus().replaceExitCode("FAILED").addExitDescription("Manually " + "failed job") ); jobRepository.update(lastJobExecution); for (StepExecution stepExecution : lastJobExecution.getStepExecutions()) { stepExecution.setEndTime(currentTime); stepExecution.setStatus(BatchStatus.FAILED); stepExecution.setExitStatus(lastJobExecution.getExitStatus().replaceExitCode("FAILED")); jobRepository.update(stepExecution); } }
Source:
<code>public int read(byte[] b, int off, int len) throws IOException { byte[] contiguousRange = null; long rangeStart = -1L; long absoluteOffset = streamPos + off; for (Map.Entry<Long, byte[]> entry : data.entrySet()) { long start = entry.getKey(); long end = entry.getKey() + entry.getValue().length; if (absoluteOffset >= start && absoluteOffset < end) { contiguousRange = entry.getValue(); rangeStart = entry.getKey(); } } if (contiguousRange == null || rangeStart == -1L) { <START> streamPos += len; <END> return len; } int relativeStreamPos = (int)(streamPos - rangeStart) + off; for (int i = 0; i < len; i++) { try { b[i] = contiguousRange[relativeStreamPos + i]; } catch (Exception e) { LOGGER.severe("Error copying bytes. requested offset: " + off + " - requested length: " + len + " - relativeStreamPos: " + relativeStreamPos + " - streamPos: " + streamPos); } } streamPos += len; return len; }</code><technical_language>If happen, throw exception here</technical_language>

Target:
public int read(byte[] b, int off, int len) throws IOException { byte[] contiguousRange = null; long rangeStart = -1L; long absoluteOffset = streamPos + off; for (Map.Entry<Long, byte[]> entry : data.entrySet()) { long start = entry.getKey(); long end = entry.getKey() + entry.getValue().length; if (absoluteOffset >= start && absoluteOffset < end) { contiguousRange = entry.getValue(); rangeStart = entry.getKey(); } } if (contiguousRange == null || rangeStart == -1L) { LOGGER.severe("The requested offset is not present in the available data. Requested offset: " + off + " - requested length: " + len + " - streamPos: " + streamPos); throw new IOException("No COG data available for the requested byte location."); } int relativeStreamPos = (int)(streamPos - rangeStart) + off; System.arraycopy(contiguousRange, relativeStreamPos, b, 0, len); streamPos += len; return len; }
Source:
<code><START> public void testGetNameSpaceArray() throws JsonProcessingException { <END> String json = "[\"key\", \"value\", \"MetricGroupType.key\", \"MetricGroupType.value\"]"; MetricKey key = MetricKey.create("step", MetricName.named(json, "name")); assertThat(FlinkMetricContainer.getNameSpaceArray(key), is(DEFAULT_SCOPE_COMPONENTS)); }</code><technical_language>throws removed</technical_language>

Target:
public void testGetNameSpaceArray() { String json = "[\"key\", \"value\", \"MetricGroupType.key\", \"MetricGroupType.value\"]"; MetricKey key = MetricKey.create("step", MetricName.named(json, "name")); assertThat(FlinkMetricContainer.getNameSpaceArray(key), is(DEFAULT_SCOPE_COMPONENTS)); }