auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private DfsBlockCache(final DfsBlockCacheConfig cfg) { tableSize = tableSize(cfg); if (tableSize < 1) throw new IllegalArgumentException(JGitText.get().tSizeMustBeGreaterOrEqual1); table = new AtomicReferenceArray<>(tableSize); loadLocks = new ReentrantLock[cfg.getConcurrencyLevel()]; for (int i = 0; i < loadLocks.length; i++) loadLocks[i] = new ReentrantLock(true ); maxBytes = cfg.getBlockLimit(); maxStreamThroughCache = (long) (maxBytes * cfg.getStreamRatio()); blockSize = cfg.getBlockSize(); blockSizeShift = Integer.numberOfTrailingZeros(blockSize); clockLock = new ReentrantLock(true ); String none = ""; clockHand = new Ref<>( DfsStreamKey.of(new DfsRepositoryDescription(none), none), -1, 0, null); clockHand.next = clockHand; statHit = new <START> AtomicReference<>(new AtomicLong[] { new AtomicLong() }); <END> statMiss = new AtomicReference<>(new AtomicLong[] { new AtomicLong() }); statEvict = new AtomicReference<>( new AtomicLong[] { new AtomicLong() }); }</code><technical_language>Create a static helper method presizes PackExt.values().length</technical_language>

Target:
private DfsBlockCache(final DfsBlockCacheConfig cfg) { tableSize = tableSize(cfg); if (tableSize < 1) throw new IllegalArgumentException(JGitText.get().tSizeMustBeGreaterOrEqual1); table = new AtomicReferenceArray<>(tableSize); loadLocks = new ReentrantLock[cfg.getConcurrencyLevel()]; for (int i = 0; i < loadLocks.length; i++) loadLocks[i] = new ReentrantLock(true ); maxBytes = cfg.getBlockLimit(); maxStreamThroughCache = (long) (maxBytes * cfg.getStreamRatio()); blockSize = cfg.getBlockSize(); blockSizeShift = Integer.numberOfTrailingZeros(blockSize); clockLock = new ReentrantLock(true ); String none = ""; clockHand = new Ref<>( DfsStreamKey.of(new DfsRepositoryDescription(none), none, null), -1, 0, null); clockHand.next = clockHand; statHit = new AtomicReference<>(newCounters()); statMiss = new AtomicReference<>(newCounters()); statEvict = new AtomicReference<>(newCounters()); liveBytes = new AtomicReference<>(newCounters()); }
Source:
<code>public void testContainer() { final List<Container> resultContainers = this.resultPod.getSpec().getContainers(); assertEquals(1, resultContainers.size()); final Container resultMainContainer = resultContainers.get(0); assertEquals( KubernetesTaskManagerParameters.TASK_MANAGER_MAIN_CONTAINER_NAME, resultMainContainer.getName()); assertEquals(CONTAINER_IMAGE, resultMainContainer.getImage()); assertEquals(CONTAINER_IMAGE_PULL_POLICY.name(), resultMainContainer.getImagePullPolicy()); <START> assertEquals(CONTAINER_IMAGE_PULL_POLICY.name(), resultMainContainer.getImagePullPolicy()); <END> assertEquals(4, resultMainContainer.getEnv().size()); assertTrue(resultMainContainer.getEnv() .stream() .anyMatch(envVar -> envVar.getName().equals("key1"))); assertEquals(1, resultMainContainer.getPorts().size()); assertEquals(1, resultMainContainer.getCommand().size()); assertEquals(3, resultMainContainer.getArgs().size()); assertEquals(2, resultMainContainer.getVolumeMounts().size()); }</code><technical_language>A duplicated line</technical_language>

Target:
public void testContainer() { final List<Container> resultContainers = this.resultPod.getSpec().getContainers(); assertEquals(1, resultContainers.size()); final Container resultMainContainer = resultContainers.get(0); assertEquals( KubernetesTaskManagerParameters.TASK_MANAGER_MAIN_CONTAINER_NAME, resultMainContainer.getName()); assertEquals(CONTAINER_IMAGE, resultMainContainer.getImage()); assertEquals(CONTAINER_IMAGE_PULL_POLICY.name(), resultMainContainer.getImagePullPolicy()); assertEquals(4, resultMainContainer.getEnv().size()); assertTrue(resultMainContainer.getEnv() .stream() .anyMatch(envVar -> envVar.getName().equals("key1"))); assertEquals(1, resultMainContainer.getPorts().size()); assertEquals(1, resultMainContainer.getCommand().size()); assertEquals(3, resultMainContainer.getArgs().size()); assertEquals(2, resultMainContainer.getVolumeMounts().size()); }
Source:
<code>public AppStateClusterImpl(AppSettings appSettings) { ClusterProperties clusterProperties = new ClusterProperties(appSettings); clusterProperties.validate(); if (!clusterProperties.isEnabled()) { throw new IllegalStateException("Cluster is not enabled on this instance"); } Config hzConfig = new Config(); try { hzConfig.setInstanceName(InetAddress.getLocalHost().getHostName()); <START> } catch (UnknownHostException e) { <END> } hzConfig.getGroupConfig().setName(clusterProperties.getName()); NetworkConfig netConfig = hzConfig.getNetworkConfig(); netConfig.setPort(clusterProperties.getPort()); if (!clusterProperties.getInterfaces().isEmpty()) { netConfig.getInterfaces() .setEnabled(true) .setInterfaces(clusterProperties.getInterfaces()); } JoinConfig joinConfig = netConfig.getJoin(); joinConfig.getAwsConfig().setEnabled(false); joinConfig.getMulticastConfig().setEnabled(false); joinConfig.getTcpIpConfig().setEnabled(true); joinConfig.getTcpIpConfig().setMembers(clusterProperties.getMembers()); hzConfig .setProperty("hazelcast.tcp.join.port.try.count", "10") .setProperty("hazelcast.socket.bind.any", "false") .setProperty("hazelcast.phone.home.enabled", "false") .setProperty("hazelcast.logging.type", "slf4j"); hzConfig.getPartitionGroupConfig().setEnabled(false); hzInstance = Hazelcast.newHazelcastInstance(hzConfig); operationalProcesses = hzInstance.getReplicatedMap(OPERATIONAL_PROCESSES); listenerUuid = operationalProcesses.addEntryListener(new OperationalProcessListener()); }</code><technical_language>![MAJOR](<LINK_0> 'Severity: MAJOR') log rethrow this exception. [![rule](<LINK_2>](<LINK_1></technical_language>

Target:
public AppStateClusterImpl(AppSettings appSettings) { ClusterProperties clusterProperties = new ClusterProperties(appSettings); clusterProperties.validate(); if (!clusterProperties.isEnabled()) { throw new IllegalStateException("Cluster is not enabled on this instance"); } Config hzConfig = new Config(); try { hzConfig.setInstanceName(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { } hzConfig.getGroupConfig().setName(clusterProperties.getName()); NetworkConfig netConfig = hzConfig.getNetworkConfig(); netConfig.setPort(clusterProperties.getPort()); if (!clusterProperties.getNetworkInterfaces().isEmpty()) { netConfig.getInterfaces() .setEnabled(true) .setInterfaces(clusterProperties.getNetworkInterfaces()); } JoinConfig joinConfig = netConfig.getJoin(); joinConfig.getAwsConfig().setEnabled(false); joinConfig.getMulticastConfig().setEnabled(false); joinConfig.getTcpIpConfig().setEnabled(true); joinConfig.getTcpIpConfig().setMembers(clusterProperties.getHosts()); hzConfig .setProperty("hazelcast.tcp.join.port.try.count", "10") .setProperty("hazelcast.socket.bind.any", "false") .setProperty("hazelcast.phone.home.enabled", "false") .setProperty("hazelcast.logging.type", "slf4j"); hzConfig.getPartitionGroupConfig().setEnabled(false); hzInstance = Hazelcast.newHazelcastInstance(hzConfig); operationalProcesses = hzInstance.getReplicatedMap(OPERATIONAL_PROCESSES); listenerUuid = operationalProcesses.addEntryListener(new OperationalProcessListener()); }
Source:
<code>protected void endActionOnVmConfiguration() { if (getVm() != null) { if (getVm().getstatus() == VMStatus.ImageLocked) { VmHandler.unlockVm(getVm(), getCompensationContext()); } <START> throw new RuntimeException("asd"); <END> } else { setCommandShouldBeLogged(false); log.warn("VmCommand::EndVmCommand: Vm is null - not performing EndAction on Vm"); } }</code><technical_language>Unmeaningful exception - "asd" logs :)</technical_language>

Target:
protected void endActionOnVmConfiguration() { if (getVm() != null) { if (getVm().getstatus() == VMStatus.ImageLocked) { VmHandler.unlockVm(getVm(), getCompensationContext()); } updateVmInSpm(getVm().getstorage_pool_id(), Arrays.asList(getVm())); } else { setCommandShouldBeLogged(false); log.warn("VmCommand::EndVmCommand: Vm is null - not performing EndAction on Vm"); } }
Source:
<code>public static Option commonOptions() throws Exception { return composite(karafContainer(), vmOptions("-Djava.net.preferIPv4Stack=true", "-Djgroups.bind_addr=127.0.0.1"), <START> vmOptions("-Xmx1G", "-XX:-PrintGCDetails", "-XX:-PrintGCTimeStamps"), <END> verboseKaraf(), runWithoutConsole(), junitBundles(), keepRuntimeFolder(), featurePaxUrlWrap(), bundlePaxExamSpi(), bundleTestAnnotations(), localRepoForPAXUrl()); }</code><technical_language>hmmm a bit weird - set Xmx in integrationtests/osgi/pom.xml 1GB. please why? this parametrized (e.g. pom)</technical_language>

Target:
public static Option commonOptions() throws Exception { return composite(karafContainer(), vmOptions("-Djava.net.preferIPv4Stack=true", "-Djgroups.bind_addr=127.0.0.1"), vmOptions("-Xmx500m", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=" + System.getProperty("user.dir")), verboseKaraf(), runWithoutConsole(), junitBundles(), keepRuntimeFolder(), featurePaxUrlWrap(), bundlePaxExamSpi(), bundleTestAnnotations(), localRepoForPAXUrl()); }
Source:
<code>boolean matchBean(Configuration configuration) { Filter include = configuration.getInclude(); if (!include.isEmptyBeanName() && !include.getBeanNames().contains(beanName)) { return false; } for (String bean_attr : include.keySet()) { if (EXCLUDED_BEAN_PARAMS.contains(bean_attr)) { continue; } ArrayList<String> beanValues = include.getParameterValues(bean_attr); boolean matchBeanAttr = false; for (String beanVal : beanValues) { if (beanParameters.get(bean_attr) == null || !beanParameters.get(bean_attr).equals(beanVal)) { continue; } <START> matchBeanAttr = true; <END> break; } if (!matchBeanAttr) { return false; } } return true; }</code><technical_language>return true right there</technical_language>

Target:
boolean matchBean(Configuration configuration) { Filter include = configuration.getInclude(); if (!include.isEmptyBeanName() && !include.getBeanNames().contains(beanName)) { return false; } for (String bean_attr : include.keySet()) { if (EXCLUDED_BEAN_PARAMS.contains(bean_attr)) { continue; } if (beanParameters.get(bean_attr) == null) { continue; } ArrayList<String> beanValues = include.getParameterValues(bean_attr); boolean matchBeanAttr = false; for (String beanVal : beanValues) { if (!beanParameters.get(bean_attr).equals(beanVal)) { continue; } return true; } if (!matchBeanAttr) { return false; } } return true; }
Source:
<code>public CompleteTransactionResponseMessage(CompleteTransactionMessage msg) { m_txnId = msg.getTxnId(); m_spHandle = msg.getSpHandle(); m_isRestart = msg.isRestart(); m_spiHSId = msg.getCoordinatorHSId(); <START> m_ackRequestedFromSender = msg.isAckRequestedFromSender(); <END> }</code><technical_language>get flag status CompleteTransactionMessage's "m_isForReplica"</technical_language>

Target:
public CompleteTransactionResponseMessage(CompleteTransactionMessage msg) { m_txnId = msg.getTxnId(); m_spHandle = msg.getSpHandle(); m_isRestart = msg.isRestart(); m_spiHSId = msg.getCoordinatorHSId(); m_ackRequired = msg.requiresAck(); }
Source:
<code><START> void startBootstrap() { <END> isBootstrapMode = true; }</code><technical_language>Is this method necessary? journal start in *bootstrap* mode construction</technical_language>

Target:
void startBootstrap() { inBootstrapMode = true; }
Source:
<code>public Response toResponse(NotFoundException exception) { <START> return ExceptionMapperUtils.buildResponse(exception, Response.Status.BAD_REQUEST); <END> }</code><technical_language>good Jeeva, 404 status</technical_language>

Target:
public Response toResponse(NotFoundException exception) { if (exception.getCause() instanceof NumberFormatException) { return ExceptionMapperUtils.buildResponse(exception, Response.Status.BAD_REQUEST); } else { return ExceptionMapperUtils.buildResponse(exception, Response.Status.NOT_FOUND); } }
Source:
<code>public String getPortalIP() { String tmp = asString("spec.portalIP"); <START> if (tmp == null || tmp.trim().length() == 0) { <END> tmp = getClusterIP(); } return tmp; }</code><technical_language>StringUtils.isBlank</technical_language>

Target:
public String getPortalIP() { String tmp = asString("spec.portalIP"); if (StringUtils.isBlank(tmp)) { tmp = getClusterIP(); } return tmp; }
Source:
<code>@Test public void testSimplifyCaseBranchesCollapse() { RexNode x = input(tBoolean(), 0); RexNode firstCond = isTrue(x); RexNode literal1 = literal(1); RexNode secondCond = isNotTrue(x); RexNode literal2 = literal(2); RexNode caseNode = case_(firstCond, literal1, secondCond, literal1, literal2); RexNode result = simplify.simplifyUnknownAs(caseNode, RexUnknownAs.FALSE); assertThat(result.getType().isNullable(), is(false)); assertThat(result.getType().getSqlTypeName(), is(SqlTypeName.INTEGER)); RexNode expectedResult = case_(or(x, not(x)), literal1, literal2); <START> assertThat(result.toString(), is(expectedResult.toString())); <END> }</code><technical_language>frankly speaking I prefer following: java checkSimplify3( case_( isTrue(vInt()), literal(1), isNotTrue(vInt()), literal(2), ), "...", "...", "..."); verifies (TRUE/FALSE/UNKNOWN) cases, prints more-or-less understandable messages</technical_language>

Target:
@Test public void testSimplifyCaseBranchesCollapse() { checkSimplify3( case_( isTrue(vBool()), literal(1), isNotTrue(vBool()), literal(1), literal(2)), "CASE(OR(IS TRUE(?0.bool0), IS NOT TRUE(?0.bool0)), 1, 2)", "CASE(OR(IS TRUE(?0.bool0), IS NOT TRUE(?0.bool0)), 1, 2)", "CASE(OR(IS TRUE(?0.bool0), IS NOT TRUE(?0.bool0)), 1, 2)"); }
Source:
<code>protected void doSetUserClaimValueWithID(String userID, String claimURI, String claimValue, String profileName) throws UserStoreException { try { String attributeName = getClaimAtrribute(claimURI, userID, null); Map<String, String> userStoreAttributeValueMap = new HashMap<>(); userStoreAttributeValueMap.put(attributeName, claimValue); processAttributesBeforeUpdate(userStoreAttributeValueMap); for (Map.Entry<String, String> entry : userStoreAttributeValueMap.entrySet()) { doSetUserAttributeWithID(userID, entry.getKey(), entry.getValue(), profileName); } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException( "Error occurred while getting the claim attribute for claimURI: " + claimURI + " of the user: " <START> + userID); <END> } }</code><technical_language>include 'e' in wrapped exception</technical_language>

Target:
protected void doSetUserClaimValueWithID(String userID, String claimURI, String claimValue, String profileName) throws UserStoreException { try { String attributeName = getClaimAtrribute(claimURI, userID, null); Map<String, String> userStoreAttributeValueMap = new HashMap<>(); userStoreAttributeValueMap.put(attributeName, claimValue); processAttributesBeforeUpdateWithID(userID, userStoreAttributeValueMap, profileName); for (Map.Entry<String, String> entry : userStoreAttributeValueMap.entrySet()) { doSetUserAttributeWithID(userID, entry.getKey(), entry.getValue(), profileName); } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException( "Error occurred while getting the claim attribute for claimURI: " + claimURI + " of the user: " + userID, e); } }
Source:
<code>public void testInvertMapNull() { try { MapUtils.invertMap(null); fail("Expecting NullPointerException for null map"); } catch (final NullPointerException ex) { <START> } <END> }</code><technical_language>depend JUnit 5, can/should test exceptions JUnit 5 APIs: <LINK_0></technical_language>

Target:
public void testInvertMapNull() { Map<String, String> nullMap = null; Exception exception = assertThrows(NullPointerException.class, () -> { MapUtils.invertMap(nullMap); }); String actualMessage = exception.getMessage(); assertTrue(actualMessage.contains("map")); }
Source:
<code>public String getRequestObjectListType(final String requestName) { switch(requestName) { case "get_bulk_job_spectra_s3_request": return "BULK_GET"; case "put_bulk_job_spectra_s3_request": return "BULK_PUT"; case "verify_bulk_job_spectra_s3_request": case "eject_storage_domain_spectra_s3_request": case "eject_storage_domain_blobs_spectra_s3_request": case "get_physical_placement_for_objects_spectra_s3_request": case "get_physical_placement_for_objects_with_full_details_spectra_s3_request": case "verify_physical_placement_for_objects_spectra_s3_request": case "verify_physical_placement_for_objects_with_full_details_spectra_s3_request": return "GET_PHYSICAL_PLACEMENT"; case "complete_multi_part_upload_request": return "COMPLETE_MPU"; case "put_multi_part_upload_part_request": case "put_object_request": return "DATA"; case "delete_objects_request": return "STRING_LIST"; case "get_blob_persistence_spectra_s3_request": case "replicate_put_job_spectra_s3_request": return "STRING"; default: <START> return null; <END> } }</code><technical_language>Is null expected return value, is this error state</technical_language>

Target:
public String getRequestObjectListType(final String requestName) { switch(requestName) { case "get_bulk_job_spectra_s3_request": return "BULK_GET"; case "put_bulk_job_spectra_s3_request": return "BULK_PUT"; case "verify_bulk_job_spectra_s3_request": case "eject_storage_domain_spectra_s3_request": case "eject_storage_domain_blobs_spectra_s3_request": case "get_physical_placement_for_objects_spectra_s3_request": case "get_physical_placement_for_objects_with_full_details_spectra_s3_request": case "verify_physical_placement_for_objects_spectra_s3_request": case "verify_physical_placement_for_objects_with_full_details_spectra_s3_request": return "GET_PHYSICAL_PLACEMENT"; case "complete_multi_part_upload_request": return "COMPLETE_MPU"; case "put_multi_part_upload_part_request": case "put_object_request": return "DATA"; case "delete_objects_request": return "STRING_LIST"; case "get_blob_persistence_spectra_s3_request": case "replicate_put_job_spectra_s3_request": return "STRING"; default: throw new InvalidParameterException("Unknown request:" + requestName); } }
Source:
<code>void testDeleteBranch() { deleteBranchPort.delete( <START> projectId, new Branch("testBranch2", "fcd9a0e7c34086fdb0aedc82497f8ddfa142e961")); <END> Assertions.assertThat(listBranchesPort.listBranchesInProject(projectId)) .containsExactlyInAnyOrder( new Branch("testBranch1", "d3272b3793bc4b2bc36a1a3a7c8293fcf8fe27df"), new Branch("master", "e9f7ff6fdd8c0863fdb5b24c9ed35a3651e20382")); Assertions.assertThat(commitRepository.findByProjectId(projectId)).hasSize(14); Assertions.assertThat(fileRepository.findAllinProject(projectId)).hasSize(8); }</code><technical_language>Create a member for branch objects</technical_language>

Target:
void testDeleteBranch() { deleteBranchPort.delete(projectId, testBranch2); Assertions.assertThat(listBranchesPort.listBranchesInProject(projectId)) .containsExactlyInAnyOrder(testBranch1, master); Assertions.assertThat(commitRepository.findByProjectId(projectId)).hasSize(14); Assertions.assertThat(fileRepository.findAllinProject(projectId)).hasSize(8); }
Source:
<code>public byte[] readRound(long seq) throws IOException { lock.readLock().lock(); try { byte[] result = currentLog.readRound(seq); <START> if (firstEntry.isDone() && Futures.getUnchecked(firstEntry) <= seq) { <END> byte[] experimentalResult = safeReadFromExperimental(psl -> psl.readRound(seq)); if (!Arrays.equals(result, experimentalResult)) { log.error("Mismatch in reading round for sequence number between legacy and current " + "implementations. Legacy result {}, current result {}.", SafeArg.of("sequence", seq), UnsafeArg.of("legacy", hydrateIfNotNull(result)), UnsafeArg.of("current", hydrateIfNotNull(experimentalResult))); } } return result; } finally { lock.readLock().unlock(); } }</code><technical_language>In hindsight, a suggestion @j-baker, worth this check actually, this a good test a hypothesis entries important. worth keeping track of entry dumping arg in result</technical_language>

Target:
public byte[] readRound(long seq) throws IOException { lock.readLock().lock(); try { byte[] result = currentLog.readRound(seq); byte[] experimentalResult = safeReadFromExperimental(psl -> psl.readRound(seq)); OptionalLong firstWrittenSequence = firstEntry.isDone() ? OptionalLong.of(Futures.getUnchecked(firstEntry)) : OptionalLong.empty(); if (!Arrays.equals(result, experimentalResult)) { log.error("Mismatch in reading round for sequence number between legacy and current implementations." + " Legacy result {}, current result {}. First written sequence was {}.", SafeArg.of("sequence", seq), UnsafeArg.of("legacy", hydrateIfNotNull(result)), UnsafeArg.of("current", hydrateIfNotNull(experimentalResult)), SafeArg.of("firstWrittenSequence", firstWrittenSequence)); } return result; } finally { lock.readLock().unlock(); } }
Source:
<code>public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { <START> if (capability == CapabilityEnergy.ENERGY) { <END> return (T) energyInterface; } if (capability != null && (capability == MJ_CONN || capability == MJ_RECV)) { return (T) mjReceiver; } return super.getCapability(capability, facing); }</code><technical_language>is bad check if null equals of fields</technical_language>

Target:
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { if (capability == CapabilityEnergy.ENERGY) { return (T) energyInterface; } if (capability == MJ_CONN || capability == MJ_RECV) { return (T) mjReceiver; } return super.getCapability(capability, facing); }
Source:
<code>private MessageProducerNode producerNode(String name, MessageProducerSupport producer) { MessageChannel outputChannel = producer.getOutputChannel(); <START> String outputChannelName = outputChannel == null ? "__unknown__" : outputChannel.toString(); <END> return new MessageProducerNode(this.nodeId.incrementAndGet(), name, producer, outputChannelName); }</code><technical_language>Is good this weird placeholder? I thought agreed MessageProducerSupport.afterSingletonsInstantiated() fixes problem null anymore</technical_language>

Target:
private MessageProducerNode producerNode(String name, MessageProducerSupport producer) { MessageChannel outputChannel = producer.getOutputChannel(); return new MessageProducerNode(this.nodeId.incrementAndGet(), name, producer, outputChannel.toString()); }
Source:
<code>public AsyncHttpClient get() { ApacheHttpClient httpClient; try { HttpClientConfig config = injector.getInstance(Key.get(HttpClientConfig.class, annotation)); httpClient = new ApacheHttpClient(config); } catch (IOException e) { throw Throwables.propagate(e); } AsyncHttpClientConfig asyncConfig = injector.getInstance(Key.get(AsyncHttpClientConfig.class, annotation)); <START> ExecutorService executor = newFixedThreadPool(asyncConfig.getWorkerThreads(), new ThreadFactoryBuilder().setNameFormat(name + "-http-client-%s").build()); <END> return new AsyncHttpClient(httpClient, executor); }</code><technical_language>shut this executor</technical_language>

Target:
public AsyncHttpClient get() { ExecutorService executorService = injector.getInstance(Key.get(ExecutorService.class, annotation)); ApacheHttpClient httpClient; try { HttpClientConfig config = injector.getInstance(Key.get(HttpClientConfig.class, annotation)); httpClient = new ApacheHttpClient(config); } catch (IOException e) { throw Throwables.propagate(e); } return new AsyncHttpClient(httpClient, executorService); }
Source:
<code>public void vdsNonOperational(Guid vdsId, NonOperationalReason reason, boolean logCommand, Guid domainId) { StorageDomainStatic storageDomain = DbFacade.getInstance().getStorageDomainStaticDao().get(domainId); Map<String, String> customLogValues = null; if (storageDomain != null) { customLogValues = new HashMap<>(); <START> customLogValues.put("StorageDomainNames", storageDomain.getName()); <END> } vdsNonOperational(vdsId, reason, logCommand, domainId, customLogValues); }</code><technical_language>Collections.singletonMap</technical_language>

Target:
public void vdsNonOperational(Guid vdsId, NonOperationalReason reason, boolean logCommand, Guid domainId) { StorageDomainStatic storageDomain = DbFacade.getInstance().getStorageDomainStaticDao().get(domainId); Map<String, String> customLogValues = null; if (storageDomain != null) { customLogValues = Collections.singletonMap("StorageDomainNames", storageDomain.getName()); } vdsNonOperational(vdsId, reason, logCommand, domainId, customLogValues); }
Source:
<code>public static Callable<ThrottlingState> createThrottlingState( int timeBucketCapacityInSeconds, int timeBucketRefillAmountInSeconds, int timeBucketRefillPeriodInMinutes, int errorBucketCapacity, int errorBucketRefillAmount, int errorBucketRefillPeriodInMinutes) { return () -> new ThrottlingState( TokenBuckets.builder() .withCapacity(MILLISECONDS.convert(timeBucketCapacityInSeconds, TimeUnit.SECONDS)) <START> .withFixedIntervalRefillStrategy(timeBucketRefillAmountInSeconds, timeBucketRefillPeriodInMinutes, <END> MINUTES) .build(), TokenBuckets.builder() .withCapacity(errorBucketCapacity) .withFixedIntervalRefillStrategy(errorBucketRefillAmount, errorBucketRefillPeriodInMinutes, MINUTES) .build()); }</code><technical_language>this is in seconds? Capacity in milliseconds</technical_language>

Target:
public static Callable<ThrottlingState> createThrottlingState( int timeBucketCapacityInSeconds, int timeBucketRefillAmountInSeconds, int timeBucketRefillPeriodInMinutes, int errorBucketCapacity, int errorBucketRefillAmount, int errorBucketRefillPeriodInMinutes) { return () -> new ThrottlingState( TokenBuckets.builder() .withCapacity( MILLISECONDS.convert(timeBucketCapacityInSeconds, TimeUnit.SECONDS)) .withFixedIntervalRefillStrategy( MILLISECONDS.convert(timeBucketRefillAmountInSeconds, TimeUnit.SECONDS), timeBucketRefillPeriodInMinutes, MINUTES) .build(), TokenBuckets.builder() .withCapacity(errorBucketCapacity) .withFixedIntervalRefillStrategy( errorBucketRefillAmount, errorBucketRefillPeriodInMinutes, MINUTES) .build()); }
Source:
<code>public void isolation_01() { DatasetGraph dsg = create() ; ThreadAction other = ThreadTxn.threadTxnRead(dsg, ()-> { long x = Iter.count(dsg.find()) ; <START> Assert.assertEquals(0, x) ; <END> }) ; dsg.begin(WRITE) ; dsg.add(q1) ; dsg.commit() ; dsg.end() ; other.run() ; }</code><technical_language>ThreadAction other = ThreadTxn.threadTxnRead(dsg, () -> Assert.assertTrue(dsg.isEmpty())); is a clearer</technical_language>

Target:
public void isolation_01() { DatasetGraph dsg = create() ; ThreadAction other = ThreadTxn.threadTxnRead(dsg, ()-> Assert.assertTrue(dsg.isEmpty()) ) ; dsg.begin(WRITE) ; dsg.add(q1) ; dsg.commit() ; dsg.end() ; other.run() ; }
Source:
<code>private <T> void deleteEntries( final InternalDataAdapter<T> adapter, final Index index, final String... additionalAuthorizations ) throws IOException { statisticsStore.removeAllStatistics( adapter.getAdapterId(), additionalAuthorizations); baseOperations.deleteAll( index.getName(), <START> "", <END> adapter.getAdapterId(), additionalAuthorizations); }</code><technical_language>this line stay</technical_language>

Target:
private <T> void deleteEntries( final InternalDataAdapter<T> adapter, final Index index, final String... additionalAuthorizations ) throws IOException { statisticsStore.removeAllStatistics( adapter.getAdapterId(), additionalAuthorizations); baseOperations.deleteAll( index.getName(), adapter.getTypeName(), adapter.getAdapterId(), additionalAuthorizations); }
Source:
<code><START> default boolean gravity() { <END> return get(Keys.ENTITY_HAS_GRAVITY).get(); }</code><technical_language><LINK_0></technical_language>

Target:
default Value<Boolean> gravity() { return getValue(Keys.HAS_GRAVITY).get(); }
Source:
<code>private Set<LocalizedTitle> transformLocalizedTitles( Set<org.atlasapi.media.entity.simple.LocalizedTitle> titles ) { Set<LocalizedTitle> newTitles = titles.stream() .map(title -> makeNewTitle(title)) .collect(Collectors.toSet()); <START> return ImmutableSet.<LocalizedTitle>copyOf(newTitles); <END> }</code><technical_language>return titles.stream()...collect(MoreCollectors.toImmutableSet());</technical_language>

Target:
private Set<LocalizedTitle> transformLocalizedTitles( Set<org.atlasapi.media.entity.simple.LocalizedTitle> titles ) { return titles.stream() .map(title -> makeNewTitle(title)) .collect(MoreCollectors.toImmutableSet()); }
Source:
<code>public static void setRanges(Class<?> implementingClass, Configuration conf, Collection<Range> ranges) { checkArgument(ranges != null, "ranges is null"); ArrayList<String> rangeStrings = new ArrayList<>(ranges.size()); try { for (Range r : ranges) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); r.write(new DataOutputStream(baos)); rangeStrings.add(Base64.getEncoder().encodeToString(baos.toByteArray())); } conf.setStrings(enumToConfKey(implementingClass, ScanOpts.RANGES), rangeStrings.toArray(new String[0])); } catch (IOException ex) { <START> throw new UncheckedIOException("Unable to encode ranges to Base64", ex); <END> } }</code><technical_language>This is illegal argument. This is user-facing API, IOException is incidental implementation. user-facing exception IAE</technical_language>

Target:
public static void setRanges(Class<?> implementingClass, Configuration conf, Collection<Range> ranges) { checkArgument(ranges != null, "ranges is null"); ArrayList<String> rangeStrings = new ArrayList<>(ranges.size()); try { for (Range r : ranges) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); r.write(new DataOutputStream(baos)); rangeStrings.add(Base64.getEncoder().encodeToString(baos.toByteArray())); } conf.setStrings(enumToConfKey(implementingClass, ScanOpts.RANGES), rangeStrings.toArray(new String[0])); } catch (IOException ex) { throw new IllegalArgumentException("Unable to encode ranges to Base64", ex); } }
Source:
<code>public void shouldSetValuesOnPublicSetter() throws Exception { when(resultSetMetaData.getColumnCount()).thenReturn(1); when(resultSetMetaData.getColumnLabel(1)).thenReturn("longField"); Long expected = 1L; when(resultSet.getLong(1)).thenReturn(expected); when(resultSet.wasNull()).thenReturn(false); SampleBean sampleBean = mapper.map(resultSet, ctx); <START> assertThat(sampleBean.getLongField()).isNotNull(); <END> }</code><technical_language>isEqualTo(expected)</technical_language>

Target:
public void shouldSetValuesOnPublicSetter() throws Exception { when(resultSetMetaData.getColumnCount()).thenReturn(1); when(resultSetMetaData.getColumnLabel(1)).thenReturn("longField"); Long expected = 1L; when(resultSet.getLong(1)).thenReturn(expected); when(resultSet.wasNull()).thenReturn(false); SampleBean sampleBean = mapper.map(resultSet, ctx); assertThat(sampleBean.getLongField()).isEqualTo(expected); }
Source:
<code>public static long parseMemString(String strMemSize) { if (strMemSize == null) { return 0L; } long size = 0L; if (strMemSize.endsWith("g") || strMemSize.endsWith("G") || strMemSize.endsWith("m") || strMemSize.endsWith("M") || strMemSize.endsWith("k") || strMemSize.endsWith("K")) { String strSize = strMemSize.substring(0, strMemSize.length() - 1); size = Long.parseLong(strSize); } else { size = Long.parseLong(strMemSize); } long sizeInKb = 0L; <START> if (strMemSize.endsWith("g") || strMemSize.endsWith("G")) { <END> sizeInKb = size * 1024L * 1024L; } else if (strMemSize.endsWith("m") || strMemSize.endsWith("M")) { sizeInKb = size * 1024L; } else { sizeInKb = size / 1024L; } return sizeInKb; }</code><technical_language>this part need handle "strMemSize.endsWith("k")" well</technical_language>

Target:
public static long parseMemString(String strMemSize) { if (strMemSize == null) { return 0L; } long size = 0L; if (strMemSize.endsWith("g") || strMemSize.endsWith("G") || strMemSize.endsWith("m") || strMemSize.endsWith("M") || strMemSize.endsWith("k") || strMemSize.endsWith("K")) { String strSize = strMemSize.substring(0, strMemSize.length() - 1); size = Long.parseLong(strSize); } else { size = Long.parseLong(strMemSize); } long sizeInKb = 0L; if (strMemSize.endsWith("g") || strMemSize.endsWith("G")) { sizeInKb = size * 1024L * 1024L; } else if (strMemSize.endsWith("m") || strMemSize.endsWith("M")) { sizeInKb = size * 1024L; } else if (strMemSize.endsWith("k") || strMemSize.endsWith("K")) { sizeInKb = size; } else { sizeInKb = size / 1024L; } return sizeInKb; }
Source:
<code>private void scanDirectory(File entryDirectory, ImmutableList.Builder<ScanResult> results) throws IOException { File beansXmlFile = new File(entryDirectory, AbstractWeldDeployment.BEANS_XML); if (beansXmlFile.canRead()) { logger.debugv(BEANS_XML_FOUND_MESSAGE, entryDirectory); final BeansXml beansXml = parseBeansXml(beansXmlFile.toURI().toURL()); if (accept(beansXml)) { results.add(new ScanResult(beansXml, entryDirectory.getPath())); } } else { logger.debugv(BEANS_XML_NOT_FOUND_MESSAGE, entryDirectory); File extensionFile = new File(entryDirectory, EXTENSION_FILE); if (!extensionFile.canRead()) { results.add(new ScanResult(null, entryDirectory.getPath())); } } File manifestFile = new File(entryDirectory, MANIFEST_FILE); if (manifestFile.canRead()) { <START> final Manifest manifest = new Manifest(new FileInputStream(manifestFile)); <END> final Attributes manifestMainAttributes = manifest.getMainAttributes(); if (manifestMainAttributes.containsKey(CLASS_PATH)) { scanManifestClassPath(entryDirectory.toURI().toURL(), manifestMainAttributes.getValue(CLASS_PATH), results); } } }</code><technical_language>closing FileInputStream</technical_language>

Target:
private void scanDirectory(File entryDirectory, ImmutableList.Builder<ScanResult> results) throws IOException { File beansXmlFile = new File(entryDirectory, AbstractWeldDeployment.BEANS_XML); if (beansXmlFile.canRead()) { logger.debugv(BEANS_XML_FOUND_MESSAGE, entryDirectory); final BeansXml beansXml = parseBeansXml(beansXmlFile.toURI().toURL()); if (accept(beansXml)) { results.add(new ScanResult(beansXml, entryDirectory.getPath())); } } else { logger.debugv(BEANS_XML_NOT_FOUND_MESSAGE, entryDirectory); File extensionFile = new File(entryDirectory, EXTENSION_FILE); if (!extensionFile.canRead()) { results.add(new ScanResult(null, entryDirectory.getPath())); } } File manifestFile = new File(entryDirectory, MANIFEST_FILE); if (manifestFile.canRead()) { try (FileInputStream fis = new FileInputStream(manifestFile)) { final Manifest manifest = new Manifest(fis); final Attributes manifestMainAttributes = manifest.getMainAttributes(); if (manifestMainAttributes.containsKey(CLASS_PATH)) { scanManifestClassPath(entryDirectory.toURI().toURL(), manifestMainAttributes.getValue(CLASS_PATH), results); } } } }
Source:
<code>public static String describe() { return String.format("Java : %s\n" + "JVM vendor name : %s\n" + "JVM vendor version : %s\n" + "JVM name : %s\n" + "JVM version : %s\n" + "JVM info : %s\n" + "OS name : %s\n" + "OS version : %s\n" , JAVA_VERSION, JVM_VENDOR, JVM_VENDOR_VERSION, JVM_NAME, JVM_VERSION, JVM_INFO, <START> System.getProperty("os.name"), <END> System.getProperty("os.version")); }</code><technical_language>consistent, constant Strings too</technical_language>

Target:
public static String describe() { return String.format("Java : %s\n" + "JVM vendor name : %s\n" + "JVM vendor version : %s\n" + "JVM name : %s\n" + "JVM version : %s\n" + "JVM info : %s\n" + "OS name : %s\n" + "OS version : %s\n", JAVA_VERSION, JVM_VENDOR, JVM_VENDOR_VERSION, JVM_NAME, JVM_VERSION, JVM_INFO, OS_NAME, OS_VERSION); }
Source:
<code>private void testActionWithBlobKeySuccess() { ______TS("Typical case: Success scenario"); loginAsStudent(account.googleId); String[] submissionParams = new String[] { Const.ParamsNames.STUDENT_ID, studentProfileAttributes.googleId, Const.ParamsNames.BLOB_KEY, studentProfileAttributes.pictureKey, }; DeleteStudentProfilePictureAction action = getAction(submissionParams); JsonResult result = getJsonResult(action); MessageOutput messageOutput = (MessageOutput) result.getOutput(); <START> assertEquals(HttpStatus.SC_OK, result.getStatusCode()); <END> assertEquals(messageOutput.getMessage(), "Your profile picture has been deleted successfully"); }</code><technical_language>Insufficient check. confirm picture is deleted</technical_language>

Target:
private void testActionWithBlobKeySuccess() { ______TS("Typical case: success scenario"); loginAsStudent(account.googleId); String[] submissionParams = { Const.ParamsNames.STUDENT_ID, account.googleId, }; DeleteStudentProfilePictureAction action = getAction(submissionParams); JsonResult result = getJsonResult(action); MessageOutput messageOutput = (MessageOutput) result.getOutput(); String newPictureKey = logic.getStudentProfile(account.googleId).pictureKey; assertEquals(HttpStatus.SC_OK, result.getStatusCode()); assertEquals(messageOutput.getMessage(), "Your profile picture has been deleted successfully"); assertEquals("", newPictureKey); }
Source:
<code><START> @Override public String toString() { <END> return "RecordExpectation{" + "acceptedDelta=" + acceptedDelta + ", doubleExpectation=" + doubleExpectation + ", editorExpectation='" + editorExpectation + '\'' + ", expectedFieldType=" + expectedFieldType + ", fieldName='" + fieldName + '\'' + ", intExpectation=" + intExpectation + ", stringExpectation='" + stringExpectation + '\'' + ", stringExpectationInCSV=" + stringExpectationInCSV + ", editorStringExpectation=" + editorStringExpectation + '}'; }</code><technical_language>I prefer annotations line above. write elsewhere</technical_language>

Target:
public String toString() { return "RecordExpectation{" + "acceptedDelta=" + acceptedDelta + ", doubleExpectation=" + doubleExpectation + ", editorExpectation='" + editorExpectation + '\'' + ", expectedFieldType=" + expectedFieldType + ", fieldName='" + fieldName + '\'' + ", intExpectation=" + intExpectation + ", stringExpectation='" + stringExpectation + '\'' + ", stringExpectationInCSV=" + stringExpectationInCSV + ", editorStringExpectation=" + editorStringExpectation + '}'; }
Source:
<code>public void receiveRequest(final Request request, final EndpointReceiver receiver) { final KeyMID idByMID = new KeyMID(request.getMID(), endpointContextMatcher.getEndpointIdentity(request.getSourceContext())); final Exchange exchange = new Exchange(request, Origin.REMOTE, executor); final Exchange previous = exchangeStore.findPrevious(idByMID, exchange); boolean duplicate = previous != null; if (duplicate) { EndpointContext sourceContext = request.getSourceContext(); Request previousRequest = previous.getRequest(); EndpointContext previousSourceContext = previousRequest.getSourceContext(); duplicate = endpointContextMatcher.isToBeSent(previousSourceContext, sourceContext); if (!duplicate) { if (!exchangeStore.replacePrevious(idByMID, previous, exchange)) { <START> LOGGER.warn("new request could not be registered!", request); <END> } } } if (duplicate) { LOGGER.trace("duplicate request: {}", request); request.setDuplicate(true); previous.execute(new Runnable() { @Override public void run() { try { receiver.receiveRequest(previous, request); } catch (RuntimeException ex) { LOGGER.warn("error receiving request again!", request, ex); receiver.reject(request); } } }); } else { exchange.setRemoveHandler(exchangeRemoveHandler); exchange.execute(new Runnable() { @Override public void run() { try { receiver.receiveRequest(exchange, request); } catch (RuntimeException ex) { LOGGER.warn("error receiving request {}", request, ex); receiver.reject(request); } } }); } }</code><technical_language>add a log successful replacement new request</technical_language>

Target:
public void receiveRequest(final Request request, final EndpointReceiver receiver) { final KeyMID idByMID = new KeyMID(request.getMID(), endpointContextMatcher.getEndpointIdentity(request.getSourceContext())); final Exchange exchange = new Exchange(request, Origin.REMOTE, executor); final Exchange previous = exchangeStore.findPrevious(idByMID, exchange); boolean duplicate = previous != null; if (duplicate) { EndpointContext sourceContext = request.getSourceContext(); Request previousRequest = previous.getRequest(); EndpointContext previousSourceContext = previousRequest.getSourceContext(); duplicate = endpointContextMatcher.isToBeSent(previousSourceContext, sourceContext); if (!duplicate) { if (exchangeStore.replacePrevious(idByMID, previous, exchange)) { LOGGER.debug("replaced request by new request {}!", previous.getCurrentRequest(), request); } else { LOGGER.warn("new request could not be registered! Deduplication disabled!", request); } } } if (duplicate) { LOGGER.trace("duplicate request: {}", request); request.setDuplicate(true); previous.execute(new Runnable() { @Override public void run() { try { receiver.receiveRequest(previous, request); } catch (RuntimeException ex) { LOGGER.warn("error receiving request again!", request, ex); receiver.reject(request); } } }); } else { exchange.setRemoveHandler(exchangeRemoveHandler); exchange.execute(new Runnable() { @Override public void run() { try { receiver.receiveRequest(exchange, request); } catch (RuntimeException ex) { LOGGER.warn("error receiving request {}", request, ex); receiver.reject(request); } } }); } }
Source:
<code>public void unsync(ServoControl sc) { this.removeServoEventListener(this); <START> sc.detach(sc); <END> unsubscribe(sc.getName(), "publishServoEvent", getName(), "moveTo"); }</code><technical_language>removeEventListener handled in detach method</technical_language>

Target:
public void unsync(ServoControl sc) { this.removeServoEventListener(this); ((Servo) sc).removeServoEventListener((NameProvider) sc); unsubscribe(sc.getName(), "publishServoEvent", getName(), "moveTo"); }
Source:
<code>public Response addService(@PathParam("clusterId") Long clusterId, Service service) { service.setClusterId(clusterId); try { Cluster cluster = catalogService.getCluster(clusterId); if (cluster == null) { return WSUtils.respond(NOT_FOUND, ENTITY_NOT_FOUND, "cluster: " + clusterId.toString()); } String serviceName = service.getName(); Service result = catalogService.getServiceByName(clusterId, serviceName); if (result != null) { <START> throw new AlreadyExistsException("Service entity already exists with cluster id " + <END> clusterId + " and name " + serviceName); } Service createdService = catalogService.addService(service); return WSUtils.respond(CREATED, SUCCESS, createdService); } catch (ProcessingException ex) { return WSUtils.respond(BAD_REQUEST, ResponseMessage.BAD_REQUEST); } catch (Exception ex) { return WSUtils.respond(INTERNAL_SERVER_ERROR, EXCEPTION, ex.getMessage()); } }</code><technical_language>for cluster id ... service + serviceName</technical_language>

Target:
public Response addService(@PathParam("clusterId") Long clusterId, Service service) { service.setClusterId(clusterId); try { Cluster cluster = catalogService.getCluster(clusterId); if (cluster == null) { return WSUtils.respond(NOT_FOUND, ENTITY_NOT_FOUND, "cluster: " + clusterId.toString()); } String serviceName = service.getName(); Service result = catalogService.getServiceByName(clusterId, serviceName); if (result != null) { throw new AlreadyExistsException("Service entity already exists with cluster id " + clusterId + " and service name " + serviceName); } Service createdService = catalogService.addService(service); return WSUtils.respond(createdService, CREATED, SUCCESS); } catch (ProcessingException ex) { return WSUtils.respond(BAD_REQUEST, ResponseMessage.BAD_REQUEST); } catch (Exception ex) { return WSUtils.respond(INTERNAL_SERVER_ERROR, EXCEPTION, ex.getMessage()); } }
Source:
<code>private boolean sendEmail(String courseId, String studentEmail) { try { EmailWrapper email = new EmailGenerator().generateFeedbackSessionSummaryOfCourse(courseId, studentEmail); emailSender.sendEmail(email); return true; <START> } catch (Exception e) { <END> log.severe("Error while sending session summary email" + TeammatesException.toStringWithStackTrace(e)); return false; } }</code><technical_language>emailSender.sendEmail method throws exceptions upwards. returns EmailSendingStatus object checked if email successfully. exception catch</technical_language>

Target:
private boolean sendEmail(String courseId, String studentEmail) { EmailWrapper email = new EmailGenerator().generateFeedbackSessionSummaryOfCourse(courseId, studentEmail); EmailSendingStatus status = emailSender.sendEmail(email); return status.isSuccess(); }
Source:
<code>public void onFailure(final String errorMessage) { messageBusPromise.then(new Operation<MessageBus>() { @Override public void apply(MessageBus messageBus) throws OperationException { try { messageBus.unsubscribe(wsChannel, subscriptionHandler); } catch (WebSocketException e) { Log.error(getClass(), e); } notification.setStatus(Notification.Status.FINISHED); <START> notification.setType(Notification.Type.ERROR); <END> notification.setImportant(true); notification.setMessage(errorMessage); } }).catchError(promiseErrorHandler); }</code><technical_language>I truth i in this case set notification type setting notification status, FINISHED trigger for notification progress stop</technical_language>

Target:
public void onFailure(final String errorMessage) { messageBusPromise.then(new Operation<MessageBus>() { @Override public void apply(MessageBus messageBus) throws OperationException { try { messageBus.unsubscribe(wsChannel, subscriptionHandler); } catch (WebSocketException e) { Log.error(getClass(), e); } notification.setType(Notification.Type.ERROR); notification.setStatus(Notification.Status.FINISHED); notification.setImportant(true); notification.setMessage(errorMessage); } }).catchError(logErrorHandler); }
Source:
<code>public static boolean isRegionReplicaReplicationEnabled(Configuration conf, TableName tn) { return isMetaRegionReplicaReplicationEnabled(conf, tn) || <START> conf.getBoolean(REGION_REPLICA_REPLICATION_CONF_KEY, DEFAULT_REGION_REPLICA_REPLICATION); <END> }</code><technical_language>Nit: another utility method of conf.getBoolean(REGION_REPLICA_REPLICATION_CONF_KEY, DEFAULT_REGION_REPLICA_REPLICATION) is isUserRegionReplicaReplicationEnabled(***)? easy read</technical_language>

Target:
public static boolean isRegionReplicaReplicationEnabled(Configuration conf, TableName tn) { return isMetaRegionReplicaReplicationEnabled(conf, tn) || isRegionReplicaReplicationEnabled(conf); }
Source:
<code>public ZoneGroupsNameAndIDMap(final int zoneID, final String zoneName, JsonArray groups) { this.zoneID = zoneID; this.zoneName = zoneName; <START> HashMap<Short, String> groupIdNames = new HashMap<Short, String>(groups.size()); <END> HashMap<String, Short> groupNameIds = new HashMap<String, Short>(groups.size()); for (int k = 0; k < groups.size(); k++) { short groupID = ((JsonObject) groups.get(k)).get("group").getAsShort(); String groupName = ((JsonObject) groups.get(k)).get("name").getAsString(); groupIdNames.put(groupID, groupName); groupNameIds.put(groupName, groupID); } this.groupIdNames = groupIdNames; this.groupNameIds = groupNameIds; }</code><technical_language>Java 8 diamond operator Java 7</technical_language>

Target:
public ZoneGroupsNameAndIDMap(final int zoneID, final String zoneName, JsonArray groups) { this.zoneID = zoneID; this.zoneName = zoneName; groupIdNames = new HashMap<>(groups.size()); groupNameIds = new HashMap<>(groups.size()); for (int k = 0; k < groups.size(); k++) { short groupID = ((JsonObject) groups.get(k)).get("group").getAsShort(); String groupName = ((JsonObject) groups.get(k)).get("name").getAsString(); groupIdNames.put(groupID, groupName); groupNameIds.put(groupName, groupID); } }