auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void writeDictionary() throws IOException { Collection<MetricsDictionary.Word> words = dictionary.words(); dictionaryDos.writeInt(words.size()); String lastWord = ""; for (MetricsDictionary.Word word : words) { String wordText = word.word(); if (wordText.length() > UNSIGNED_BYTE_MAX_VALUE) { throw new RuntimeException("Dictionary element too long: " + wordText); } int maxCommonLen = Math.min(lastWord.length(), wordText.length()) & UNSIGNED_BYTE_MAX_VALUE; int commonLen = 0; while (commonLen < maxCommonLen && wordText.charAt(commonLen) == lastWord.charAt(commonLen)) { commonLen++; } int diffLen = wordText.length() - commonLen; <START> dictionaryDos.writeInt(word.dictionaryId()); <END> dictionaryDos.writeByte(commonLen); dictionaryDos.writeByte(diffLen); for (int i = commonLen; i < wordText.length(); i++) { dictionaryDos.writeChar(wordText.charAt(i)); } lastWord = wordText; } }</code><technical_language>I writing tmpDos copy backing buffer dictionaryDos end. reason for introducing tmpDos avoid allocating single-byte byte[] instances DeflaterOutputStream for writing (most of the) primitives. DeflaterOutputStream#write(int)</technical_language>

Target:
private void writeDictionary() throws IOException { Collection<MetricsDictionary.Word> words = dictionary.words(); dictionaryDos.writeInt(words.size()); String lastWord = ""; for (MetricsDictionary.Word word : words) { tmpBaos.reset(); String wordText = word.word(); if (wordText.length() > UNSIGNED_BYTE_MAX_VALUE) { throw new RuntimeException("Dictionary element too long: " + wordText); } int maxCommonLen = Math.min(lastWord.length(), wordText.length()); int commonLen = 0; while (commonLen < maxCommonLen && wordText.charAt(commonLen) == lastWord.charAt(commonLen)) { commonLen++; } int diffLen = wordText.length() - commonLen; tmpDos.writeInt(word.dictionaryId()); tmpDos.writeByte(commonLen); tmpDos.writeByte(diffLen); for (int i = commonLen; i < wordText.length(); i++) { tmpDos.writeChar(wordText.charAt(i)); } lastWord = wordText; dictionaryDos.write(tmpBaos.internalBuffer(), 0, tmpBaos.size()); } }
Source:
<code>WorkbenchSiteProgressService getSiteProgressService() { <START> return (WorkbenchSiteProgressService) e4Context.get(IWorkbenchSiteProgressService.class); <END> }</code><technical_language>I this cast removed</technical_language>

Target:
IWorkbenchSiteProgressService getSiteProgressService() { return e4Context.get(IWorkbenchSiteProgressService.class); }
Source:
<code>protected void appendCgroupsCmds(StringBuilder cmdLine) { if (myriadConfiguration.getFrameworkSuperUser().isPresent() && myriadConfiguration.isCgroupEnabled()) { cmdLine.append(" export TASK_DIR=`basename $PWD`&&"); appendSudo(cmdLine); cmdLine.append("chown " + myriadConfiguration.getFrameworkUser().get() + " "); cmdLine.append(myriadConfiguration.getCGroupPath()); cmdLine.append("/cpu/mesos/$TASK_DIR &&"); cmdLine.append(String.format("export %s=%s -D%s=%s", ENV_YARN_NODEMANAGER_OPTS, ENV_YARN_NODEMANAGER_OPTS, KEY_YARN_NM_LCE_CGROUPS_HIERARCHY, "mesos/$TASK_DIR")); } else if (myriadConfiguration.isCgroupEnabled()) { <START> LOGGER.info("frameworkSuperUser not set ignoring cgroup configuration, this will likely can the nodemanager to crash"); <END> } }</code><technical_language>If is highly likely/definite NodeManager crash, I recommend setting a guard condition/exception handling configuration step</technical_language>

Target:
protected void appendCgroupsCmds(StringBuilder cmdLine) { if (myriadConfiguration.getFrameworkSuperUser().isPresent() && myriadConfiguration.isCgroupEnabled()) { cmdLine.append(" export TASK_DIR=`cat /proc/self/cgroup | grep :cpu: | cut -d: -f3` &&"); appendSudo(cmdLine); cmdLine.append("chown " + myriadConfiguration.getFrameworkUser().get() + " "); cmdLine.append(myriadConfiguration.getCGroupPath()); cmdLine.append("/cpu$TASK_DIR &&"); cmdLine.append(String.format("export %s=\"$%s -D%s=%s\" && ", ENV_YARN_NODEMANAGER_OPTS, ENV_YARN_NODEMANAGER_OPTS, KEY_YARN_NM_LCE_CGROUPS_HIERARCHY, "$TASK_DIR")); } else if (myriadConfiguration.isCgroupEnabled()) { LOGGER.info("frameworkSuperUser not set ignoring cgroup configuration, this will likely can the nodemanager to crash"); } }
Source:
<code>private void validateInitialCursors(final SubscriptionBase subscription, final List<EventTypePartition> allPartitions) throws WrongInitialCursorsException, RepositoryProblemException { final boolean cursorsMissing = allPartitions.stream() .anyMatch(p -> !subscription.getInitialCursors().stream().anyMatch(p::ownsCursor)); if (cursorsMissing) { throw new WrongInitialCursorsException( "initial_cursors should contain cursors for all partitions of subscription"); } final boolean hasCursorForWrongPartition = subscription.getInitialCursors().stream() .anyMatch(c -> !allPartitions.contains(new EventTypePartition(c.getEventType(), c.getPartition()))); if (hasCursorForWrongPartition) { throw new WrongInitialCursorsException( "initial_cursors should contain cursors only for partitions of this subscription"); } if (subscription.getInitialCursors().size() > allPartitions.size()) { throw new WrongInitialCursorsException( "there should be no more than 1 cursor for each partition in initial_cursors"); } try { <START> for (SubscriptionCursorWithoutToken cursor : subscription.getInitialCursors()) { <END> final NakadiCursor nakadiCursor = cursorConverter.convert(cursor); timelineService.getTopicRepository(nakadiCursor.getTimeline()).validateReadCursors( Collections.singletonList(nakadiCursor)); } } catch (final InvalidCursorException ex) { throw new WrongInitialCursorsException(ex.getMessage(), ex); } catch (final NakadiException ex) { throw new RepositoryProblemException("Topic repository problem occurred when validating cursors", ex); } }</code><technical_language>final</technical_language>

Target:
private void validateInitialCursors(final SubscriptionBase subscription, final List<EventTypePartition> allPartitions) throws WrongInitialCursorsException, RepositoryProblemException { final boolean cursorsMissing = allPartitions.stream() .anyMatch(p -> !subscription.getInitialCursors().stream().anyMatch(p::ownsCursor)); if (cursorsMissing) { throw new WrongInitialCursorsException( "initial_cursors should contain cursors for all partitions of subscription"); } final boolean hasCursorForWrongPartition = subscription.getInitialCursors().stream() .anyMatch(c -> !allPartitions.contains(new EventTypePartition(c.getEventType(), c.getPartition()))); if (hasCursorForWrongPartition) { throw new WrongInitialCursorsException( "initial_cursors should contain cursors only for partitions of this subscription"); } if (subscription.getInitialCursors().size() > allPartitions.size()) { throw new WrongInitialCursorsException( "there should be no more than 1 cursor for each partition in initial_cursors"); } try { for (final SubscriptionCursorWithoutToken cursor : subscription.getInitialCursors()) { final NakadiCursor nakadiCursor = cursorConverter.convert(cursor); timelineService.getTopicRepository(nakadiCursor.getTimeline()).validateReadCursors( Collections.singletonList(nakadiCursor)); } } catch (final InvalidCursorException ex) { throw new WrongInitialCursorsException(ex.getMessage(), ex); } catch (final NakadiException ex) { throw new RepositoryProblemException("Topic repository problem occurred when validating cursors", ex); } }
Source:
<code>public String destroy(Request req, Response res) throws IOException { String groupName = req.params("group_name"); PipelineConfigs pipelineConfigs = fetchEntityFromConfig(groupName); HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); <START> if (!pipelineConfigs.isEmpty()) { result.unprocessableEntity(String.format("Failed to delete group %s because it was not empty.", groupName)); } else { pipelineConfigsService.deleteGroup(SessionUtils.currentUsername(), pipelineConfigs, result); } <END> return renderHTTPOperationResult(result, req, res); }</code><technical_language>@kritika-singh3 @viraj2712 -- performing this config entity related validation [DeletePipelineConfigsCommand.isValid](<LINK_0> Reasons: 1. Controllers responsible for validations, call service methods. 2. This validation performed for calling pipelineConfigsService.deleteGroup method</technical_language>

Target:
public String destroy(Request req, Response res) throws IOException { PipelineConfigs pipelineConfigs = fetchEntityFromConfig(req.params("group_name")); HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); pipelineConfigsService.deleteGroup(SessionUtils.currentUsername(), pipelineConfigs, result); return renderHTTPOperationResult(result, req, res); }
Source:
<code>public ConceptName getName() { if (getNames().isEmpty()) { if (log.isDebugEnabled()) { log.debug("there are no names defined for: " + conceptId); } return null; } for (Locale currentLocale : LocaleUtility.getLocalesInOrder()) { ConceptName preferredName = getPreferredName(currentLocale); if (preferredName != null) { return preferredName; } ConceptName fullySpecifiedName = getFullySpecifiedName(currentLocale); if (fullySpecifiedName != null) { return fullySpecifiedName; } if (!StringUtils.isBlank(currentLocale.getCountry()) || !StringUtils.isBlank(currentLocale.getVariant())) { Locale broaderLocale = new Locale(currentLocale.getLanguage()); ConceptName prefNameInBroaderLoc = getPreferredName(broaderLocale); if (prefNameInBroaderLoc != null) { return prefNameInBroaderLoc; } ConceptName fullySpecNameInBroaderLoc = getFullySpecifiedName(broaderLocale); if (fullySpecNameInBroaderLoc != null) { return fullySpecNameInBroaderLoc; } } } for (ConceptName cn : getNames()) { if (cn.isFullySpecifiedName()) { return cn; } } <START> if (!getSynonyms().isEmpty()) { <END> return getSynonyms().iterator().next(); } return null; }</code><technical_language>CollectionUtils.isNotEmpty()</technical_language>

Target:
public ConceptName getName() { if (getNames().isEmpty()) { if (log.isDebugEnabled()) { log.debug("there are no names defined for: " + conceptId); } return null; } for (Locale currentLocale : LocaleUtility.getLocalesInOrder()) { ConceptName preferredName = getPreferredName(currentLocale); if (preferredName != null) { return preferredName; } ConceptName fullySpecifiedName = getFullySpecifiedName(currentLocale); if (fullySpecifiedName != null) { return fullySpecifiedName; } if (!StringUtils.isBlank(currentLocale.getCountry()) || !StringUtils.isBlank(currentLocale.getVariant())) { Locale broaderLocale = new Locale(currentLocale.getLanguage()); ConceptName prefNameInBroaderLoc = getPreferredName(broaderLocale); if (prefNameInBroaderLoc != null) { return prefNameInBroaderLoc; } ConceptName fullySpecNameInBroaderLoc = getFullySpecifiedName(broaderLocale); if (fullySpecNameInBroaderLoc != null) { return fullySpecNameInBroaderLoc; } } } for (ConceptName cn : getNames()) { if (cn.isFullySpecifiedName()) { return cn; } } if (CollectionUtils.isNotEmpty(getSynonyms())) { return getSynonyms().iterator().next(); } return null; }
Source:
<code>protected DocumentTypeSelectionDialog(final Shell parentShell, final String title, final String message) { super(parentShell, title, null, message, MessageDialog.QUESTION, new String[] { Messages.getString("DocumentTypeSelectionDialog.ok"), Messages.getString("DocumentTypeSelectionDialog.cancel") }, 0); <START> setShellStyle(SWT.RESIZE); <END> }</code><technical_language>setShellStyle(SWT.RESIZE | SWT.ON_TOP)</technical_language>

Target:
protected DocumentTypeSelectionDialog(final Shell parentShell, final String title, final String message) { super(parentShell, title, null, message, MessageDialog.QUESTION, new String[] { Messages.getString("DocumentTypeSelectionDialog.ok"), Messages.getString("DocumentTypeSelectionDialog.cancel") }, 0); setShellStyle(SWT.RESIZE | SWT.ON_TOP); }
Source:
<code>public void doLaunch(Context context, View v) { if (v == null) { <START> Toast.makeText(context, ("MSG: " + this.pojo.displayName), Toast.LENGTH_SHORT).show(); <END> } else { Toast.makeText(context, "Uh-oh something went wrong!!" + this.pojo.displayName, Toast.LENGTH_SHORT).show(); } }</code><technical_language>Please string templates instead of concatenating parts of messages +. this translatable please</technical_language>

Target:
public void doLaunch(Context context, View v) { if (v != null) { Toast.makeText(context, R.string.application_not_found, Toast.LENGTH_LONG).show(); } }
Source:
<code>public BaseListModelSuggestBox(MultiWordSuggestOracle suggestOracle) { <START> suggestBox = new SuggestBox(suggestOracle, new TextBox(), suggestionDisplay) { <END> @Override public void setText(String text) { super.setText(text); postTextSet(text); } }; suggestBox.removeStyleName("gwt-SuggestBox"); suggestBox.addSelectionHandler(new SelectionHandler<Suggestion>() { @Override public void onSelection(SelectionEvent<Suggestion> event) { ValueChangeEvent.fire(suggestBox, event.getSelectedItem().getReplacementString()); } }); }</code><technical_language>I suspect this affects display of ListModelSuggestBox. pass base class constructor, ListModelSuggestBox pass default ListModelTypeAheadListBox pass custom one</technical_language>

Target:
public BaseListModelSuggestBox(MultiWordSuggestOracle suggestOracle) { suggestBox = new SuggestBox(suggestOracle, new TextBox(), suggestionDisplay); suggestBox.removeStyleName("gwt-SuggestBox"); suggestBox.addSelectionHandler(new SelectionHandler<Suggestion>() { @Override public void onSelection(SelectionEvent<Suggestion> event) { ValueChangeEvent.fire(suggestBox, event.getSelectedItem().getReplacementString()); } }); }
Source:
<code>private List<StructuredRecord> getInputData() throws IOException { List<StructuredRecord> messagesToWrite = new ArrayList<>(); File file = new File(this.getClass().getResource("/trainData.csv").getFile()); BufferedReader bufferedInputStream = new BufferedReader(new FileReader(file)); String line; while ((line = bufferedInputStream.readLine()) != null) { String[] flightData = line.split(","); Double depdelaymins = Double.parseDouble(flightData[11]); <START> double delayed = depdelaymins > 40 ? 1.0 : 0.0; <END> messagesToWrite.add(new Flight(Integer.parseInt(flightData[0]), Integer.parseInt(flightData[1]), flightData[2], flightData[3], Integer.parseInt(flightData[4]), flightData[5], flightData[6], flightData[7], flightData[8], Integer.parseInt(flightData[9]), Double.parseDouble(flightData[10]), depdelaymins, Double.parseDouble(flightData[12]), Double.parseDouble(flightData[13]), Double.parseDouble(flightData[14]), Double.parseDouble(flightData[15]), Integer.parseInt(flightData[16]), delayed) .toStructuredRecord()); } return messagesToWrite; }</code><technical_language>camelCase variable name</technical_language>

Target:
private List<StructuredRecord> getInputData() throws IOException { List<StructuredRecord> messagesToWrite = new ArrayList<>(); File file = new File(this.getClass().getResource("/trainData.csv").getFile()); BufferedReader bufferedInputStream = new BufferedReader(new FileReader(file)); String line; while ((line = bufferedInputStream.readLine()) != null) { String[] flightData = line.split(","); Double depDelayMins = Double.parseDouble(flightData[11]); double delayed = depDelayMins > 40 ? 1.0 : 0.0; messagesToWrite.add(new Flight(Integer.parseInt(flightData[0]), Integer.parseInt(flightData[1]), Double.parseDouble(flightData[2]), flightData[3], Integer.parseInt(flightData[4]), Integer.parseInt(flightData[5]), flightData[6], Integer.parseInt(flightData[7]), flightData[8], Integer.parseInt(flightData[9]), Double.parseDouble(flightData[10]), depDelayMins, Double.parseDouble(flightData[12]), Double.parseDouble(flightData[13]), Double.parseDouble(flightData[14]), Double.parseDouble(flightData[15]), Integer.parseInt(flightData[16]), delayed) .toStructuredRecord()); } return messagesToWrite; }
Source:
<code>void runOnce() { if (transactionManager != null) { try { if (transactionManager.isTransactional() && transactionManager.hasUnresolvedSequences() && !transactionManager.hasFatalError()) { transactionManager.transitionToFatalError( new KafkaException("The client hasn't received acknowledgment for " + "some previously sent messages and can no longer retry them. It isn't safe to continue.")); } if (transactionManager.hasFatalError()) { RuntimeException lastError = transactionManager.lastError(); if (lastError != null) maybeAbortBatches(lastError); client.poll(retryBackoffMs, time.milliseconds()); return; } transactionManager.resetProducerIdIfNeeded(); if (maybeSendAndPollTransactionalRequest()) { return; <START> } <END> } catch (AuthenticationException e) { log.trace("Authentication exception while processing transactional request: {}", e); transactionManager.authenticationFailed(e); } } long currentTimeMs = time.milliseconds(); long pollTimeout = sendProducerData(currentTimeMs); client.poll(pollTimeout, currentTimeMs); }</code><technical_language>SG</technical_language>

Target:
void runOnce() { if (transactionManager != null) { try { if (transactionManager.isTransactional() && transactionManager.hasUnresolvedSequences() && !transactionManager.hasFatalError()) { transactionManager.transitionToFatalError( new KafkaException("The client hasn't received acknowledgment for " + "some previously sent messages and can no longer retry them. It isn't safe to continue.")); } if (transactionManager.hasFatalError()) { RuntimeException lastError = transactionManager.lastError(); if (lastError != null) maybeAbortBatches(lastError); client.poll(retryBackoffMs, time.milliseconds()); return; } transactionManager.resetIdempotentProducerIdIfNeeded(); if (maybeSendAndPollTransactionalRequest()) { return; } } catch (AuthenticationException e) { log.trace("Authentication exception while processing transactional request: {}", e); transactionManager.authenticationFailed(e); } } long currentTimeMs = time.milliseconds(); long pollTimeout = sendProducerData(currentTimeMs); client.poll(pollTimeout, currentTimeMs); }
Source:
<code>private static CasualtyDetails getLowLuckAaCasualties( final List<Unit> availableTargets, final AaPowerStrengthAndRolls unitPowerAndRollsMap, final DiceRoll dice, final IDelegateBridge bridge) { final LowLuckTargetGroups targetGroups = createGuaranteedLowLuckHitGroups(availableTargets, dice, unitPowerAndRollsMap); <START> if (targetGroups.guaranteedHitGroups.isEmpty()) { <END> return buildCasualtyDetails( availableTargets, findRandomTargets(availableTargets, bridge, dice.getHits())); } if (dice.getHits() >= targetGroups.guaranteedHitGroups.size()) { final List<Unit> hitTargetIndices = new ArrayList<>(); for (final List<Unit> group : targetGroups.guaranteedHitGroups) { hitTargetIndices.add(group.get(0)); } final int remainderHits = dice.getHits() - targetGroups.guaranteedHitGroups.size(); if (remainderHits > 0) { if (remainderHits == targetGroups.remainderUnits.size()) { hitTargetIndices.addAll(targetGroups.remainderUnits); } else { hitTargetIndices.addAll( findRandomTargets(targetGroups.remainderUnits, bridge, remainderHits)); } } return buildCasualtyDetails(availableTargets, hitTargetIndices); } else { final List<Unit> guaranteedHitUnits = new ArrayList<>(); for (final List<Unit> group : targetGroups.guaranteedHitGroups) { guaranteedHitUnits.add(group.get(0)); } return buildCasualtyDetails( availableTargets, findRandomTargets(guaranteedHitUnits, bridge, dice.getHits())); } }</code><technical_language>is interesting empty condition means operation create guaranteed hit groups is implies large group choose targets. guaranteedHitGroups variable is possibly double duty, non-empty means a succesful operation results, empty means a result computed split possible. As-is, implicit inference based implementation for guaranteedHitGroups empty implies. fix this potential SRP code-smell object targetGroups more expressive a method returns condition directly. EG, a suggestion: - if(targetGroups.hasGuaranteedHitGroups()) - if(targetGroups.canBeSplitIntoGuaranteedHitGroups())</technical_language>

Target:
private static Collection<Unit> getLowLuckAaCasualties( final List<Unit> availableTargets, final AaPowerStrengthAndRolls unitPowerAndRollsMap, final DiceRoll dice, final IDelegateBridge bridge) { final LowLuckTargetGroups targetGroups = new LowLuckTargetGroups(availableTargets, dice, unitPowerAndRollsMap); if (!targetGroups.hasGuaranteedGroups()) { return findRandomTargets(availableTargets, bridge, dice.getHits()); } if (dice.getHits() >= targetGroups.getGuaranteedHitGroups().size()) { final List<Unit> hitUnits = targetGroups.getGuaranteedHits(); final int remainderHits = dice.getHits() - hitUnits.size(); if (remainderHits > 0) { if (remainderHits == targetGroups.getRemainderUnits().size()) { hitUnits.addAll(targetGroups.getRemainderUnits()); } else { hitUnits.addAll( findRandomTargets(targetGroups.getRemainderUnits(), bridge, remainderHits)); } } return hitUnits; } else { return findRandomTargets(targetGroups.getGuaranteedHits(), bridge, dice.getHits()); } }
Source:
<code>protected void respond(AjaxRequestTarget target) { <START> String coordinateRaw = RequestCycle.get().getRequest().getRequestParameters() <END> .getParameterValue("coordinate").toString(); String featureId = RequestCycle.get().getRequest().getRequestParameters() .getParameterValue("id").toString(); String properties = RequestCycle.get().getRequest().getRequestParameters() .getParameterValue("properties").toString(); JsonObject propertiesJson = null; JsonElement propertiesParsed = new JsonParser().parse(properties); if (!(propertiesParsed instanceof JsonNull)) { propertiesJson = propertiesParsed.getAsJsonObject(); } String[] coordinates = coordinateRaw.split(","); Double longitude = Double.parseDouble(coordinates[0]); Double latitude = Double.parseDouble(coordinates[1]); if (!featureId.isEmpty()) { handleClick(target, featureId, new LongLat(longitude, latitude, projection), propertiesJson); } else { handleClickMiss(target, new LongLat(longitude, latitude, projection)); } }</code><technical_language>cache result of getRequestParameters</technical_language>

Target:
protected void respond(AjaxRequestTarget target) { IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters(); String coordinateRaw = params.getParameterValue("coordinate").toString(); String featureId = params.getParameterValue("id").toString(); String properties = params.getParameterValue("properties").toString(); JsonObject propertiesJson = null; JsonElement propertiesParsed = new JsonParser().parse(properties); if (!(propertiesParsed instanceof JsonNull)) { propertiesJson = propertiesParsed.getAsJsonObject(); } String[] coordinates = Strings.split(coordinateRaw, ','); Double longitude = Double.parseDouble(coordinates[0]); Double latitude = Double.parseDouble(coordinates[1]); if (!featureId.isEmpty()) { handleClick(target, featureId, new LongLat(longitude, latitude, projection), propertiesJson); } else { handleClickMiss(target, new LongLat(longitude, latitude, projection)); } }
Source:
<code>public String getDaemonDir() { String daemonDirectory = pipeConfiguration.getDaemonDir(); <START> int observersDirLength = "pipes/".length() + daemonDirectory.length() - daemonDirectory.lastIndexOf("pipe"); <END> daemonDirectory = daemonDirectory.substring(0, daemonDirectory.length() - observersDirLength); return daemonDirectory + "observers/" + name; }</code><technical_language>this assumes dir of format "/var/run/pipe/test/pipes/pipe11" , this true right ? if change directory structure</technical_language>

Target:
public File getDaemonDir() { String daemonDirectory = pipeConfiguration.getDaemonDir().getAbsolutePath(); int observersDirLength = "pipes/".length() + daemonDirectory.length() - daemonDirectory.lastIndexOf("pipe"); daemonDirectory = daemonDirectory.substring(0, daemonDirectory.length() - observersDirLength); return new File(daemonDirectory, "observers/" + name); }
Source:
<code>public static byte[] decode(char[] encoded, boolean allowSingleChar) throws IllegalArgumentException { int resultLengthBytes = (encoded.length + 1) / 2; byte[] result = new byte[resultLengthBytes]; int resultOffset = 0; int i = 0; if (allowSingleChar) { if ((encoded.length % 2) != 0) { result[resultOffset++] = (byte) toDigit(encoded, i); i++; } } else { if ((encoded.length % 2) != 0) { throw new IllegalArgumentException("Invalid input length: " + encoded.length); } } <START> for (; i < encoded.length; i += 2) { <END> result[resultOffset++] = (byte) ((toDigit(encoded, i) << 4) | toDigit(encoded, i + 1)); } return result; }</code><technical_language>previous implementation a bit strange. a more efficient extracts encoded.length a loop invariant. method duplicates expression encoded.length in places extract a common variable top of method</technical_language>

Target:
public static byte[] decode(char[] encoded, boolean allowSingleChar) throws IllegalArgumentException { int encodedLength = encoded.length; int resultLengthBytes = (encodedLength + 1) / 2; byte[] result = new byte[resultLengthBytes]; int resultOffset = 0; int i = 0; if (allowSingleChar) { if ((encodedLength % 2) != 0) { result[resultOffset++] = (byte) toDigit(encoded, i); i++; } } else { if ((encodedLength % 2) != 0) { throw new IllegalArgumentException("Invalid input length: " + encodedLength); } } for (; i < encodedLength; i += 2) { result[resultOffset++] = (byte) ((toDigit(encoded, i) << 4) | toDigit(encoded, i + 1)); } return result; }
Source:
<code>protected void parseEviction(XMLExtendedStreamReader reader, ConfigurationBuilder builder) throws XMLStreamException { log.evictionDeprecated(); for (int i = 0; i < reader.getAttributeCount(); i++) { String value = replaceProperties(reader.getAttributeValue(i)); Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case STRATEGY: { builder.eviction().strategy(EvictionStrategy.valueOf(value)); break; } case MAX_ENTRIES: { log.evictionMaxEntriesDeprecated(); long parsedLong = Long.parseLong(value); builder.eviction().size(parsedLong); builder.memory().size(parsedLong); break; } case THREAD_POLICY: { builder.eviction().threadPolicy(EvictionThreadPolicy.valueOf(value)); break; } case TYPE: { EvictionType type = EvictionType.valueOf(value); builder.eviction().type(type); builder.memory().evictionType(type); break; } case SIZE: { long size = Long.parseLong(value); <START> builder.eviction().size(size); <END> builder.memory().size(size); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); }</code><technical_language>Instead of invoking both, eviction stuff act a facade memory configuration</technical_language>

Target:
protected void parseEviction(XMLExtendedStreamReader reader, ConfigurationBuilder builder) throws XMLStreamException { log.evictionDeprecated(); for (int i = 0; i < reader.getAttributeCount(); i++) { String value = replaceProperties(reader.getAttributeValue(i)); Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case STRATEGY: { builder.eviction().strategy(EvictionStrategy.valueOf(value)); break; } case MAX_ENTRIES: { log.evictionMaxEntriesDeprecated(); builder.eviction().maxEntries(Long.parseLong(value)); break; } case THREAD_POLICY: { builder.eviction().threadPolicy(EvictionThreadPolicy.valueOf(value)); break; } case TYPE: { builder.eviction().type(EvictionType.valueOf(value)); break; } case SIZE: { builder.eviction().size(Long.parseLong(value)); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); }
Source:
<code>public VdcParametersMap put(VdcParameter param, Object value) { <START> paramsMap.put(param, (Serializable) value); <END> return this; }</code><technical_language>hmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm! validate this gwt, I do want validate core. conditional? if isAssignableFrom works perform validation else not? gwt classes more remove conditional</technical_language>

Target:
public VdcParametersMap put(VdcParameter param, Object value) { if (!isAssignableFrom(param.getJavaType(), value.getClass())) { throw new InvalidParameterValueException(param.getJavaType(), value.getClass()); } paramsMap.put(param, (Serializable) value); return this; }
Source:
<code>public static Policy getHttpPolicy(Configuration conf) { <START> String policyStr = conf.get("ozone.http.policy", OzoneConfigKeys.OZONE_HTTP_POLICY); <END> if(policyStr == null || policyStr.length() == 0) { policyStr = conf.get("dfs.http.policy", DFSConfigKeys.DFS_HTTP_POLICY_DEFAULT); } Policy policy = Policy.fromString(policyStr); if (policy == null) { throw new HadoopIllegalArgumentException("Unrecognized value '" + policyStr + "' for " + "dfs.http.policy"); } else { conf.set("dfs.http.policy", policy.name()); return policy; } }</code><technical_language>Minor NIT: ozone.http.policy -> OzoneConfigKeys.OZONE_HTTP_POLICY</technical_language>

Target:
public static Policy getHttpPolicy(Configuration conf) { String policyStr = conf.get(OzoneConfigKeys.OZONE_HTTP_POLICY, DFSConfigKeys.DFS_HTTP_POLICY_DEFAULT); Policy policy = Policy.fromString(policyStr); conf.set("dfs.http.policy", policy.name()); return policy; }
Source:
<code>public void setJsonParameters(Map<String, Object> allParameters) throws Exception { Map<String, Object> parameters = (Map<String, Object>)allParameters.get("parameters"); <START> Long bitmask = (Long) parameters.get("type"); <END> type = new ConnectionType(bitmask.intValue()); }</code><technical_language>Number instead of Long</technical_language>

Target:
public void setJsonParameters(Map<String, Object> allParameters) throws Exception { Map<String, Object> parameters = (Map<String, Object>)allParameters.get("parameters"); Number bitmask = (Number) parameters.get("type"); type = new ConnectionType(bitmask.intValue()); }
Source:
<code>private void renameStyle( StyleInfo s, String newName ) throws IOException { <START> LOGGER.fine( "Renameing style " + s.getName() + " to " + newName ); <END> Resource xml = dd.config(s); renameRes( xml, newName+".xml" ); Resource style = dd.style(s); StyleHandler format = Styles.handler( s.getFormat() ); Resource target = uniqueResource( style, newName, format.getFileExtension() ); renameRes(style, target.name()); s.setFilename(target.name()); if( !"sld".equals(format.getFormat())){ Resource sld = style.parent().get(FilenameUtils.getBaseName(style.name()) + ".sld"); if( sld.getType() == Type.RESOURCE ){ Resource generated = uniqueResource( sld, newName, "sld" ); renameRes(sld, generated.name()); } } }</code><technical_language>"Renaming style " instead of "Renameing style "</technical_language>

Target:
private void renameStyle( StyleInfo s, String newName ) throws IOException { LOGGER.fine( "Renaming style " + s.getName() + " to " + newName ); Resource xml = dd.config(s); renameRes( xml, newName+".xml" ); Resource style = dd.style(s); StyleHandler format = Styles.handler( s.getFormat() ); Resource target = uniqueResource( style, newName, format.getFileExtension() ); renameRes(style, target.name()); s.setFilename(target.name()); if( !SLDHandler.FORMAT.equals(format.getFormat())){ Resource sld = style.parent().get(FilenameUtils.getBaseName(style.name()) + ".sld"); if( sld.getType() == Type.RESOURCE ){ Resource generated = uniqueResource( sld, newName, "sld" ); renameRes(sld, generated.name()); } } }
Source:
<code>public void joinCourseForInstructor(String encryptedKey, String googleId, String institute) throws JoinCourseException, InvalidParametersException { verifyInstructorJoinCourseRequest(encryptedKey, googleId, institute); InstructorAttributes instructor = InstructorsLogic.inst().getInstructorForRegistrationKey(encryptedKey); if(!institute.isEmpty()){ AccountAttributes accountToAdd = new AccountAttributes(googleId, instructor.name, true, instructor.email, institute); createAccount(accountToAdd); <START> } <END> instructor.googleId = googleId; try { InstructorsLogic.inst().updateInstructorByEmail(instructor.email, instructor); } catch (InvalidParametersException | EntityDoesNotExistException e) { throw new JoinCourseException(e.getMessage()); } AccountAttributes account = accountsDb.getAccount(googleId); if(account == null) { try { createInstructorAccount(instructor); } catch (InvalidParametersException e) { throw new JoinCourseException(e.getMessage()); } } else { makeAccountInstructor(googleId); } }</code><technical_language>Is indentation problem here</technical_language>

Target:
public void joinCourseForInstructor(String encryptedKey, String googleId, String institute) throws JoinCourseException, InvalidParametersException{ try { joinCourseForInstructorWithInstitute(encryptedKey, googleId, institute); } catch (EntityDoesNotExistException e) { throw new JoinCourseException(e.getMessage()); } }
Source:
<code><START> FileSessionPropertyManager(FileSessionPropertyManagerConfig config) <END> { requireNonNull(config, "config is null"); Path configurationFile = Paths.get(config.getConfigFile()); try { sessionMatchSpecs = CODEC.fromJson(Files.readAllBytes(configurationFile)); } catch (IOException e) { throw new UncheckedIOException(e); } catch (IllegalArgumentException e) { Throwable cause = e.getCause(); if (cause instanceof UnrecognizedPropertyException) { UnrecognizedPropertyException ex = (UnrecognizedPropertyException) cause; String message = format("Unknown property at line %s:%s: %s", ex.getLocation().getLineNr(), ex.getLocation().getColumnNr(), ex.getPropertyName()); throw new IllegalArgumentException(message, e); } if (cause instanceof JsonMappingException) { if (cause.getCause() != null) { cause = cause.getCause(); } throw new IllegalArgumentException(cause.getMessage(), e); } throw e; } }</code><technical_language>this public class is public</technical_language>

Target:
public FileSessionPropertyManager(FileSessionPropertyManagerConfig config) { requireNonNull(config, "config is null"); Path configurationFile = config.getConfigFile().toPath(); try { sessionMatchSpecs = CODEC.fromJson(Files.readAllBytes(configurationFile)); } catch (IOException e) { throw new UncheckedIOException(e); } catch (IllegalArgumentException e) { Throwable cause = e.getCause(); if (cause instanceof UnrecognizedPropertyException) { UnrecognizedPropertyException ex = (UnrecognizedPropertyException) cause; String message = format("Unknown property at line %s:%s: %s", ex.getLocation().getLineNr(), ex.getLocation().getColumnNr(), ex.getPropertyName()); throw new IllegalArgumentException(message, e); } if (cause instanceof JsonMappingException) { if (cause.getCause() != null) { cause = cause.getCause(); } throw new IllegalArgumentException(cause.getMessage(), e); } throw e; } }
Source:
<code>static long[][] buildFrequencies(final List<CramCompressionRecord> records) { <START> final long[][] frequencies = new long[200][200]; <END> for (final CramCompressionRecord record : records) { if (record.readFeatures != null) { for (final ReadFeature readFeature : record.readFeatures) { if (readFeature.getOperator() == Substitution.operator) { final Substitution substitution = ((Substitution) readFeature); final byte refBase = substitution.getReferenceBase(); final byte base = substitution.getBase(); frequencies[refBase][base]++; } } } } return frequencies; }</code><technical_language>This array is indexed byte values - is significant 200 ?</technical_language>

Target:
static long[][] buildFrequencies(final List<CramCompressionRecord> records) { final long[][] frequencies = new long[BYTE_SPACE_SIZE][BYTE_SPACE_SIZE]; for (final CramCompressionRecord record : records) { if (record.readFeatures != null) { for (final ReadFeature readFeature : record.readFeatures) { if (readFeature.getOperator() == Substitution.operator) { final Substitution substitution = ((Substitution) readFeature); final byte refBase = substitution.getReferenceBase(); final byte base = substitution.getBase(); frequencies[refBase][base]++; } } } } return frequencies; }
Source:
<code>public RuleViolations evaluate(final RuleExtension rule, final GraphConnectionContext context) { final Graph<?, Node> graph = (Graph<?, Node>) context.getGraph(); final Optional<Node<? extends View<?>, ? extends Edge>> oSource = context.getSource(); final Optional<Node<? extends View<?>, ? extends Edge>> oTarget = context.getTarget(); final DefaultRuleViolations result = new DefaultRuleViolations(); if (!(oSource.isPresent() && oTarget.isPresent())) { return result; } final Node<? extends View<?>, ? extends Edge> source = oSource.get(); final Node<? extends View<?>, ? extends Edge> target = oTarget.get(); final Edge<? extends View<?>, ? extends Node> connector = context.getConnector(); if (isConnectionAlreadyFormed(source, target, connector)) { result.addViolation(new RuleViolationImpl(ERROR_MESSAGE)); } return result; <START> } <END></code><technical_language>hey guys, is I do some initial casts (not great code I know, review some point...), this stream functions apply seams more clear... you! protected boolean isConnectionAlreadyFormed(final Node<? extends View<? extends Definition>, ? extends Edge> source, final Node<? extends View<? extends Definition>, ? extends Edge> target, final Edge<? extends View<? extends Definition>, ? extends Node> connector) { final String connectorDefId = getDefinitionId(connector.getContent()); final List<Edge<View<? extends Definition>, Node>> outEdges = (List<Edge<View<? extends Definition>, Node>>) source.getOutEdges(); return outEdges .stream() .filter(e -> connectorDefId.equals(getDefinitionId(e.getContent()))) .map(Edge::getTargetNode) .filter(n -> n.equals(target)) .findFirst() .isPresent(); } private String getDefinitionId(final Definition definition) { return definitionManager.adapters().forDefinition().getId(definition); } private String getDefinitionId(final View view) { return definitionManager.adapters().forDefinition().getId(view.getDefinition()); }</technical_language>

Target:
public RuleViolations evaluate(final RuleExtension rule, final GraphConnectionContext context) { final Optional<Node<? extends View<?>, ? extends Edge>> oSource = context.getSource(); final Optional<Node<? extends View<?>, ? extends Edge>> oTarget = context.getTarget(); final DefaultRuleViolations result = new DefaultRuleViolations(); if (!(oSource.isPresent() && oTarget.isPresent())) { return result; } final Node<? extends View<?>, ? extends Edge> source = oSource.get(); final Node<? extends View<?>, ? extends Edge> target = oTarget.get(); final Edge<? extends View<?>, ? extends Node> connector = context.getConnector(); if (isConnectionAlreadyFormed(source, target, connector)) { result.addViolation(new RuleViolationImpl(ERROR_MESSAGE)); } return result; }
Source:
<code>public void close() throws IOException { cachedLookups.close(); <START> if(column != null) { <END> column.close(); } if(multiValueColumn != null) { multiValueColumn.close(); } }</code><technical_language>want do other closes if prior closes throw IOException</technical_language>

Target:
public void close() throws IOException { CloseQuietly.close(cachedLookups); if(column != null) { column.close(); } if(multiValueColumn != null) { multiValueColumn.close(); } }
Source:
<code>public boolean addNetworkRules(final String vmName, final String vmId, final String guestIP, final String sig, final String seq, final String mac, final String rules, final String vif, final String brname, final String secIps) { if (!_canBridgeFirewall) { return false; } final String newRules = rules.replace(" ", ";"); <START> final Script cmd = new Script(_securityGroupPath, _timeout.getMillis(), s_logger); <END> cmd.add("add_network_rules"); cmd.add("--vmname", vmName); cmd.add("--vmid", vmId); cmd.add("--vmip", guestIP); cmd.add("--sig", sig); cmd.add("--seq", seq); cmd.add("--vmmac", mac); cmd.add("--vif", vif); cmd.add("--brname", brname); cmd.add("--nicsecips", secIps); if (newRules != null && !newRules.isEmpty()) { cmd.add("--rules", newRules); } final String result = cmd.execute(); if (result != null) { return false; } return true; }</code><technical_language>Please consider adding overridden version of Script(String, int, Logger) constructor accepts Duration encapsulate this type conversion</technical_language>

Target:
public boolean addNetworkRules(final String vmName, final String vmId, final String guestIP, final String sig, final String seq, final String mac, final String rules, final String vif, final String brname, final String secIps) { if (!_canBridgeFirewall) { return false; } final String newRules = rules.replace(" ", ";"); final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("add_network_rules"); cmd.add("--vmname", vmName); cmd.add("--vmid", vmId); cmd.add("--vmip", guestIP); cmd.add("--sig", sig); cmd.add("--seq", seq); cmd.add("--vmmac", mac); cmd.add("--vif", vif); cmd.add("--brname", brname); cmd.add("--nicsecips", secIps); if (newRules != null && !newRules.isEmpty()) { cmd.add("--rules", newRules); } final String result = cmd.execute(); if (result != null) { return false; } return true; }
Source:
<code>public void afterPropertiesSet() throws Exception { List<Link> links = new ArrayList<Link>(); <START> Link l = new Link("/api", "pid"); <END> links.add(l); }</code><technical_language>this "/api/pid","pid" define a constant in Controller mapping annotation</technical_language>

Target:
public void afterPropertiesSet() throws Exception { discoverableEndpointsService .register(this, Arrays.asList( new Link( new UriTemplate("/api/" + CATEGORY + "/" + ACTION, new TemplateVariables( new TemplateVariable(PARAM, VariableType.REQUEST_PARAM))), CATEGORY))); }
Source:
<code><START> public Map<String, byte[]> getFiles() { <END> return files; }</code><technical_language>Yes. I this is api change. deprecate method</technical_language>

Target:
public Map<String, InputStream> getFiles() { Map<String, InputStream> streamMap = new HashMap<>(files.size()); for (Entry<String, byte[]> entry : files.entrySet()) { streamMap.put(entry.getKey(), new ByteArrayInputStream(entry.getValue())); } return streamMap; }
Source:
<code>protected OAuth2Client readEntity(JsonNode jn) { String name = getStringField(jn, NAME_FIELD); <START> List<String> redirectURIs = requireNonNullElse(getStringListField(jn, REDIRECT_URI_FIELD), <END> Collections.emptyList()); String clientId = getStringField(jn, "id"); String secret = getStringField(jn, "secret"); boolean autoGrant = BooleanUtils.toBoolean(getBooleanField(jn, "isAutoGrant")); boolean enabled = BooleanUtils.toBoolean(getBooleanField(jn, "isEnabled")); return new OAuth2Client(name, clientId, secret, redirectURIs, autoGrant, enabled); }</code><technical_language>requireNonNullElseGet avoid emptyList call if needed</technical_language>

Target:
protected OAuth2Client readEntity(JsonNode jn) { String name = getStringField(jn, NAME_FIELD); List<String> redirectURIs = requireNonNullElseGet(getStringListField(jn, REDIRECT_URI_FIELD), Collections::emptyList); String clientId = getStringField(jn, ID_FIELD); String secret = getStringField(jn, SECRET_FIELD); boolean autoGrant = requireNonNullElse(getBooleanField(jn, AUTO_GRANT_FIELD), false); boolean enabled = requireNonNullElse(getBooleanField(jn, ENABLED_FIELD), false); return new OAuth2Client(name, clientId, secret, redirectURIs, autoGrant, enabled); }
Source:
<code><START> public int hashCode() { <END> final int prime = 31; int result = 1; long temp; temp = Double.doubleToLongBits(numeraire); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(forward); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(volatility); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; }</code><technical_language>Regenerate</technical_language>

Target:
public int hashCode() { int hash = getClass().hashCode(); hash = hash * 31 + JodaBeanUtils.hashCode(getForward()); hash = hash * 31 + JodaBeanUtils.hashCode(getNumeraire()); hash = hash * 31 + JodaBeanUtils.hashCode(getNormalVolatility()); return hash; }
Source:
<code><START> protected void addToString(EntityType model, CodeWriter writer) { <END> }</code><technical_language>This a bit hacky me, move code bodyEnd() this overridden addToString? Is implementation default anyway? toString in bodyEnd() sophisticated. more a debugging leftover..</technical_language>

Target:
protected void addToString(EntityType model, CodeWriter writer) throws IOException { Collection<PrimaryKeyData> primaryKeys = (Collection<PrimaryKeyData>) model.getData().get(PrimaryKeyData.class); if (primaryKeys == null || primaryKeys.isEmpty()) { super.addToString(model, writer); return; } StringBuilder toString = new StringBuilder(); Map<String, Property> columnToProperty = new HashMap<String, Property>(); for (Property property : model.getProperties()) { columnToProperty.put(property.getAnnotation(Column.class).value(), property); } for (PrimaryKeyData pk : primaryKeys) { for (String column : pk.getColumns()) { Property property = columnToProperty.get(column); String propName = property.getEscapedName(); if (toString.length() > 0) { toString.append("+ \";\" + "); } else { toString.append("\"" + model.getSimpleName() + "#\" + "); } toString.append(propName); } } writer.annotation(Override.class); writer.beginPublicMethod(Types.STRING, "toString"); writer.line("return ", toString + ";"); writer.end(); }
Source:
<code>private void writeXMLDeclaration(MessageContext messageContext, OutputStream outputStream, OMOutputFormat format) { String xmlDeclaration; <START> String writeXmlDeclaration = (String) messageContext.getProperty("WRITE_XML_DECLARATION"); <END> if (writeXmlDeclaration != null && "true".equalsIgnoreCase(writeXmlDeclaration)) { String xmlDeclarationEncoding = (String) messageContext.getProperty("XML_DECLARATION_ENCODING"); if (xmlDeclarationEncoding == null) { xmlDeclarationEncoding = (format.getCharSetEncoding() != null) ? format.getCharSetEncoding() : Charset.defaultCharset().toString(); } String xmlDeclarationStandalone = (String) messageContext.getProperty("XML_DECLARATION_STANDALONE"); if (xmlDeclarationStandalone != null) { xmlDeclaration = "<?xml version=\"1.0\" encoding=\"" + xmlDeclarationEncoding + "\" " + "standalone=\"" + xmlDeclarationStandalone + "\" ?>"; } else { xmlDeclaration = "<?xml version=\"1.0\" encoding=\"" + xmlDeclarationEncoding + "\" ?>"; } try { outputStream.write(xmlDeclaration.getBytes()); } catch (IOException e) { log.error("Error while writing the XML declaration ", e); } } }</code><technical_language>introducing new constants for WRITE_XML_DECLARATION, XML_DECLARATION_ENCODING, XML_DECLARATION_STANDALONE</technical_language>

Target:
private void writeXMLDeclaration(MessageContext messageContext, OutputStream outputStream, OMOutputFormat format) { String xmlDeclaration; String writeXmlDeclaration = (String) messageContext.getProperty(WRITE_XML_DECLARATION); if (writeXmlDeclaration != null && "true".equalsIgnoreCase(writeXmlDeclaration)) { String xmlDeclarationEncoding = (String) messageContext.getProperty(XML_DECLARATION_ENCODING); if (xmlDeclarationEncoding == null) { xmlDeclarationEncoding = (format.getCharSetEncoding() != null) ? format.getCharSetEncoding() : Charset.defaultCharset().toString(); } String xmlDeclarationStandalone = (String) messageContext.getProperty(XML_DECLARATION_STANDALONE); if (xmlDeclarationStandalone != null) { xmlDeclaration = "<?xml version=\"1.0\" encoding=\"" + xmlDeclarationEncoding + "\" " + "standalone=\"" + xmlDeclarationStandalone + "\" ?>"; } else { xmlDeclaration = "<?xml version=\"1.0\" encoding=\"" + xmlDeclarationEncoding + "\" ?>"; } try { outputStream.write(xmlDeclaration.getBytes()); } catch (IOException e) { log.error("Error while writing the XML declaration ", e); } } }
Source:
<code>private void setAuthorView(Media item, TextView author) { if (item.getCreator()!="") { <START> author.setText("Uploaded by: "+item.getCreator()); <END> } else { author.setText(""); } }</code><technical_language>This is hardcoding string "Uploaded by: " translated</technical_language>

Target:
private void setAuthorView(Media item, TextView author) { if (!TextUtils.isEmpty(item.getCreator())) { author.setVisibility(View.VISIBLE); author.setText(getContext().getString(R.string.image_uploaded_by, item.getCreator())); } else { author.setVisibility(View.GONE); } }
Source:
<code>public void setOffset(int offset) { if (offset + length > buffer.length) { <START> throw new IllegalArgumentException("length"); <END> } this.offset = offset; }</code><technical_language>typo</technical_language>

Target:
public void setOffset(int offset) { if (offset + length > buffer.length || offset < 0) { throw new IllegalArgumentException("offset"); } this.offset = offset; }