auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private static Rule toRule(RuleDefinitionDto ruleDefinition, List<RuleParamDto> params) { String severity = ruleDefinition.getSeverityString(); String description = ruleDefinition.getDescription(); RuleDto.Format descriptionFormat = ruleDefinition.getDescriptionFormat(); Rule apiRule = new Rule(); apiRule .setName(ruleDefinition.getName()) .setLanguage(ruleDefinition.getLanguage()) .setKey(ruleDefinition.getRuleKey()) .setConfigKey(ruleDefinition.getConfigKey()) .setIsTemplate(ruleDefinition.isTemplate()) .setCreatedAt(new Date(ruleDefinition.getCreatedAt())) .setUpdatedAt(new Date(ruleDefinition.getUpdatedAt())) .setRepositoryKey(ruleDefinition.getRepositoryKey()) .setSeverity(severity != null ? RulePriority.valueOf(severity) : null) .setStatus(ruleDefinition.getStatus().name()) .setSystemTags(ruleDefinition.getSystemTags().toArray(new String[ruleDefinition.getSystemTags().size()])) <START> .setTags(new String[0]) <END> .setId(ruleDefinition.getId()); if (description != null && descriptionFormat != null) { if (RuleDto.Format.HTML.equals(descriptionFormat)) { apiRule.setDescription(description); } else { apiRule.setDescription(Markdown.convertToHtml(description)); } } List<org.sonar.api.rules.RuleParam> apiParams = newArrayList(); for (RuleParamDto param : params) { apiParams.add(new org.sonar.api.rules.RuleParam(apiRule, param.getName(), param.getDescription(), param.getType()) .setDefaultValue(param.getDefaultValue())); } apiRule.setParams(apiParams); return apiRule; }</code><technical_language>I this is a change of behavior. backward-compatibility referencing system tags in tags systemTags</technical_language>

Target:
private static Rule toRule(RuleDefinitionDto ruleDefinition, List<RuleParamDto> params) { String severity = ruleDefinition.getSeverityString(); String description = ruleDefinition.getDescription(); RuleDto.Format descriptionFormat = ruleDefinition.getDescriptionFormat(); Rule apiRule = new Rule(); String[] systemTags = ruleDefinition.getSystemTags().toArray(new String[ruleDefinition.getSystemTags().size()]); apiRule .setName(ruleDefinition.getName()) .setLanguage(ruleDefinition.getLanguage()) .setKey(ruleDefinition.getRuleKey()) .setConfigKey(ruleDefinition.getConfigKey()) .setIsTemplate(ruleDefinition.isTemplate()) .setCreatedAt(new Date(ruleDefinition.getCreatedAt())) .setUpdatedAt(new Date(ruleDefinition.getUpdatedAt())) .setRepositoryKey(ruleDefinition.getRepositoryKey()) .setSeverity(severity != null ? RulePriority.valueOf(severity) : null) .setStatus(ruleDefinition.getStatus().name()) .setSystemTags(systemTags) .setTags(systemTags) .setId(ruleDefinition.getId()); if (description != null && descriptionFormat != null) { if (RuleDto.Format.HTML.equals(descriptionFormat)) { apiRule.setDescription(description); } else { apiRule.setDescription(Markdown.convertToHtml(description)); } } List<org.sonar.api.rules.RuleParam> apiParams = newArrayList(); for (RuleParamDto param : params) { apiParams.add(new org.sonar.api.rules.RuleParam(apiRule, param.getName(), param.getDescription(), param.getType()) .setDefaultValue(param.getDefaultValue())); } apiRule.setParams(apiParams); return apiRule; }
Source:
<code>public void testCompressedFrame() { EmbeddedChannel encoderChannel = new EmbeddedChannel( ZlibCodecFactory.newZlibEncoder(ZlibWrapper.NONE, 9, 15, 8)); EmbeddedChannel decoderChannel = new EmbeddedChannel(new PerMessageDeflateDecoder(false, NEVER_SKIP)); byte[] payload = new byte[300]; random.nextBytes(payload); encoderChannel.writeOutbound(Unpooled.wrappedBuffer(payload)); ByteBuf compressedPayload = encoderChannel.readOutbound(); BinaryWebSocketFrame compressedFrame = new BinaryWebSocketFrame(true, WebSocketExtension.RSV1 | WebSocketExtension.RSV3, compressedPayload.slice(0, compressedPayload.readableBytes() - 4)); decoderChannel.writeInbound(compressedFrame); <START> BinaryWebSocketFrame uncompressedFrame = decoderChannel.readInbound(); <END> assertNotNull(uncompressedFrame); assertNotNull(uncompressedFrame.content()); assertEquals(WebSocketExtension.RSV3, uncompressedFrame.rsv()); assertEquals(300, uncompressedFrame.content().readableBytes()); byte[] finalPayload = new byte[300]; uncompressedFrame.content().readBytes(finalPayload); assertArrayEquals(finalPayload, payload); uncompressedFrame.release(); }</code><technical_language>this removed</technical_language>

Target:
public void testCompressedFrame() { EmbeddedChannel encoderChannel = new EmbeddedChannel( ZlibCodecFactory.newZlibEncoder(ZlibWrapper.NONE, 9, 15, 8)); EmbeddedChannel decoderChannel = new EmbeddedChannel(new PerMessageDeflateDecoder(false)); byte[] payload = new byte[300]; random.nextBytes(payload); assertTrue(encoderChannel.writeOutbound(Unpooled.wrappedBuffer(payload))); ByteBuf compressedPayload = encoderChannel.readOutbound(); BinaryWebSocketFrame compressedFrame = new BinaryWebSocketFrame(true, WebSocketExtension.RSV1 | WebSocketExtension.RSV3, compressedPayload.slice(0, compressedPayload.readableBytes() - 4)); assertTrue(decoderChannel.writeInbound(compressedFrame)); BinaryWebSocketFrame uncompressedFrame = decoderChannel.readInbound(); assertNotNull(uncompressedFrame); assertNotNull(uncompressedFrame.content()); assertEquals(WebSocketExtension.RSV3, uncompressedFrame.rsv()); assertEquals(300, uncompressedFrame.content().readableBytes()); byte[] finalPayload = new byte[300]; uncompressedFrame.content().readBytes(finalPayload); assertArrayEquals(finalPayload, payload); uncompressedFrame.release(); }
Source:
<code><START> private ErlangFile getErlangFile(@NotNull VirtualFile virtualFile) { <END> PsiFile psiFile = myPsiManager.findFile(virtualFile); if (psiFile instanceof ErlangFile) { return (ErlangFile) psiFile; } return null; }</code><technical_language>is Nullable? call obtain a not-null value. Move assertion here, method null. Also, of ObjectUtils.tryCast - improve readability. move this method usages - sort of interrupts a reading flow</technical_language>

Target:
private ErlangFile getErlangFile(@NotNull VirtualFile virtualFile) { PsiFile psiFile = myPsiManager.findFile(virtualFile); ErlangFile erlangFile = ObjectUtils.tryCast(psiFile, ErlangFile.class); assert erlangFile != null; return erlangFile; }
Source:
<code><START> public synchronized Integer getAvailable() { <END> Integer quark = fAvailableQuarks.poll(); if (quark == null) { quark = fSs.getQuarkRelativeAndAdd(fBaseQuark, String.valueOf(fCount)); fCount++; } fInUseQuarks.add(quark); return quark; }</code><technical_language>quarks in state system "int" directly, this class care of boxing/unboxing? ie, return a int here, a int parameter in method (and in constructors)</technical_language>

Target:
public synchronized int getAvailable() { Integer quark = fAvailableQuarks.poll(); if (quark == null) { quark = fSs.getQuarkRelativeAndAdd(fBaseQuark, String.valueOf(fCount)); fCount++; } fQuarksInUse.add(quark); return quark; }
Source:
<code>protected List<ConfigIssue> init() { List<ConfigIssue> issues = gcsOriginConfig.init(getContext(), super.init()); storage = StorageOptions.getDefaultInstance().getService(); minMaxPriorityQueue = MinMaxPriorityQueue.orderedBy((Blob o1, Blob o2) -> { int result = o1.getUpdateTime().compareTo(o2.getUpdateTime()); if(result != 0) { return result; } return o1.getName().compareTo(o2.getName()); <START> }).maximumSize(10000).create(); <END> return issues; }</code><technical_language>I recommend exposing 10000 a configuration, i.e max result queue size</technical_language>

Target:
protected List<ConfigIssue> init() { List<ConfigIssue> issues = gcsOriginConfig.init(getContext(), super.init()); minMaxPriorityQueue = MinMaxPriorityQueue.orderedBy((Blob o1, Blob o2) -> { int result = o1.getUpdateTime().compareTo(o2.getUpdateTime()); if(result != 0) { return result; } return o1.getName().compareTo(o2.getName()); }).maximumSize(gcsOriginConfig.maxResultQueueSize).create(); antPathMatcher = new AntPathMatcher(); gcsOriginConfig.prefixPattern = gcsOriginConfig.commonPrefix + gcsOriginConfig.prefixPattern; gcsOriginConfig.credentials.getCredentialsProvider(getContext(), issues).ifPresent(p -> credentialsProvider = p); try { storage = StorageOptions.newBuilder().setCredentials(credentialsProvider.getCredentials()).build().getService(); } catch (IOException e) { getContext().reportError(Errors.GCS_01, e); } return issues; }
Source:
<code>private <START> static void <END> accessLocation() { sConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { } @Override public void onServiceDisconnected(ComponentName name) { } }; Intent testAppService = new Intent(); testAppService.setComponent(new ComponentName(TEST_APP_PKG, TEST_APP_SERVICE)); sContext.bindService(testAppService, sConnection, BIND_AUTO_CREATE); }</code><technical_language>remove static access non-static variables</technical_language>

Target:
private void accessLocation() { mConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { } @Override public void onServiceDisconnected(ComponentName name) { } }; Intent testAppService = new Intent(); testAppService.setComponent(new ComponentName(TEST_APP_PKG, TEST_APP_SERVICE)); sContext.bindService(testAppService, mConnection, BIND_AUTO_CREATE); }
Source:
<code>private boolean isConditionColumnWithSpecialOperator( final BaseColumn baseColumn ) { <START> final ArrayList specialOperators = new ArrayList(); <END> specialOperators.add( "== null" ); specialOperators.add( "!= null" ); return baseColumn instanceof ConditionCol52 && specialOperators.contains( ( (ConditionCol52) baseColumn ).getOperator() ); }</code><technical_language>move this instance static member method-local</technical_language>

Target:
private boolean isConditionColumnWithSpecialOperator( final BaseColumn baseColumn ) { return baseColumn instanceof ConditionCol52 && NullEqualityOperator.contains( ( (ConditionCol52) baseColumn ).getOperator() ) ; }
Source:
<code>public void shouldNotBeOverdueWhenDueTomorrow() throws Exception { Configuration config = new Configuration(); config.setValue("40"); config.setReferencePoint("end"); config.setAction("add"); Appraisal appraisal = new Appraisal(); DateTime endDate = new DateTime(); appraisal.setEndDate(endDate.plusDays(-39).toDate()); assert !EvalsUtil.isOverdue(appraisal, config); <START> assert EvalsUtil.isDue(appraisal, config) > 0; <END> }</code><technical_language>In this case specific check is due in 1 day instead of > 0</technical_language>

Target:
public void shouldNotBeOverdueWhenDueTomorrow() throws Exception { Configuration config = new Configuration(); config.setValue("40"); config.setReferencePoint("end"); config.setAction("add"); Appraisal appraisal = new Appraisal(); DateTime endDate = new DateTime(); appraisal.setEndDate(endDate.plusDays(-39).toDate()); assert !EvalsUtil.isOverdue(appraisal, config); assert EvalsUtil.isDue(appraisal, config) == 1; }
Source:
<code>private void clusterSelectedItemChanged() { AsyncDataProvider.getInstance().getGlusterSnapshotConfig(new AsyncQuery(this, new INewAsyncCallback() { @Override public void onSuccess(Object model, Object returnValue) { VdcQueryReturnValue vdcValue = (VdcQueryReturnValue) returnValue; Pair<List<GlusterVolumeSnapshotConfig>, List<GlusterVolumeSnapshotConfig>> configs = (Pair<List<GlusterVolumeSnapshotConfig>, List<GlusterVolumeSnapshotConfig>>) vdcValue.getReturnValue(); if (configs != null) { List<GlusterVolumeSnapshotConfig> clusterConfigOptions = configs.getFirst(); Collections.sort(clusterConfigOptions, new Linq.GlusterVolumeSnapshotConfigComparator()); setModelItems(getClusterConfigOptions(), clusterConfigOptions, existingClusterConfigs); } else { getClusterConfigOptions().setItems(null); } } private void setModelItems(ListModel<EntityModel<GlusterVolumeSnapshotConfig>> listModel, List<GlusterVolumeSnapshotConfig> cfgs, Map<String, String> fetchedCfgsBackup) { List<EntityModel<GlusterVolumeSnapshotConfig>> coll = new ArrayList<EntityModel<GlusterVolumeSnapshotConfig>>(); for (GlusterVolumeSnapshotConfig cfg : cfgs) { EntityModel<GlusterVolumeSnapshotConfig> cfgModel = new EntityModel<GlusterVolumeSnapshotConfig>(); cfgModel.setEntity(cfg); fetchedCfgsBackup.put(cfg.getParamName(), cfg.getParamValue()); coll.add(cfgModel); } listModel.setItems(coll); } }), <START> getClusters().getSelectedItem().getId(), <END> null); }</code><technical_language>NPE if default cluster is set</technical_language>

Target:
private void clusterSelectedItemChanged() { VDSGroup selectedCluster = getClusters().getSelectedItem(); if (selectedCluster == null) { return; } AsyncDataProvider.getInstance().getGlusterSnapshotConfig(new AsyncQuery(this, new INewAsyncCallback() { @Override public void onSuccess(Object model, Object returnValue) { VdcQueryReturnValue vdcValue = (VdcQueryReturnValue) returnValue; Pair<List<GlusterVolumeSnapshotConfig>, List<GlusterVolumeSnapshotConfig>> configs = (Pair<List<GlusterVolumeSnapshotConfig>, List<GlusterVolumeSnapshotConfig>>) vdcValue.getReturnValue(); if (configs != null) { List<GlusterVolumeSnapshotConfig> clusterConfigOptions = configs.getFirst(); Collections.sort(clusterConfigOptions, new Linq.GlusterVolumeSnapshotConfigComparator()); setModelItems(getClusterConfigOptions(), clusterConfigOptions, existingClusterConfigs); } else { getClusterConfigOptions().setItems(null); } } private void setModelItems(ListModel<EntityModel<GlusterVolumeSnapshotConfig>> listModel, List<GlusterVolumeSnapshotConfig> cfgs, Map<String, String> fetchedCfgsBackup) { List<EntityModel<GlusterVolumeSnapshotConfig>> coll = new ArrayList<EntityModel<GlusterVolumeSnapshotConfig>>(); for (GlusterVolumeSnapshotConfig cfg : cfgs) { EntityModel<GlusterVolumeSnapshotConfig> cfgModel = new EntityModel<GlusterVolumeSnapshotConfig>(); cfgModel.setEntity(cfg); fetchedCfgsBackup.put(cfg.getParamName(), cfg.getParamValue()); coll.add(cfgModel); } listModel.setItems(coll); } }), selectedCluster.getId(), null); }
Source:
<code>public void testCreateNodeWithCustomHardware() throws Exception { Template template = buildTemplate(templateBuilder() .hardwareId("automatic:cores=2;ram=2048;disk=10")); try { NodeMetadata node = getOnlyElement(client.createNodesInGroup(group + "custom", 1, template)); assertThat(node.getHardware().getRam()).isEqualTo(2048); assertThat(node.getHardware().getProcessors().get(0).getCores()).isEqualTo(2); <START> assertThat(node.getHardware().getVolumes().get(0).getSize()).isEqualTo(10); <END> } finally { client.destroyNodesMatching(inGroup(group + "custom")); } }</code><technical_language>Add assertion check hardwre id</technical_language>

Target:
public void testCreateNodeWithCustomHardware() throws Exception { Template template = buildTemplate(templateBuilder() .hardwareId("automatic:cores=2;ram=2048;disk=10")); try { NodeMetadata node = getOnlyElement(client.createNodesInGroup(group + "custom", 1, template)); assertThat(node.getHardware().getRam()).isEqualTo(2048); assertThat(node.getHardware().getProcessors().get(0).getCores()).isEqualTo(2); assertThat(node.getHardware().getVolumes().get(0).getSize()).isEqualTo(10); assertThat(node.getHardware().getId()).isEqualTo("automatic:cores=2;ram=2048;disk=10"); } finally { client.destroyNodesMatching(inGroup(group + "custom")); } }
Source:
<code>public B findGitDir(File current) { if (getGitDir() == null) { FS tryFS = safeFS(); while (current != null) { File dir = new File(current, DOT_GIT); if (FileKey.isGitRepository(dir, tryFS)) { setGitDir(dir); break; } else if (dir.isFile()) try { setGitDir(getSymRef(current, dir, tryFS)); break; } catch (IOException ignored) { } <START> else if (FileKey.isGitRepository(current, tryFS)) { <END> setGitDir(current); break; } current = current.getParentFile(); if (current != null && ceilingDirectories != null && ceilingDirectories.contains(current)) break; } } return self(); }</code><technical_language>I add braces else block improve readability</technical_language>

Target:
public B findGitDir(File current) { if (getGitDir() == null) { FS tryFS = safeFS(); while (current != null) { File dir = new File(current, DOT_GIT); if (FileKey.isGitRepository(dir, tryFS)) { setGitDir(dir); break; } else if (dir.isFile()) { try { setGitDir(getSymRef(current, dir, tryFS)); break; } catch (IOException ignored) { } } else if (FileKey.isGitRepository(current, tryFS)) { setGitDir(current); break; } current = current.getParentFile(); if (current != null && ceilingDirectories != null && ceilingDirectories.contains(current)) break; } } return self(); }
Source:
<code>public void start() { <START> System.out.println("ServerSideSession Start"); <END> instruments.startSession(getSessionId(), application, device, capabilities); final int sessionTimeoutMillis = options.getSessionTimeoutMillis(); stopSessionTimer.schedule(new TimerTask() { @Override public void run() { log.warning("forcing stop session that has been running for " + sessionTimeoutMillis / 1000 + " seconds"); hardForceStop(); } }, sessionTimeoutMillis); URL url = null; try { url = new URL("http://localhost:" + driver.getHostInfo().getPort() + "/wd/hub"); } catch (Exception e) { e.printStackTrace(); } nativeDriver = new ServerSideNativeDriver(url, new SessionId(instruments.getSessionId())); if ("Safari".equals(capabilities.getBundleName())) { setMode(WorkingMode.Web); getRemoteWebDriver().get("about:blank"); } }</code><technical_language>Drop logging line</technical_language>

Target:
public void start() { instruments.startSession(getSessionId(), application, device, capabilities); final int sessionTimeoutMillis = options.getSessionTimeoutMillis(); stopSessionTimer.schedule(new TimerTask() { @Override public void run() { log.warning("forcing stop session that has been running for " + sessionTimeoutMillis / 1000 + " seconds"); hardForceStop(); } }, sessionTimeoutMillis); URL url = null; try { url = new URL("http://localhost:" + driver.getHostInfo().getPort() + "/wd/hub"); } catch (Exception e) { e.printStackTrace(); } nativeDriver = new ServerSideNativeDriver(url, new SessionId(instruments.getSessionId())); if ("Safari".equals(capabilities.getBundleName())) { setMode(WorkingMode.Web); getRemoteWebDriver().get("about:blank"); } }
Source:
<code>private void changeStatus(DestroyVmVDSCommandParameters parameters, VM curVm) { <START> if (curVm.getRunOnVds() != null || curVm.getStatus() != VMStatus.MigratingTo) { <END> ResourceManager.getInstance().InternalSetVmStatus(curVm, parameters.getGracefully() ? VMStatus.PoweringDown : VMStatus.Down); } }</code><technical_language>i thought compare vm.runOnVds getVdsId() this consideration cases specific migration flow</technical_language>

Target:
private void changeStatus(DestroyVmVDSCommandParameters parameters, VM curVm) { if (getVdsId().equals(curVm.getRunOnVds())) { ResourceManager.getInstance().InternalSetVmStatus(curVm, parameters.getGracefully() ? VMStatus.PoweringDown : VMStatus.Down); } }
Source:
<code>private Set<IPath> getAllPaths() { Set<IPath> paths = new HashSet<IPath>(); TableItem[] items = fileTableViewer.getTable().getItems(); for (TableItem item : items) { Object element = item.getData(); IResource source; if (element instanceof IResource) { source = (IResource) element; } else if (element instanceof IAdaptable) { source = (IResource) ((IAdaptable) element).getAdapter(IResource.class); } else { <START> RDTSyncUIPlugin.getDefault().logErrorMessage(Messages.SyncMenuOperation_6); <END> continue; } paths.add(source.getProjectRelativePath()); } return paths; }</code><technical_language>Recommend a new error message instead of borrowing sync menu</technical_language>

Target:
private Set<IPath> getAllPaths() { Set<IPath> paths = new HashSet<IPath>(); TableItem[] items = fileTableViewer.getTable().getItems(); for (TableItem item : items) { Object element = item.getData(); IResource source; if (element instanceof IResource) { source = (IResource) element; } else if (element instanceof IAdaptable) { source = (IResource) ((IAdaptable) element).getAdapter(IResource.class); } else { RDTSyncUIPlugin.getDefault().logErrorMessage( Messages.SyncMergeFileTableViewer_Selected_element_not_adaptable); continue; } paths.add(source.getProjectRelativePath()); } return paths; }
Source:
<code>public AzureKeyVaultKeyWrapMetadata(URL masterKeyUri) { <START> super(AzureKeyVaultKeyWrapMetadata.TYPE_CONSTANT, masterKeyUri.toString(), "RSA-OAEP-256"); <END> }</code><technical_language>create a static constant (even in this class start with) for this - "RSA-OAEP-256" - is easier change track in future</technical_language>

Target:
public AzureKeyVaultKeyWrapMetadata(URL masterKeyUri) { super(AzureKeyVaultKeyWrapMetadata.TYPE_CONSTANT, masterKeyUri.toString(), ALGO); }
Source:
<code>private void examinedEnoughCellsIs(boolean expected) { CellsToSweepPartitioningIterator.ExaminedCellLimit limit = new CellsToSweepPartitioningIterator.ExaminedCellLimit(startingRow.getBytes(), maxCellsToExamine); <START> assertThat(limit.examinedEnoughCells(cellsExamined, cell()), Matchers.is(expected)); <END> }</code><technical_language>nit: standard practice is static import</technical_language>

Target:
private void examinedEnoughCellsIs(boolean expected) { CellsToSweepPartitioningIterator.ExaminedCellLimit limit = new CellsToSweepPartitioningIterator.ExaminedCellLimit(startingRow.getBytes(), maxCellsToExamine); assertThat(limit.examinedEnoughCells(cellsExamined, cell()), is(expected)); }
Source:
<code>public void testNewInstanceMethod() { MyStreamCodec codec = new MyStreamCodec(); DefaultStatefulStreamCodec newCodec = codec.newInstance(); <START> Assert.assertEquals("The class type is correct", newCodec.getClass(), codec.getClass()); <END> }</code><technical_language>Add codec != newCodec assertion checks for DefaultStatefulStreamCodec</technical_language>

Target:
public void testNewInstanceMethod() { NoNewInstanceStatefulStreamCodec codec = new NoNewInstanceStatefulStreamCodec(); DefaultStatefulStreamCodec newCodec = codec.newInstance(); Assert.assertNotEquals("Codec and newCodec are not same ", codec, newCodec); Assert.assertEquals("Class of codec and newCodec is same ", newCodec.getClass(), codec.getClass()); }
Source:
<code>public boolean vdsUpEvent(final VDS vds) { HostStoragePoolParametersBase params = new HostStoragePoolParametersBase(vds); boolean isSucceeded = backend.runInternalAction(VdcActionType.InitVdsOnUp, params).getSucceeded(); if (isSucceeded) { ThreadPoolUtil.execute(new Runnable() { @Override public void run() { try { List<VmStatic> vmsToMigrate = DbFacade.getInstance().getVmStaticDao().getAllWithFailbackByVds(vds.getId()); if (!vmsToMigrate.isEmpty()) { CommandContext ctx = new CommandContext(new EngineContext()); ctx.getExecutionContext().setMonitored(true); backend.runInternalMultipleActions(VdcActionType.MigrateVmToServer, new ArrayList<>(createMigrateVmToServerParametersList(vmsToMigrate, vds)), ctx); } } catch (RuntimeException e) { log.error("Failed to initialize Vds on up: {}", e.getMessage()); log.error("Exception", e); } } }); } <START> if (isSucceeded && vds.getVdsGroupSupportsGlusterService()) { <END> isSucceeded = resourceManagerProvider.get().runVdsCommand(VDSCommandType.ManageGlusterService, new GlusterServiceVDSParameters(vds.getId(), Arrays.asList("glusterd"), "restart")).getSucceeded(); } return isSucceeded; }</code><technical_language>I verifying this patch. vdsUpEvent called. called host status is UP. host status glusterd service is started. I move this logic ActivcateVdsCommand</technical_language>

Target:
public boolean vdsUpEvent(final VDS vds) { HostStoragePoolParametersBase params = new HostStoragePoolParametersBase(vds); boolean isSucceeded = backend.runInternalAction(VdcActionType.InitVdsOnUp, params).getSucceeded(); if (isSucceeded) { ThreadPoolUtil.execute(new Runnable() { @Override public void run() { try { List<VmStatic> vmsToMigrate = DbFacade.getInstance().getVmStaticDao().getAllWithFailbackByVds(vds.getId()); if (!vmsToMigrate.isEmpty()) { CommandContext ctx = new CommandContext(new EngineContext()); ctx.getExecutionContext().setMonitored(true); backend.runInternalMultipleActions(VdcActionType.MigrateVmToServer, new ArrayList<>(createMigrateVmToServerParametersList(vmsToMigrate, vds)), ctx); } } catch (RuntimeException e) { log.error("Failed to initialize Vds on up: {}", e.getMessage()); log.error("Exception", e); } } }); } return isSucceeded; }
Source:
<code>private Set<String> collectAllLiterals(Map<String, Node> elements) { <START> Set<String> literalTypes = new HashSet(); <END> for (Node n : elements.values()) { if (n.isString()) { literalTypes.add(n.getString()); } } return literalTypes; }</code><technical_language>literal initializers, types. emit types collect initializers</technical_language>

Target:
private Set<String> collectAllLiterals(Map<String, Node> elements) { Set<String> literalInitializers = new HashSet(); for (Node n : elements.values()) { if (n.isString()) { literalInitializers.add(n.getString()); } } return literalInitializers; }
Source:
<code><START> private void loadMetricConfigResources(AppConfig config, LinkedList<Configuration> configurationList) { <END> List<String> resourceConfigList = config.getMetricConfigResources(); if (resourceConfigList != null) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); for (String resourceName : resourceConfigList) { LOGGER.info("Reading metric config resource " + resourceName); InputStream inputStream = classLoader.getResourceAsStream(resourceName); if (inputStream == null) { LOGGER.warn("Cannot find metric config resource" + resourceName); } else { try { LinkedHashMap<String, ArrayList<LinkedHashMap<String, Object>>> topYaml = (LinkedHashMap<String, ArrayList<LinkedHashMap<String, Object>>>) YAML.get().load(inputStream); ArrayList<LinkedHashMap<String, Object>> jmxConf = topYaml.get("jmx_metrics"); if(jmxConf != null) { for (LinkedHashMap<String, Object> conf : jmxConf) { configurationList.add(new Configuration(conf)); } } else { LOGGER.warn("jmx_metrics block not found in resource " + resourceName); } } catch (Exception e) { LOGGER.warn("Cannot parse yaml resource " + resourceName, e); } finally { try { inputStream.close(); } catch (IOException e) { } } } } } }</code><technical_language>create a method get inputStream this method testable creating object instance calling this method while providing inputStream</technical_language>

Target:
static void loadMetricConfigResources(AppConfig config, LinkedList<Configuration> configurationList) { List<String> resourceConfigList = config.getMetricConfigResources(); if (resourceConfigList != null) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); for (String resourceName : resourceConfigList) { LOGGER.info("Reading metric config resource " + resourceName); InputStream inputStream = classLoader.getResourceAsStream(resourceName); if (inputStream == null) { LOGGER.warn("Cannot find metric config resource" + resourceName); } else { try { LinkedHashMap<String, ArrayList<LinkedHashMap<String, Object>>> topYaml = (LinkedHashMap<String, ArrayList<LinkedHashMap<String, Object>>>) YAML.get().load(inputStream); ArrayList<LinkedHashMap<String, Object>> jmxConf = topYaml.get("jmx_metrics"); if(jmxConf != null) { for (LinkedHashMap<String, Object> conf : jmxConf) { configurationList.add(new Configuration(conf)); } } else { LOGGER.warn("jmx_metrics block not found in resource " + resourceName); } } catch (Exception e) { LOGGER.warn("Cannot parse yaml resource " + resourceName, e); } finally { try { inputStream.close(); } catch (IOException e) { } } } } } }
Source:
<code>private <E> FileAppender<E> newAppender(Path temp) { Format format = descriptor.getFormat(); if (Formats.PARQUET.equals(format)) { <START> if (DescriptorUtil.isDisabled( <END> FileSystemProperties.NON_DURABLE_PARQUET_PROP, descriptor)) { return (FileAppender<E>) new DurableParquetAppender( fs, temp, descriptor.getSchema(), conf, descriptor.getCompressionType()); } else { return (FileAppender<E>) new ParquetAppender( fs, temp, descriptor.getSchema(), conf, descriptor.getCompressionType()); } } else if (Formats.AVRO.equals(format)) { return new AvroAppender<E>(fs, temp, descriptor.getSchema(), descriptor.getCompressionType()); } else if (Formats.CSV.equals(format) && DescriptorUtil.isEnabled(FileSystemProperties.ALLOW_CSV_PROP, descriptor)) { return new CSVAppender<E>(fs, temp, descriptor); } else { this.state = ReaderWriterState.ERROR; throw new DatasetWriterException("Unknown format " + descriptor); } }</code><technical_language>Is new method needed get default-to-false? isEnabled change default property</technical_language>

Target:
<E> FileAppender<E> newAppender(Path temp) { Format format = descriptor.getFormat(); if (Formats.PARQUET.equals(format)) { if (DescriptorUtil.isDisabled( FileSystemProperties.NON_DURABLE_PARQUET_PROP, descriptor)) { return (FileAppender<E>) new DurableParquetAppender( fs, temp, descriptor.getSchema(), conf, descriptor.getCompressionType()); } else { return (FileAppender<E>) new ParquetAppender( fs, temp, descriptor.getSchema(), conf, descriptor.getCompressionType()); } } else if (Formats.AVRO.equals(format)) { return new AvroAppender<E>(fs, temp, descriptor.getSchema(), descriptor.getCompressionType()); } else if (Formats.CSV.equals(format) && DescriptorUtil.isEnabled(FileSystemProperties.ALLOW_CSV_PROP, descriptor)) { return new CSVAppender<E>(fs, temp, descriptor); } else { this.state = ReaderWriterState.ERROR; throw new DatasetWriterException("Unknown format " + descriptor); } }
Source:
<code>public Optional<? extends ActivePagination> getValue(final Parameter.Key<? super ActivePagination> parameterKey, final ArgumentReader.Mutable reader, final CommandContext.Builder context) throws ArgumentParseException { <START> final Audience source = context.getCause().first(Audience.class) <END> .orElseThrow(() -> reader.createException(TextComponent.of("No usable source found"))); final SourcePaginations paginations = SpongePaginationService.this.getPaginationState(source, false); if (paginations == null) { final String name = source instanceof Nameable ? ((Nameable) source).getName() : source.toString(); throw reader.createException(TextComponent.of(String.format("Source %s has no paginations!", name))); } final UUID id; final ArgumentReader.Immutable state = reader.getImmutable(); try { id = UUID.fromString(reader.parseString()); } catch (final IllegalArgumentException ex) { if (paginations.getLastUuid() != null) { reader.setState(state); return Optional.ofNullable(paginations.get(paginations.getLastUuid())); } throw reader.createException(TextComponent.of("Input was not a valid UUID!")); } final ActivePagination pagination = paginations.get(id); if (pagination == null) { throw reader.createException(TextComponent.of("No pagination registered for id " + id)); } return Optional.ofNullable(paginations.get(id)); }</code><technical_language>first(Audience.class) -> .getAudience()</technical_language>

Target:
public Optional<? extends ActivePagination> getValue(final Parameter.Key<? super ActivePagination> parameterKey, final ArgumentReader.Mutable reader, final CommandContext.Builder context) throws ArgumentParseException { final Audience source = context.getCause().getAudience(); final SourcePaginations paginations = SpongePaginationService.this.getPaginationState(source, false); if (paginations == null) { final String name = source instanceof Nameable ? ((Nameable) source).getName() : source.toString(); throw reader.createException(TextComponent.of(String.format("Source %s has no paginations!", name))); } final UUID id; final ArgumentReader.Immutable state = reader.getImmutable(); try { id = UUID.fromString(reader.parseString()); } catch (final IllegalArgumentException ex) { if (paginations.getLastUuid() != null) { reader.setState(state); return Optional.ofNullable(paginations.get(paginations.getLastUuid())); } throw reader.createException(TextComponent.of("Input was not a valid UUID!")); } final ActivePagination pagination = paginations.get(id); if (pagination == null) { throw reader.createException(TextComponent.of("No pagination registered for id " + id)); } return Optional.ofNullable(paginations.get(id)); }
Source:
<code>public List<? extends ToolInstaller> getDefaultInstallers() { try { Class<? extends ToolInstaller> jdkInstallerClass = Jenkins.getInstance().getPluginManager() .uberClassLoader.loadClass("hudson.tools.JDKInstaller").asSubclass(ToolInstaller.class); Constructor<? extends ToolInstaller> constructor = jdkInstallerClass.getConstructor(String.class, boolean.class); return Collections.singletonList(constructor.newInstance(null, false)); } catch (ClassNotFoundException e) { return Collections.emptyList(); <START> } catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) { <END> LOGGER.log(Level.WARNING, "Unable to get default installer", e); return Collections.emptyList(); } }</code><technical_language>ClassCastException I suppose, theoretically. catch Exception already</technical_language>

Target:
public List<? extends ToolInstaller> getDefaultInstallers() { try { Class<? extends ToolInstaller> jdkInstallerClass = Jenkins.getInstance().getPluginManager() .uberClassLoader.loadClass("hudson.tools.JDKInstaller").asSubclass(ToolInstaller.class); Constructor<? extends ToolInstaller> constructor = jdkInstallerClass.getConstructor(String.class, boolean.class); return Collections.singletonList(constructor.newInstance(null, false)); } catch (ClassNotFoundException e) { return Collections.emptyList(); } catch (Exception e) { LOGGER.log(Level.WARNING, "Unable to get default installer", e); return Collections.emptyList(); } }
Source:
<code>private void testCancelNewOrEditQuestion() { ______TS("Testing cancelling adding or editing questions"); feedbackEditPage.selectNewQuestionType("Multiple-choice (single answer) question"); feedbackEditPage.clickNewQuestionButton(); ______TS("MCQ: click and cancel 'cancel new question'"); feedbackEditPage.clickAndCancel(feedbackEditPage.getCancelQuestionLink(-1)); assertTrue(feedbackEditPage.verifyNewMcqQuestionFormIsDisplayed()); ______TS("MCQ: click and confirm 'cancel new question'"); feedbackEditPage.clickAndConfirm(feedbackEditPage.getCancelQuestionLink(-1)); assertFalse(feedbackEditPage.verifyNewMcqQuestionFormIsDisplayed()); ______TS("MCQ: click and cancel 'editing question'"); feedbackEditPage.selectNewQuestionType("Multiple-choice (single answer) question"); feedbackEditPage.clickNewQuestionButton(); feedbackEditPage.fillQuestionBox("mcq qn"); feedbackEditPage.fillMcqOption(0, "Choice 1"); feedbackEditPage.fillMcqOption(1, "Choice 2"); feedbackEditPage.clickAddQuestionButton(); <START> assertEquals(true, feedbackEditPage.clickEditQuestionButton(1)); <END> feedbackEditPage.clickAndCancel(feedbackEditPage.getCancelQuestionLink(1)); assertTrue(feedbackEditPage.checkCancelEditQuestionButtonVisibility(1)); ______TS("MCQ: click and confirm 'editing question'"); feedbackEditPage.clickAndConfirm(feedbackEditPage.getCancelQuestionLink(1)); assertFalse(feedbackEditPage.checkCancelEditQuestionButtonVisibility(1)); feedbackEditPage.clickAndConfirm(feedbackEditPage.getDeleteQuestionLink(1)); }</code><technical_language>assertTrue instead</technical_language>

Target:
private void testCancelNewOrEditQuestion() { ______TS("Testing cancelling adding or editing questions"); feedbackEditPage.selectNewQuestionType("Multiple-choice (single answer) question"); feedbackEditPage.clickNewQuestionButton(); ______TS("MCQ: click and cancel 'cancel new question'"); feedbackEditPage.clickAndCancel(feedbackEditPage.getCancelQuestionLink(-1)); assertTrue(feedbackEditPage.verifyNewMcqQuestionFormIsDisplayed()); ______TS("MCQ: click and confirm 'cancel new question'"); feedbackEditPage.clickAndConfirm(feedbackEditPage.getCancelQuestionLink(-1)); assertFalse(feedbackEditPage.verifyNewMcqQuestionFormIsDisplayed()); ______TS("MCQ: click and cancel 'editing question'"); feedbackEditPage.selectNewQuestionType("Multiple-choice (single answer) question"); feedbackEditPage.clickNewQuestionButton(); feedbackEditPage.fillQuestionBox("mcq qn"); feedbackEditPage.fillMcqOption(0, "Choice 1"); feedbackEditPage.fillMcqOption(1, "Choice 2"); feedbackEditPage.clickAddQuestionButton(); assertTrue(feedbackEditPage.clickEditQuestionButton(1)); feedbackEditPage.clickAndCancel(feedbackEditPage.getCancelQuestionLink(1)); assertTrue(feedbackEditPage.checkCancelEditQuestionButtonVisibility(1)); ______TS("MCQ: click and confirm 'editing question'"); feedbackEditPage.clickAndConfirm(feedbackEditPage.getCancelQuestionLink(1)); assertFalse(feedbackEditPage.checkCancelEditQuestionButtonVisibility(1)); feedbackEditPage.clickAndConfirm(feedbackEditPage.getDeleteQuestionLink(1)); }
Source:
<code>Type leastUpperBound(List<Type> typeAlternatives) { <START> return types.leastUpperBound(typeAlternatives.toArray(new Type[typeAlternatives.size()])); <END> }</code><technical_language>convulotions list array</technical_language>

Target:
Type leastUpperBound(List<Type> typeAlternatives) { return types.leastUpperBound(typeAlternatives); }
Source:
<code>private boolean isRegisterHealthIndicator(CircuitBreaker circuitBreaker) { return circuitBreakerProperties.findCircuitBreakerProperties(circuitBreaker.getName()) .map(InstanceProperties::getRegisterHealthIndicator) <START> .orElse(true); <END> }</code><technical_language>disable HealthIndicator default. Please set false default value</technical_language>

Target:
private boolean isRegisterHealthIndicator(CircuitBreaker circuitBreaker) { return circuitBreakerProperties.findCircuitBreakerProperties(circuitBreaker.getName()) .map(InstanceProperties::getRegisterHealthIndicator) .orElse(false); }
Source:
<code>protected ScriptEngine getScriptEngine() throws ScriptException { String lang = getScriptLanguage(); if (lang.isEmpty()) { lang = defaultScriptLanguage; <START> log.warn("Script language has not been chosen on the UI, the script will be interpreted as a groovy script"); <END> } ScriptEngine scriptEngine = getInstance().getEngineByName(lang); if (scriptEngine == null) { throw new ScriptException("Cannot find engine named: '"+lang+"', ensure you set language field in JSR223 Test Element: "+getName()); } return scriptEngine; }</code><technical_language>Do intend warn sampler execution? This broken</technical_language>

Target:
protected ScriptEngine getScriptEngine() throws ScriptException { String lang = getScriptLanguage(); if (StringUtils.isEmpty(lang)) { lang = DEFAULT_SCRIPT_LANGUAGE; setScriptLanguage(lang); } ScriptEngine scriptEngine = getInstance().getEngineByName(lang); if (scriptEngine == null) { throw new ScriptException("Cannot find engine named: '"+lang+"', ensure you set language field in JSR223 Test Element: "+getName()); } return scriptEngine; }
Source:
<code>void configureDataSource(Resource dbprops, Resource monitoringDir) throws Exception { Properties db = new Properties(); if (dbprops == null) { dbprops = monitoringDir.get("db.properties"); InputStream in = getClass().getResourceAsStream("db.properties"); IOUtils.copy(in, dbprops.out()); db.load(getClass().getResourceAsStream("db.properties")); } else { InputStream in = dbprops.in(); db.load(in); <START> in.close(); <END> } logDbProperties(db); setDriverClassName(db.getProperty("driver")); setUrl(getURL(db)); if (db.containsKey("username")) { setUsername(db.getProperty("username")); } if (db.containsKey("password")) { setPassword(db.getProperty("password")); } setDefaultAutoCommit(Boolean.valueOf(db.getProperty("defaultAutoCommit", "true"))); setMinIdle(1); setMaxActive(4); super.getConnection(); }</code><technical_language>@NielsCharlier is this a resource leak? fixed a try-with-resources block</technical_language>

Target:
void configureDataSource(Resource dbprops, Resource monitoringDir) throws Exception { Properties db = new Properties(); if (dbprops == null) { dbprops = monitoringDir.get("db.properties"); InputStream in = getClass().getResourceAsStream("db.properties"); IOUtils.copy(in, dbprops.out()); db.load(getClass().getResourceAsStream("db.properties")); } else { try (InputStream in = dbprops.in()) { db.load(in); } } logDbProperties(db); setDriverClassName(db.getProperty("driver")); setUrl(getURL(db)); if (db.containsKey("username")) { setUsername(db.getProperty("username")); } if (db.containsKey("password")) { setPassword(db.getProperty("password")); } setDefaultAutoCommit(Boolean.valueOf(db.getProperty("defaultAutoCommit", "true"))); setMinIdle(1); setMaxActive(4); super.getConnection(); }
Source:
<code>private boolean permitCmAndStackUpgrade(Image currentImage, Image image, String versionKey, String buildNumberKey) { <START> String currentVersion = currentImage.getPackageVersions().get(versionKey); <END> String newVersion = image.getPackageVersions().get(versionKey); return upgradePermissionProvider.permitCmAndStackUpgrade(currentVersion, newVersion) || (currentVersion.equals(newVersion) && componentBuildNumberComparator.compare(currentImage, image, buildNumberKey)); }</code><technical_language>pls do this in NPE safe</technical_language>

Target:
private boolean permitCmAndStackUpgrade(Image currentImage, Image image, String versionKey, String buildNumberKey) { return upgradePermissionProvider.permitCmAndStackUpgrade(currentImage, image, versionKey, buildNumberKey); }
Source:
<code>private void cleanupInvalidRegistrationIDsForVariant(String variantID, MulticastResult multicastResult, List<String> registrationIDs) { final List<Result> results = multicastResult.getResults(); final Set<String> inactiveTokens = new HashSet<String>(); for (int i = 0; i < results.size(); i++) { final Result result = results.get(i); final String errorCodeName = result.getErrorCodeName(); <START> if (Constants.ERROR_INVALID_REGISTRATION.equals(errorCodeName) || Constants.ERROR_NOT_REGISTERED.equals(errorCodeName)) { <END> inactiveTokens.add(registrationIDs.get(i)); } } logger.fine("Deleting '" + inactiveTokens.size() + "' invalid Android installations"); clientInstallationService.removeInstallationsForVariantByDeviceTokens(variantID, inactiveTokens); }</code><technical_language>a static Set of invalid error codes this line if (INVALID_CODES.conatins(errorCodeName)) {</technical_language>

Target:
private void cleanupInvalidRegistrationIDsForVariant(String variantID, MulticastResult multicastResult, List<String> registrationIDs) { final List<Result> results = multicastResult.getResults(); final Set<String> inactiveTokens = new HashSet<String>(); for (int i = 0; i < results.size(); i++) { final Result result = results.get(i); final String errorCodeName = result.getErrorCodeName(); if (GCM_ERROR_CODES.contains(errorCodeName)) { inactiveTokens.add(registrationIDs.get(i)); } } logger.fine("Deleting '" + inactiveTokens.size() + "' invalid Android installations"); clientInstallationService.removeInstallationsForVariantByDeviceTokens(variantID, inactiveTokens); }
Source:
<code>public long writeTo(WritableByteChannel channel) throws IOException { long totalWritten = 0; if (bufferToSend == null) { <START> bufferToSend = ByteBuffer.allocate(Math.max((int)sizeInBytes(), MAX_WRITE_BUFFER_SIZE)); <END> writeHeader(); bufferToSend.put(blobId.toBytes()); BlobPropertiesSerDe.putBlobPropertiesToBuffer(bufferToSend, properties); bufferToSend.putInt(usermetadata.capacity()); bufferToSend.put(usermetadata); bufferToSend.flip(); } while (sentBytes < sizeInBytes()) { if (bufferToSend.remaining() > 0) { int toWrite = bufferToSend.remaining(); int written = channel.write(bufferToSend); totalWritten += written; sentBytes += written; if (toWrite != written || sentBytes == sizeInBytes()) { break; } } logger.trace("sent Bytes from Put Request {}", sentBytes); bufferToSend.clear(); int dataRead = data.read(bufferToSend.array(), 0, (int) Math.min(bufferToSend.capacity(), (sizeInBytes() - sentBytes))); bufferToSend.limit(dataRead); } return totalWritten; }</code><technical_language>Math.min</technical_language>

Target:
public long writeTo(WritableByteChannel channel) throws IOException { long totalWritten = 0; if (bufferToSend == null) { int bufferSize = sizeInBytes() < MAX_WRITE_BUFFER_SIZE ? (int) sizeInBytes() : (Math.max(MAX_WRITE_BUFFER_SIZE, sizeExcludingData())); bufferToSend = ByteBuffer.allocate(bufferSize); writeHeader(); bufferToSend.put(blobId.toBytes()); BlobPropertiesSerDe.putBlobPropertiesToBuffer(bufferToSend, properties); bufferToSend.putInt(usermetadata.capacity()); bufferToSend.put(usermetadata); bufferToSend.flip(); } while (sentBytes < sizeInBytes()) { if (bufferToSend.remaining() > 0) { int toWrite = bufferToSend.remaining(); int written = channel.write(bufferToSend); totalWritten += written; sentBytes += written; if (toWrite != written || sentBytes == sizeInBytes()) { break; } } logger.trace("sent Bytes from Put Request {}", sentBytes); bufferToSend.clear(); int dataRead = data.read(bufferToSend.array(), 0, (int) Math.min(bufferToSend.capacity(), (sizeInBytes() - sentBytes))); bufferToSend.limit(dataRead); } return totalWritten; }
Source:
<code>public void testWritingSeveralRawTaggedFields() { <START> List<RawTaggedField> tags = Arrays.asList(new RawTaggedField[] { <END> new RawTaggedField(2, new byte[] {0x1, 0x2, 0x3}), new RawTaggedField(5, new byte[] {0x4, 0x5}) }); RawTaggedFieldWriter writer = RawTaggedFieldWriter.forFields(tags); assertEquals(2, writer.numFields()); byte[] arr = new byte[9]; ByteBufferAccessor accessor = new ByteBufferAccessor(ByteBuffer.wrap(arr)); writer.writeRawTags(accessor, 1); assertArrayEquals(new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, arr); writer.writeRawTags(accessor, 3); assertArrayEquals(new byte[] {0x2, 0x3, 0x1, 0x2, 0x3, 0x0, 0x0, 0x0, 0x0}, arr); writer.writeRawTags(accessor, 7); assertArrayEquals(new byte[] {0x2, 0x3, 0x1, 0x2, 0x3, 0x5, 0x2, 0x4, 0x5}, arr); writer.writeRawTags(accessor, Integer.MAX_VALUE); assertArrayEquals(new byte[] {0x2, 0x3, 0x1, 0x2, 0x3, 0x5, 0x2, 0x4, 0x5}, arr); }</code><technical_language>nit: vararg constructor. A couple</technical_language>

Target:
public void testWritingSeveralRawTaggedFields() { List<RawTaggedField> tags = Arrays.asList( new RawTaggedField(2, new byte[] {0x1, 0x2, 0x3}), new RawTaggedField(5, new byte[] {0x4, 0x5}) ); RawTaggedFieldWriter writer = RawTaggedFieldWriter.forFields(tags); assertEquals(2, writer.numFields()); byte[] arr = new byte[9]; ByteBufferAccessor accessor = new ByteBufferAccessor(ByteBuffer.wrap(arr)); writer.writeRawTags(accessor, 1); assertArrayEquals(new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, arr); writer.writeRawTags(accessor, 3); assertArrayEquals(new byte[] {0x2, 0x3, 0x1, 0x2, 0x3, 0x0, 0x0, 0x0, 0x0}, arr); writer.writeRawTags(accessor, 7); assertArrayEquals(new byte[] {0x2, 0x3, 0x1, 0x2, 0x3, 0x5, 0x2, 0x4, 0x5}, arr); writer.writeRawTags(accessor, Integer.MAX_VALUE); assertArrayEquals(new byte[] {0x2, 0x3, 0x1, 0x2, 0x3, 0x5, 0x2, 0x4, 0x5}, arr); }