auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Host addHost(PerunSession sess, Host host, Facility facility) throws InternalErrorException, FacilityNotExistsException, PrivilegeException { Utils.checkPerunSession(sess); getFacilitiesManagerBl().checkFacilityExists(sess, facility); if (!AuthzResolver.isAuthorized(sess, Role.FACILITYADMIN, facility)) { throw new PrivilegeException(sess, "addHost"); } Utils.notNull(host, "hosts"); List<Facility> facilitiesByHostname = getFacilitiesManagerBl().getFacilitiesByHostName(sess, host.getHostname()); List<Facility> facilitiesByDestination = getFacilitiesByDestination(sess, host.getHostname()); if(facilitiesByHostname.isEmpty() && facilitiesByDestination.isEmpty()) { return getFacilitiesManagerBl().addHost(sess, host, facility); } if(!facilitiesByHostname.isEmpty()) { boolean hasRight = false; for(Facility f: facilitiesByHostname) { if(AuthzResolver.isAuthorized(sess, Role.FACILITYADMIN, f)) { hasRight = true; break; } } if(hasRight) return getFacilitiesManagerBl().addHost(sess, host, facility); } if(!facilitiesByDestination.isEmpty()) { boolean hasRight = false; for(Facility f: facilitiesByDestination) { if(AuthzResolver.isAuthorized(sess, Role.FACILITYADMIN, f)) { hasRight = true; break; } } if(hasRight) return getFacilitiesManagerBl().addHost(sess, host, facility); } <START> throw new PrivilegeException(sess, "You can't add this host."); <END> }</code><technical_language>Add problematic host exception add reason can't. privilages this hostName</technical_language>

Target:
public Host addHost(PerunSession sess, Host host, Facility facility) throws InternalErrorException, FacilityNotExistsException, PrivilegeException { Utils.checkPerunSession(sess); getFacilitiesManagerBl().checkFacilityExists(sess, facility); if (!AuthzResolver.isAuthorized(sess, Role.FACILITYADMIN, facility)) { throw new PrivilegeException(sess, "addHost"); } Utils.notNull(host, "hosts"); List<Facility> facilitiesByHostname = getFacilitiesManagerBl().getFacilitiesByHostName(sess, host.getHostname()); List<Facility> facilitiesByDestination = getFacilitiesByDestination(sess, host.getHostname()); if(facilitiesByHostname.isEmpty() && facilitiesByDestination.isEmpty()) { return getFacilitiesManagerBl().addHost(sess, host, facility); } if(!facilitiesByHostname.isEmpty()) { boolean hasRight = false; for(Facility f: facilitiesByHostname) { if(AuthzResolver.isAuthorized(sess, Role.FACILITYADMIN, f)) { hasRight = true; break; } } if(hasRight) return getFacilitiesManagerBl().addHost(sess, host, facility); } if(!facilitiesByDestination.isEmpty()) { boolean hasRight = false; for(Facility f: facilitiesByDestination) { if(AuthzResolver.isAuthorized(sess, Role.FACILITYADMIN, f)) { hasRight = true; break; } } if(hasRight) return getFacilitiesManagerBl().addHost(sess, host, facility); } throw new PrivilegeException(sess, "You can't add host " + host + ", because you don't have privileges to use this hostName"); }
Source:
<code><START> public void logMessage(Guid clusterId, GlusterVolumeEntity volume, final String action, final String status, AuditLogType logType) { <END> logUtil.logAuditMessage(clusterId, volume, null, logType, new HashMap<String, String>(){ { put("action", action); put("status", status); }}); }</code><technical_language>this need public</technical_language>

Target:
private void logMessage(Guid clusterId, GlusterVolumeEntity volume, final String action, final String status, AuditLogType logType) { logUtil.logAuditMessage(clusterId, volume, null, logType, new HashMap<String, String>(){ { put("action", action); put("status", status); }}); }
Source:
<code>public void main(Args args) { for (Arg param : params) { param.defaultValue.ifPresent(def -> args.setIfAbsent(param.name, def)); } Optional<String> headOpt = args.head(); if (headOpt.isPresent()) { String head = headOpt.get(); if (head.equals("help")) { <START> LOG.info(helpMessage()); <END> return; } if (subCommands.containsKey(head)) { subCommands.get(head).main(args.tail()); return; } } ensureArgs(args); Runnable runnable = () -> entryPoint.accept(args); runnable.run(); }</code><technical_language>I idea cmd interface is print want, want logger here</technical_language>

Target:
public void main(Args args) { for (Arg param : params) { param.defaultValue.ifPresent(def -> args.setIfAbsent(param.name, def)); } Optional<String> headOpt = args.head(); if (headOpt.isPresent()) { String head = headOpt.get(); if (head.equals("help")) { System.out.println(helpMessage()); return; } if (subCommands.containsKey(head)) { subCommands.get(head).main(args.tail()); return; } } ensureArgs(args); Runnable runnable = () -> entryPoint.accept(args); runnable.run(); }
Source:
<code>public void interleavedOperationsTest() throws Exception { List<OperationChain> opChains = new ArrayList<>(); for (int i = 0; i < 20; i++) { Queue<OperationType> operations = new LinkedList<>(); switch (i % 3) { case 0: operations.add(OperationType.PUT_NB); operations.add(OperationType.AWAIT_CREATION); operations.add(OperationType.GET_NB); operations.add(OperationType.GET_INFO_NB); operations.add(OperationType.DELETE_NB); operations.add(OperationType.AWAIT_DELETION); operations.add(OperationType.GET_DELETED_NB); operations.add(OperationType.GET_INFO_DELETED_NB); break; case 1: operations.add(OperationType.PUT_NB); operations.add(OperationType.AWAIT_CREATION); operations.add(OperationType.DELETE_NB); operations.add(OperationType.AWAIT_DELETION); operations.add(OperationType.GET_DELETED_NB); operations.add(OperationType.GET_INFO_DELETED_NB); operations.add(OperationType.GET_DELETED_NB); operations.add(OperationType.GET_INFO_DELETED_NB); break; case 2: operations.add(OperationType.PUT_NB); operations.add(OperationType.AWAIT_CREATION); operations.add(OperationType.GET_NB); operations.add(OperationType.GET_NB); operations.add(OperationType.GET_NB); operations.add(OperationType.GET_INFO_NB); break; } <START> opChains.add(testFramework.startOperationChain(32 * 1024, i, operations)); <END> } testFramework.checkOperationChains(opChains); }</code><technical_language>I this defined a constant (maybe randomize runs?)</technical_language>

Target:
public void interleavedOperationsTest() throws Exception { List<OperationChain> opChains = new ArrayList<>(); Random random = new Random(); for (int i = 0; i < 20; i++) { Queue<OperationType> operations = new LinkedList<>(); switch (i % 3) { case 0: operations.add(OperationType.PUT_NB); operations.add(OperationType.AWAIT_CREATION); operations.add(OperationType.GET_NB); operations.add(OperationType.GET_INFO_NB); operations.add(OperationType.DELETE_NB); operations.add(OperationType.AWAIT_DELETION); operations.add(OperationType.GET_DELETED_NB); operations.add(OperationType.GET_INFO_DELETED_NB); break; case 1: operations.add(OperationType.PUT_NB); operations.add(OperationType.AWAIT_CREATION); operations.add(OperationType.DELETE_NB); operations.add(OperationType.AWAIT_DELETION); operations.add(OperationType.GET_DELETED_NB); operations.add(OperationType.GET_INFO_DELETED_NB); operations.add(OperationType.GET_DELETED_NB); operations.add(OperationType.GET_INFO_DELETED_NB); break; case 2: operations.add(OperationType.PUT_NB); operations.add(OperationType.AWAIT_CREATION); operations.add(OperationType.GET_NB); operations.add(OperationType.GET_NB); operations.add(OperationType.GET_NB); operations.add(OperationType.GET_INFO_NB); break; } int blobSize = random.nextInt(100 * 1024); opChains.add(testFramework.startOperationChain(blobSize, i, operations)); } testFramework.checkOperationChains(opChains); }
Source:
<code>public static ItemStack getPreference(String oreName) { if(preferenceCache.containsKey(oreName)) { <START> return preferenceCache.get(oreName).copy(); <END> } List<ItemStack> items = OreDictionary.getOres(oreName, false); if(items.isEmpty()) { return ItemStack.EMPTY; } cachePreference(oreName, items); return preferenceCache.get(oreName).copy(); }</code><technical_language>good, forget copy! worth checking out Map.computeIfAbsent save ifs</technical_language>

Target:
public static ItemStack getPreference(String oreName) { return preferenceCache.computeIfAbsent(oreName, RecipeUtil::cachePreference).copy(); }
Source:
<code>public AbstractSSTableWriter build() throws Exception { <START> System.setProperty("cassandra.config", configFilePath); <END> AbstractSSTableWriter result; if (cqlVersion == 3) { CQL3SSTableWriter writer = new CQL3SSTableWriter(); writer.setRowMeta( rowMeta ); result = writer; } else { CQL2SSTableWriter writer = new CQL2SSTableWriter(); writer.setPartitionerClassName( new YamlConfigurationLoader().loadConfig().partitioner ); result = writer; } result.setDirectory( directory ); result.setKeyspace( keyspace ); result.setColumnFamily( columnFamily ); result.setKeyField( keyField ); result.setBufferSize( bufferSize ); return result; }</code><technical_language>@pentaho-nbaker @mattyb149 - avoiding of System.setProperty() this a case justified</technical_language>

Target:
public AbstractSSTableWriter build() throws Exception { System.setProperty( "cassandra.config", configFilePath ); AbstractSSTableWriter result; if ( cqlVersion == 3 ) { CQL3SSTableWriter writer = getCql3SSTableWriter(); writer.setRowMeta( rowMeta ); result = writer; } else { CQL2SSTableWriter writer = getCql2SSTableWriter(); writer.setPartitionerClassName( getPartitionerClass() ); result = writer; } result.setDirectory( directory ); result.setKeyspace( keyspace ); result.setColumnFamily( columnFamily ); result.setKeyField( keyField ); result.setBufferSize( bufferSize ); return result; }
Source:
<code>protected void EndVmCommand() { try { if (acquireLock()) { setVm(DbFacade.getInstance().getVmDAO().get(getVmId())); if (getVm() != null) { VmHandler.updateDisksFromDb(getVm()); List<DiskImage> diskImages = ImagesHandler.filterImageDisks(getVm().getDiskMap().values(), false, true); if (diskImages.isEmpty()) { RemoveVmFromDb(); } else { <START> imagesLeftInVm = true; <END> for (DiskImage diskImage : diskImages) { diskImage.setimageStatus(ImageStatus.ILLEGAL); getDbFacade().getImageDao().update(diskImage.getImage()); } VmHandler.UnLockVm(getVm().getId()); } } } setSucceeded(true); } finally { freeLock(); } }</code><technical_language>Transaction, need transaction - is a question asked Maor. Maor, u want unify related db operation transaction</technical_language>

Target:
protected void EndVmCommand() { try { if (acquireLock()) { setVm(DbFacade.getInstance().getVmDAO().get(getVmId())); if (getVm() != null) { updateDisksAfterVmRemoved(); } RemoveVmFromDb(); } setSucceeded(true); } finally { freeLock(); } }
Source:
<code>public void testCastToCharForSbcsData() throws Exception { methodWatcher.executeUpdate("drop table sbcs if exists"); methodWatcher.executeUpdate("create table sbcs(a varchar(30) for bit data, b char(30) for bit data)"); methodWatcher.executeUpdate("insert into sbcs values (cast('a' as varchar(30) for bit data), cast('b' as char(30) for bit data))"); <START> methodWatcher.executeUpdate("insert into sbcs values (case when 1 = 2 then 'dummy' end, case when 1 = 2 then 'dummy' end)"); <END> String sql = "select cast(a as varchar(30)), cast(a as varchar(30) for sbcs data)," + "cast(b as char(30)), cast(b as char(30) for sbcs data) from sbcs --splice-properties useSpark=%s\n order by a"; String expected = "1 | 2 | 3 | 4 |\n" + "--------------------------------------------------\n" + " 61 | a |622020202020202020202020202020 | b |\n" + "NULL |NULL | NULL |NULL |"; try (ResultSet rs = methodWatcher.executeQuery(format(sql, false))) { assertEquals(expected, TestUtils.FormattedResult.ResultFactory.toString(rs)); } try (ResultSet rs = methodWatcher.executeQuery(format(sql, true))) { assertEquals(expected, TestUtils.FormattedResult.ResultFactory.toString(rs)); } }</code><technical_language>do insert sbcs values (NULL, NULL) case trick is needed want a NULL in select portion of a query I think</technical_language>

Target:
public void testCastToCharForSbcsData() throws Exception { methodWatcher.executeUpdate("drop table sbcs if exists"); methodWatcher.executeUpdate("create table sbcs(a varchar(30) for bit data, b char(30) for bit data)"); methodWatcher.executeUpdate("insert into sbcs values (cast('a' as varchar(30) for bit data), cast('b' as char(30) for bit data))"); methodWatcher.executeUpdate("insert into sbcs values (null, null)"); String sql = "select cast(a as varchar(30)), cast(a as varchar(30) for sbcs data)," + "cast(b as char(30)), cast(b as char(30) for sbcs data) from sbcs --splice-properties useSpark=%s\n order by a"; String expected = "1 | 2 | 3 | 4 |\n" + "--------------------------------------------------\n" + " 61 | a |622020202020202020202020202020 | b |\n" + "NULL |NULL | NULL |NULL |"; try (ResultSet rs = methodWatcher.executeQuery(format(sql, false))) { assertEquals(expected, TestUtils.FormattedResult.ResultFactory.toString(rs)); } try (ResultSet rs = methodWatcher.executeQuery(format(sql, true))) { assertEquals(expected, TestUtils.FormattedResult.ResultFactory.toString(rs)); } }
Source:
<code>public void testMiniMRYarnClusterWithoutJHS() throws IOException { MiniMRYarnCluster mr = null; try { final Configuration conf = new Configuration(); conf.setBoolean(MiniMRYarnCluster.MR_HISTORY_MINICLUSTER_ENABLED, false); mr = new MiniMRYarnCluster("testMiniMRYarnClusterWithoutJHS"); mr.init(conf); <START> Assert.assertEquals(null, mr.getHistoryServer()); <END> mr.start(); } finally { if (mr != null) { mr.stop(); } } }</code><technical_language>this assert happen call start()</technical_language>

Target:
public void testMiniMRYarnClusterWithoutJHS() throws IOException { MiniMRYarnCluster mr = null; try { final Configuration conf = new Configuration(); conf.setBoolean(MiniMRYarnCluster.MR_HISTORY_MINICLUSTER_ENABLED, false); mr = new MiniMRYarnCluster("testMiniMRYarnClusterWithoutJHS"); mr.init(conf); mr.start(); Assert.assertEquals(null, mr.getHistoryServer()); } finally { if (mr != null) { mr.stop(); } } }
Source:
<code><START> public void onMapLargePreview(Event event) { <END> if (currentGameInfoBean == null) { return; } if (mapService.isOfficialMap(currentGameInfoBean.getMapName())) { return; } mapDetailPopup = getMapDetailPopup(); MapPreviewLargeController mapPreviewLargeController = applicationContext.getBean(MapPreviewLargeController.class); MapInfoBean mapInfoBean = mapService.getMapInfoBeanFromVaultFromName(currentGameInfoBean.getMapName()); if (mapInfoBean.getTechnicalName() == null) { return; } mapPreviewLargeController.createPreview(mapInfoBean); sceneFactory.createScene(mapDetailPopup, mapPreviewLargeController.getRoot(), false, WindowDecorator.WindowButtonType.CLOSE); mapDetailPopup.show(); mapDetailPopup.toFront(); }</code><technical_language>@FXML default visibility</technical_language>

Target:
void onMapLargePreview(Event event) { if (currentGameInfoBean == null) { return; } mapDetailPopup = getMapDetailPopup(); MapPreviewLargeController mapPreviewLargeController = applicationContext.getBean(MapPreviewLargeController.class); MapInfoBean mapInfoBean = mapService.getMapInfoBeanFromVaultFromName(currentGameInfoBean.getTechnicalName()); if (mapInfoBean == null) { String title = i18n.get("mapPreview.loadFailure.title"); String message = i18n.get("mapPreview.loadFailure.message"); notificationService.addNotification(new ImmediateNotification(title, message, Severity.ERROR)); } mapPreviewLargeController.createPreview(mapInfoBean); sceneFactory.createScene(mapDetailPopup, mapPreviewLargeController.getRoot(), false, WindowDecorator.WindowButtonType.CLOSE); mapDetailPopup.show(); }
Source:
<code>public boolean isDeletable() { <START> return getId() != RunQC.UNSAVED_ID; <END> }</code><technical_language>a constant of Run RunQC</technical_language>

Target:
public boolean isDeletable() { return getId() != Run.UNSAVED_ID; }
Source:
<code>ManagedChannel create() throws IOException; } private final AtomicReference<ImmutableList<ManagedChannel>> channels = new AtomicReference<>(); private final AtomicInteger requestCount = new AtomicInteger(); private final ImmutableList<HeaderInterceptor> headerInterceptors; private final AtomicInteger totalSize; private final ChannelFactory factory; private final String authority; <START> private boolean shutdown = false; <END> public ChannelPool(List<HeaderInterceptor> headerInterceptors, ChannelFactory factory) throws IOException { ManagedChannel channel = factory.create(); this.channels.set(ImmutableList.of(channel)); authority = channel.authority(); totalSize = new AtomicInteger(1); this.factory = factory; if (headerInterceptors == null) { this.headerInterceptors = ImmutableList.of(); } else { this.headerInterceptors = ImmutableList.copyOf(headerInterceptors); } }</code><technical_language>nit: name shuttingdown? is shutdown=true is true pool is shut down. Hmm.. Im reading wrong. isShutdown() return this.shutdown</technical_language>

Target:
ManagedChannel create() throws IOException; } private final AtomicReference<ImmutableList<ManagedChannel>> channels = new AtomicReference<>(); private final AtomicInteger requestCount = new AtomicInteger(); private final ImmutableList<HeaderInterceptor> headerInterceptors; private final ChannelFactory factory; private final String authority; private boolean shutdown = false; public ChannelPool(List<HeaderInterceptor> headerInterceptors, ChannelFactory factory) throws IOException { ManagedChannel channel = factory.create(); this.channels.set(ImmutableList.of(channel)); authority = channel.authority(); this.factory = factory; if (headerInterceptors == null) { this.headerInterceptors = ImmutableList.of(); } else { this.headerInterceptors = ImmutableList.copyOf(headerInterceptors); } }
Source:
<code>public List<Metric> filter(Map<Metric, String> extendedSortedMap, String limit) { SystemAssert.requireArgument(extendedSortedMap != null && !extendedSortedMap.isEmpty(), "New map is not constructed successfully!"); SystemAssert.requireArgument(limit != null && !limit.equals(""), "Limit must be provided!"); List<Metric> result = new ArrayList<Metric>(); for (Map.Entry<Metric, String> entry : extendedSortedMap.entrySet()) { Number lim; try { lim = Long.parseLong(limit); <START> } catch (NumberFormatException nfe) { <END> try { lim = Double.parseDouble(limit); } catch (NumberFormatException nfe2) { throw new IllegalArgumentException("The limit " + limit + " is not a valid number."); } } Number val; try { val = Long.parseLong(entry.getValue()); } catch (NumberFormatException nfe) { try { val = Double.parseDouble(entry.getValue()); } catch (NumberFormatException nfe2) { throw new IllegalArgumentException("The limit " + limit + " is not a valid number."); } } if (NumberOperations.isGreaterThan(lim, val)) { result.add(entry.getKey()); } } return result; }</code><technical_language>for needing do re-parsing for loop</technical_language>

Target:
public List<Metric> filter(Map<Metric, String> extendedSortedMap, String limit) { SystemAssert.requireArgument(extendedSortedMap != null && !extendedSortedMap.isEmpty(), "New map is not constructed successfully!"); SystemAssert.requireArgument(limit != null && !limit.equals(""), "Limit must be provided!"); List<Metric> result = new ArrayList<Metric>(); Number lim = NumberOperations.parseConstant(limit); for (Map.Entry<Metric, String> entry : extendedSortedMap.entrySet()) { Number val = NumberOperations.parseConstant(entry.getValue()); if (NumberOperations.isGreaterThan(lim, val)) { result.add(entry.getKey()); } } return result; }
Source:
<code>private RelayStatus convertRelayStatus(final com.alliander.osgp.domain.core.entities.RelayStatus status) { RelayStatus output = null; if (status != null) { output = new RelayStatus(); output.setIndex(status.getIndex()); output.setLastKnownState(status.isLastKnownState()); final GregorianCalendar gCalendar = new GregorianCalendar(); gCalendar.setTime(status.getLastKnowSwitchingTime()); try { output.setLastKnowSwitchingTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(gCalendar)); } catch (final DatatypeConfigurationException e) { <START> LOGGER.info(e.getMessage()); <END> } } return output; }</code><technical_language>I guess SonarQube complaining loggin exception... do this is: LOGGER.error("My useful message this exception", e); see, logs situation proper log-level, is communicates useful ("Bad date format in of theRelay Status dates."), logs exception (which resolve SonarQube issue)</technical_language>

Target:
private RelayStatus convertRelayStatus(final com.alliander.osgp.domain.core.entities.RelayStatus status) { RelayStatus output = null; if (status != null) { output = new RelayStatus(); output.setIndex(status.getIndex()); output.setLastKnownState(status.isLastKnownState()); final GregorianCalendar gCalendar = new GregorianCalendar(); gCalendar.setTime(status.getLastKnowSwitchingTime()); try { output.setLastKnowSwitchingTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(gCalendar)); } catch (final DatatypeConfigurationException e) { LOGGER.error("Bad date format in one of theRelay Status dates", e); } } return output; }
Source:
<code><START> public void close() { <END> if (isClosed()) { return; } try { H5.H5Fclose(fileId); fileId = -1; } catch (final HDF5LibraryException e) { throw new GATKException( String.format("failure when closing '%s' from read-only access: %s",file.getAbsolutePath(),e.getMessage()),e); } }</code><technical_language>this class implement AutoClosable? in try-with-resources close called magically system</technical_language>

Target:
public void close() { if (isClosed()) { return; } try { H5.H5Fclose(fileId); fileId = FILE_ID_WHEN_CLOSED; } catch (final HDF5LibraryException e) { throw new GATKException( String.format("failure when closing '%s' from read-only access: %s",file.getAbsolutePath(),e.getMessage()),e); } }
Source:
<code>protected void updateStorageDomainFromIrs() { final StorageDomain <START> sdFromIrs = <END> executeGetStorageDomainStats(); final StorageDomainStatic sdStaticFromIrs = executeHSMGetStorageDomainInfo().getFirst(); TransactionSupport.executeInNewTransaction(() -> { getCompensationContext().snapshotEntity(getStorageDomain().getStorageDynamicData()); storageDomainDynamicDao.update(sdFromIrs.getStorageDynamicData()); StorageDomainStatic sdStatic = storageDomainStaticDao.get(getStorageDomain().getId()); sdStatic.setBlockSize(sdStaticFromIrs.getBlockSize()); storageDomainStaticDao.update(sdStatic); getCompensationContext().stateChanged(); return null; }); }</code><technical_language>sdDinamicFromIrs</technical_language>

Target:
protected void updateStorageDomainFromIrs() { final StorageDomainDynamic sdDynamicFromIrs = executeGetStorageDomainStats(); final StorageDomainStatic sdStaticFromIrs = executeHSMGetStorageDomainInfo(); TransactionSupport.executeInNewTransaction(() -> { getCompensationContext().snapshotEntity(getStorageDomain().getStorageDynamicData()); storageDomainDynamicDao.update(sdDynamicFromIrs); StorageDomainStatic sdStatic = storageDomainStaticDao.get(getStorageDomain().getId()); sdStatic.setBlockSize(sdStaticFromIrs.getBlockSize()); storageDomainStaticDao.update(sdStatic); getCompensationContext().stateChanged(); return null; }); }
Source:
<code>private boolean canAdd(IFeatureModel candidate) { ISiteFeature[] features = fModel.getSite().getFeatures(); IFeature cfeature = candidate.getFeature(); for (ISiteFeature bfeature : features) { if (bfeature.getId() != null && bfeature.getId().equals(cfeature.getId()) && bfeature.getVersion() != null <START> && bfeature.getVersion().equals(cfeature.getVersion())) <END> return false; } return true; }</code><technical_language>This duplicate detection work for version-less features. I a check (idEqual && (version-less || versionEqual)) --> If want add multiple versions of a feature, need enter a version for adding second. WDYT</technical_language>

Target:
private boolean canAdd(IFeatureModel candidate) { ISiteFeature[] features = fModel.getSite().getFeatures(); IFeature cfeature = candidate.getFeature(); String id = cfeature.getId(); String version = cfeature.getVersion(); for (ISiteFeature bfeature : features) { boolean idEquals = Objects.equals(bfeature.getId(), id); if (idEquals && (version == null || version.equals(bfeature.getVersion()))) { return false; } } return true; }
Source:
<code>public ExtensionMailboxInfo(@Nonnull final IMAPResponse[] resps) throws ParsingException { super(resps); for (int i = 0; i < resps.length; i++) { if (resps[i] == null) { continue; } final IMAPResponse ir = resps[i]; ir.skipSpaces(); if (ir.readByte() != '[') { ir.reset(); continue; } String key = ir.readAtom(); if (key == null) { ir.reset(); continue; } key = key.toUpperCase(); boolean handled = false; if (key.equals(MAILBOX_ID)) { final String[] values = ir.readSimpleList(); if (values != null && values.length >= 1) { mailboxId = Integer.valueOf(values[0]); handled = true; } } <START> if (handled) { <END> resps[i] = null; } else { ir.reset(); } } }</code><technical_language>do break if done</technical_language>

Target:
public ExtensionMailboxInfo(@Nonnull final IMAPResponse[] resps) throws ParsingException { super(resps); for (int i = 0; i < resps.length; i++) { if (resps[i] == null) { continue; } final IMAPResponse ir = resps[i]; ir.skipSpaces(); if (ir.readByte() != '[') { ir.reset(); continue; } String key = ir.readAtom(); if (key == null) { ir.reset(); continue; } key = key.toUpperCase(); if (key.equals(MAILBOX_ID)) { final String[] values = ir.readSimpleList(); if (values != null && values.length >= 1) { mailboxId = Integer.valueOf(values[0]); resps[i] = null; break; } } ir.reset(); } }
Source:
<code>public LineTcpServer( CairoConfiguration cairoConfiguration, LineTcpReceiverConfiguration lineConfiguration, CairoEngine engine, WorkerPool workerPool, MessageBus messageBus ) { this.contextFactory = new LineTcpConnectionContextFactory(engine, lineConfiguration, messageBus, workerPool.getWorkerCount()); this.dispatcher = IODispatchers.create( lineConfiguration .getNetDispatcherConfiguration(), contextFactory); workerPool.assign(dispatcher); scheduler = new LineTcpMeasurementScheduler(cairoConfiguration, lineConfiguration, engine, workerPool); final IORequestProcessor<LineTcpConnectionContext> processor = (operation, context) -> { if (context.handleIO()) { busyContexts.add(context); } }; workerPool.assign(new SynchronizedJob() { @Override protected boolean runSerially() { int n = busyContexts.size(); while (n > 0) { n--; if (!busyContexts.getQuick(n).handleIO()) { busyContexts.remove(n); } } return dispatcher.processIOQueue(processor); } }); for (int i = 0, n = workerPool.getWorkerCount(); i < n; i++) { <START> workerPool.assign(i, () -> { <END> contextFactory.closeContextPool(); }); } }</code><technical_language>this a big deal, a server 20 cores 20 identical classes created java for this lambda. create lambda instance of loop</technical_language>

Target:
public LineTcpServer( CairoConfiguration cairoConfiguration, LineTcpReceiverConfiguration lineConfiguration, CairoEngine engine, WorkerPool workerPool, MessageBus messageBus ) { this.contextFactory = new LineTcpConnectionContextFactory(engine, lineConfiguration, messageBus); this.dispatcher = IODispatchers.create( lineConfiguration .getNetDispatcherConfiguration(), contextFactory); workerPool.assign(dispatcher); scheduler = new LineTcpMeasurementScheduler(cairoConfiguration, lineConfiguration, engine, workerPool); final IORequestProcessor<LineTcpConnectionContext> processor = (operation, context) -> { if (context.handleIO()) { busyContexts.add(context); } }; workerPool.assign(new SynchronizedJob() { @Override protected boolean runSerially() { int n = busyContexts.size(); while (n > 0) { n--; if (!busyContexts.getQuick(n).handleIO()) { busyContexts.remove(n); } else { n++; break; } } if (n == 0) { return dispatcher.processIOQueue(processor); } return true; } }); final Closeable cleaner = contextFactory::closeContextPool; for (int i = 0, n = workerPool.getWorkerCount(); i < n; i++) { workerPool.assign(i, cleaner); } }
Source:
<code>public boolean supports(DataHolder dataHolder) { return dataHolder instanceof EntityWolf || dataHolder instanceof EntitySheep || dataHolder instanceof ItemStack && <START> isDyeable(((ItemStack) dataHolder).getItem()) || dataHolder instanceof TileEntityShulkerBox; <END> }</code><technical_language>a separate data processor instead register one</technical_language>

Target:
public boolean supports(DataHolder dataHolder) { return dataHolder instanceof EntityWolf || dataHolder instanceof EntitySheep || dataHolder instanceof ItemStack && isDyeable(((ItemStack) dataHolder).getItem()); }
Source:
<code>public void testUnordered() throws Exception { dao.unordered(); List<String> invocations = TestSqlMethodDecoratingAnnotations.invocations.get(); assertTrue(invocations.contains("foo")); assertTrue(invocations.indexOf("foo") < 2); assertTrue(invocations.contains("bar")); assertTrue(invocations.indexOf("bar") < 2); <START> assertTrue(invocations.indexOf("method") == 2); <END> }</code><technical_language>nit: check size of invocations, if accidentally foo bar method method</technical_language>

Target:
public void testUnordered() throws Exception { Dao dao = handle.attach(Dao.class); dao.unordered(); assertThat(invocations.get(), anyOf( equalTo(asList("foo", "bar", "method")), equalTo(asList("bar", "foo", "method")))); }
Source:
<code>public void setUp() { initMocks(this); when(mockMetacard.getId()).thenReturn(MOCK_METACARD_ID); when(subjectIdentity.getUniqueIdentifier(subject)).thenReturn(MOCK_IDENTITY_ATTR); when(mockMetacard.getAttribute(Security.ACCESS_ADMINISTRATORS)).thenReturn(mockAttribute); when(mockAttribute.getValues()).thenReturn(Collections.singletonList(MOCK_IDENTITY_ATTR)); ThreadContext.bind(subject); accessPlugin = new AccessControlAccessPlugin(subjectIdentity) { public boolean isAccessControlUpdated(Metacard prev, Metacard updated) { return true; } <START> public Subject getSubject() { <END> return subject; } }; }</code><technical_language>I if binding a mock subject thread context, need this method anymore</technical_language>

Target:
public void setUp() { initMocks(this); when(mockMetacard.getId()).thenReturn(MOCK_METACARD_ID); when(subjectIdentity.getUniqueIdentifier(subject)).thenReturn(MOCK_IDENTITY_ATTR); when(mockMetacard.getAttribute(Security.ACCESS_ADMINISTRATORS)).thenReturn(mockAttribute); when(mockAttribute.getValues()).thenReturn(Collections.singletonList(MOCK_IDENTITY_ATTR)); ThreadContext.bind(subject); accessPlugin = new AccessControlAccessPlugin(subjectIdentity); }
Source:
<code>public List<FeedbackResponseAttributes> getValidResponses(List<FeedbackResponseAttributes> responses, String courseId) { List<InstructorAttributes> instructors = instructorLogic.getInstructorsForCourse(courseId); ArrayList<String> instructorEmails = new ArrayList<String>(); <START> for (int i = 0; i < instructors.size(); i++) { <END> instructorEmails.add(instructors.get(i).email); } List<StudentAttributes> students = studentsLogic.getStudentsForCourse(courseId); List<TeamDetailsBundle> teams; try { teams = coursesLogic.getTeamsForCourse(courseId); } catch (EntityDoesNotExistException e) { log.severe(e.toString()); teams = new ArrayList<TeamDetailsBundle>(); } ArrayList<String> teamNames = new ArrayList<String>(); for (int i = 0; i < teams.size(); i++) { teamNames.add(teams.get(i).name); } ArrayList<FeedbackResponseAttributes> validResponses = new ArrayList<FeedbackResponseAttributes>(); for(FeedbackResponseAttributes response: responses) { if (isResponseValid(response, courseId, instructorEmails, students, teamNames)) { validResponses.add(response); } } return validResponses; }</code><technical_language>for (Instructor instructor: instructors) { do trick</technical_language>

Target:
public List<FeedbackResponseAttributes> getValidResponses(List<FeedbackResponseAttributes> responses, String courseId) { List<InstructorAttributes> instructors = instructorLogic.getInstructorsForCourse(courseId); List<String> instructorEmails = new ArrayList<String>(); for (InstructorAttributes instructor: instructors) { instructorEmails.add(instructor.email); } List<StudentAttributes> students = studentsLogic.getStudentsForCourse(courseId); List<TeamDetailsBundle> teams; try { teams = coursesLogic.getTeamsForCourse(courseId); } catch (EntityDoesNotExistException e) { log.severe(e.toString()); teams = new ArrayList<TeamDetailsBundle>(); } List<String> teamNames = new ArrayList<String>(); for (TeamDetailsBundle team: teams) { teamNames.add(team.name); } List<FeedbackResponseAttributes> validResponses = new ArrayList<FeedbackResponseAttributes>(); for(FeedbackResponseAttributes response: responses) { if (isResponseValid(response, courseId, instructorEmails, students, teamNames)) { validResponses.add(response); } } return validResponses; }
Source:
<code>public Response create(@Valid ApplicationSpec applicationSpec) { if (anyEntityIsNotAvailable(applicationSpec) || anyLocationIsNotValid(applicationSpec)) { return Response.status(Response.Status.NOT_FOUND).build(); } manager.startInBackground(applicationSpec); <START> URI ref = URI.create(applicationSpec.getName()); <END> return Response.created(ref).build(); }</code><technical_language>this URL need prepended "application/"? Suspect this is lack of familiarity..</technical_language>

Target:
public Response create(@Valid ApplicationSpec applicationSpec) { checkAllEntityTypesAreValid(applicationSpec); checkAllLocationsAreValid(applicationSpec); manager.startInBackground(applicationSpec); URI ref = URI.create(applicationSpec.getName()); return Response.created(ref).build(); }
Source:
<code>private void updateReceivedMediaStreamStats( RTCPPacket[] in) { MediaStreamStatsImpl streamStats = mediaStream.getMediaStreamStats(); for (RTCPPacket rtcp : in) { switch (rtcp.type) { case RTCPFBPacket.PSFB: if (rtcp instanceof RTCPREMBPacket) { RTCPREMBPacket remb = (RTCPREMBPacket) rtcp; if (logger.isTraceEnabled()) { logger.trace( "Received estimated bitrate (bps): " + remb.getBitrate() + ", dest: " + Arrays.toString(remb.getDest())); } streamStats.rembReceived(remb); } else if (rtcp instanceof FIRPacket) { streamStats.firReceived((FIRPacket) rtcp); } break; case RTCPPacket.RR: <START> if (rtcp instanceof RTCPSRPacket) <END> { streamStats.srReceived((RTCPSRPacket) rtcp); } case RTCPPacket.SR: { RTCPReport report; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); rtcp.assemble(new DataOutputStream(baos)); byte[] buf = baos.toByteArray(); report = parseRTCPReport(rtcp.type, buf, 0, buf.length); } catch (IOException ioe) { logger.error("Failed to assemble an RTCP report: " + ioe); report = null; } if (report != null) { streamStats.getRTCPReports().rtcpReportReceived(report); } } break; case RTCPFBPacket.RTPFB: if (rtcp instanceof NACKPacket) { NACKPacket nack = (NACKPacket) rtcp; streamStats.nackReceived(nack); } break; case RTCPExtendedReport.XR: if (rtcp instanceof RTCPExtendedReport) { streamStats.getRTCPReports().rtcpExtendedReportReceived( (RTCPExtendedReport) rtcp); } break; default: break; } } }</code><technical_language>do do this if packet type is RR</technical_language>

Target:
private void updateReceivedMediaStreamStats( RTCPPacket[] in) { MediaStreamStatsImpl streamStats = mediaStream.getMediaStreamStats(); for (RTCPPacket rtcp : in) { switch (rtcp.type) { case RTCPFBPacket.PSFB: if (rtcp instanceof RTCPREMBPacket) { RTCPREMBPacket remb = (RTCPREMBPacket) rtcp; if (logger.isTraceEnabled()) { logger.trace( "Received estimated bitrate (bps): " + remb.getBitrate() + ", dest: " + Arrays.toString(remb.getDest())); } streamStats.rembReceived(remb); } else if (rtcp instanceof FIRPacket) { streamStats.firReceived((FIRPacket) rtcp); } break; case RTCPPacket.SR: if (rtcp instanceof RTCPSRPacket) { streamStats.srReceived((RTCPSRPacket) rtcp); } case RTCPPacket.RR: { RTCPReport report; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); rtcp.assemble(new DataOutputStream(baos)); byte[] buf = baos.toByteArray(); report = parseRTCPReport(rtcp.type, buf, 0, buf.length); } catch (IOException ioe) { logger.error("Failed to assemble an RTCP report: " + ioe); report = null; } if (report != null) { streamStats.getRTCPReports().rtcpReportReceived(report); } } break; case RTCPFBPacket.RTPFB: if (rtcp instanceof NACKPacket) { NACKPacket nack = (NACKPacket) rtcp; streamStats.nackReceived(nack); } break; case RTCPExtendedReport.XR: if (rtcp instanceof RTCPExtendedReport) { streamStats.getRTCPReports().rtcpExtendedReportReceived( (RTCPExtendedReport) rtcp); } break; default: break; } } }
Source:
<code>public void shouldChangeJavaHomeFromJvm() throws Exception { AbstractSurefireMojoTest.Mojo mojo = new AbstractSurefireMojoTest.Mojo(); String fakeJava = "/some/path/to/jdk/bin/java"; mojo.setJvm( fakeJava ); File mockedFile = mock( File.class ); when( mockedFile.getAbsoluteFile() ).thenReturn( mockedFile ); when( mockedFile.getPath() ).thenReturn( fakeJava ); when( mockedFile.getName() ).thenReturn( "java" ); when( mockedFile.isFile() ).thenReturn( true ); whenNew( File.class ). withParameterTypes( String.class ). withArguments( anyString() ). thenReturn( mockedFile ); assertThat( mojo.getEnvironmentVariables() ).isEmpty(); invokeMethod( mojo, "getEffectiveJvm" ); <START> assertThat( mojo.getEnvironmentVariables() ).includes( MapAssert.entry( "JAVA_HOME", "/some/path/to/jdk" ) ); <END> }</code><technical_language>Windows fails java.lang.AssertionError: map:<{'JAVA_HOME'='D:\some\path\to\jdk'}> entry:<['JAVA_HOME'='/some/path/to/jdk']> do a bit of easier real path system property java.home is JRE. for String fakeJava. mock File. worth write test environmentVariables some other path assertion statement verify environmentVariables is intact</technical_language>

Target:
public void shouldChangeJavaHomeFromJvm() throws Exception { AbstractSurefireMojoTest.Mojo mojo = new AbstractSurefireMojoTest.Mojo(); File currentJdkHome = toJdkHomeFromJre(); String javaExecutablePath = FilenameUtils.concat( currentJdkHome.getAbsolutePath(), "bin/java" ); mojo.setJvm( javaExecutablePath ); assertThat( mojo.getEnvironmentVariables() ).isEmpty(); JdkAttributes effectiveJvm = invokeMethod( mojo, "getEffectiveJvm" ); assertThat( mojo.getEnvironmentVariables() ). includes( MapAssert.entry( "JAVA_HOME", currentJdkHome.getAbsolutePath() ) ); assertThat( effectiveJvm.getJvmExecutable() ).contains( javaExecutablePath ); }
Source:
<code>private void populateReviews(List<TaskReview> reviewContainers) { for (String reviewUrl : reviewUrls) { AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager() .getConnectorForRepositoryTaskUrl(reviewUrl); if (connector == null) { continue; } String repositoryUrl = connector.getRepositoryUrlFromTaskUrl(reviewUrl); String reviewId = connector.getTaskIdFromTaskUrl(reviewUrl); if (repositoryUrl == null || reviewId == null) { continue; } ITask task = taskList.getTask(repositoryUrl, reviewId); TasksUiPlugin.getRepositoryManager() .getConnectorForRepositoryTaskUrl(reviewUrl) .getTaskIdFromTaskUrl(reviewUrl); if (task.getSynchronizationState().isIncoming()) { task.getSynchronizationState(); } try { reviewContainers .add(new TaskReview(task.getSummary(), Integer.parseInt(task.getAttribute("CODE_REVIEW")), Integer.parseInt(task.getAttribute("VERIFIED")), "")); <START> } catch (Exception e) { <END> } } }</code><technical_language>Empty catch? If this is ABSOLUTELY necessary, consider why. I suspect reason this is want capture NumberFormatException thrown parseInt. Consider moving integer parsings "blocks", wrapping try..catch catching NumberFormatException. This read better. If get a non-string is pretty amiss too, worth logging? need integration test for this; check Sam</technical_language>

Target:
private void populateReviews(List<TaskReview> reviewContainers) { for (String reviewUrl : reviewUrls) { AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager() .getConnectorForRepositoryTaskUrl(reviewUrl); if (connector == null) { continue; } String repositoryUrl = connector.getRepositoryUrlFromTaskUrl(reviewUrl); String reviewId = connector.getTaskIdFromTaskUrl(reviewUrl); if (repositoryUrl == null || reviewId == null) { continue; } ITask task = taskList.getTask(repositoryUrl, reviewId); TasksUiPlugin.getRepositoryManager() .getConnectorForRepositoryTaskUrl(reviewUrl) .getTaskIdFromTaskUrl(reviewUrl); if (task.getSynchronizationState().isIncoming()) { task.getSynchronizationState(); } try { int codeReviewVal = Integer.parseInt(task.getAttribute("CODE_REVIEW")); int verifiedVal = Integer.parseInt(task.getAttribute("VERIFIED")); reviewContainers.add(new TaskReview(task.getSummary(), codeReviewVal, verifiedVal, "")); } catch (NumberFormatException e) { } } }
Source:
<code>private void resolve() { List<Endpoint> endpoints; synchronized (instanceLock) { try { endpoints = zkResolver.resolve(parameters.getExpression()); } catch (CloudnameException e) { log.warning("Exception from cloudname: " + e.toString()); return; } } Map<String, TrackedCoordinate> tempStatusAndEndpointsMap = new HashMap<String, TrackedCoordinate>(); for (Endpoint endpoint : endpoints) { String statusPath = ZkCoordinatePath.getStatusPath(endpoint.getCoordinate()); TrackedCoordinate trackedCoordinate = new TrackedCoordinate(this, statusPath, zkClient); trackedCoordinate.start(); try { trackedCoordinate.waitForFirstData(); } catch (InterruptedException e) { log.severe("Got interrupt while waiting for data." + e.getMessage()); <START> return; <END> } tempStatusAndEndpointsMap.put(statusPath, trackedCoordinate); } synchronized (instanceLock) { for (TrackedCoordinate trackedCoordinate : coordinateByPath.values()) { trackedCoordinate.stop(); } coordinateByPath.clear(); coordinateByPath.putAll(tempStatusAndEndpointsMap); } }</code><technical_language>og log.log(Level.SEVERE, "text", e); preserve exception. Also, interrupts us, is return correct answer ;)</technical_language>

Target:
private void resolve() { List<Endpoint> endpoints; synchronized (instanceLock) { try { endpoints = zkResolver.resolve(parameters.getExpression()); } catch (CloudnameException e) { log.warning("Exception from cloudname: " + e.toString()); return; } } Map<String, TrackedCoordinate> tempStatusAndEndpointsMap = new HashMap<String, TrackedCoordinate>(); for (Endpoint endpoint : endpoints) { String statusPath = ZkCoordinatePath.getStatusPath(endpoint.getCoordinate()); TrackedCoordinate trackedCoordinate = new TrackedCoordinate(this, statusPath, zkClient); trackedCoordinate.start(); try { trackedCoordinate.waitForFirstData(); } catch (InterruptedException e) { log.log(Level.SEVERE, "Got interrupt while waiting for data.", e); return; } tempStatusAndEndpointsMap.put(statusPath, trackedCoordinate); } synchronized (instanceLock) { for (TrackedCoordinate trackedCoordinate : coordinateByPath.values()) { trackedCoordinate.stop(); } coordinateByPath.clear(); coordinateByPath.putAll(tempStatusAndEndpointsMap); } }
Source:
<code>public boolean hasMetaConstraintBeenProcessed(Object bean, Path path, MetaConstraint<?> metaConstraint) { <START> if ( metaConstraint.getGroupList().size() <= 1 ) { <END> return false; } return processedPathUnits.contains( new BeanPathMetaConstraintProcessedUnit( bean, path, metaConstraint ) ); }</code><technical_language>replace this MetaConstraint#isInMultipleGroups() cache well</technical_language>

Target:
public boolean hasMetaConstraintBeenProcessed(Object bean, Path path, MetaConstraint<?> metaConstraint) { if ( metaConstraint.isDefinedForOneGroupOnly() ) { return false; } return processedPathUnits.contains( new BeanPathMetaConstraintProcessedUnit( bean, path, metaConstraint ) ); }
Source:
<code>public static int hexDigitToInt(final char hexDigit) { final int digit = Character.digit(hexDigit, 16); if (digit < 0) { <START> throw IllegalArgumentExceptions.format("Cannot interpret '%s' as a hexadecimal digit", hexDigit); <END> } return digit; }</code><technical_language>'%d'</technical_language>

Target:
public static int hexDigitToInt(final char hexDigit) { final int digit = Character.digit(hexDigit, 16); if (digit < 0) { throw IllegalArgumentExceptions.format("Cannot interpret '%d' as a hexadecimal digit", hexDigit); } return digit; }
Source:
<code>Path generateArtifact(T artifactGenerator, String id, String version, long size, Map<String, Object> attributesMap) throws IOException; default void setLicenses(ArtifactGenerator artifactGenerator, Map<String, Object> attributesMap) { <START> <END> Object licenses = attributesMap.get("licenses"); if (licenses instanceof LicenseConfiguration[]) { artifactGenerator.setLicenses((LicenseConfiguration[]) licenses); } }</code><technical_language>suggestion</technical_language>

Target:
Path generateArtifact(T artifactGenerator, String id, String version, long size, Map<String, Object> attributesMap) throws IOException; default void setLicenses(ArtifactGenerator artifactGenerator, Map<String, Object> attributesMap) throws IOException { Object licenses = attributesMap.get("licenses"); if (licenses instanceof LicenseConfiguration[]) { artifactGenerator.setLicenses((LicenseConfiguration[]) licenses); } }
Source:
<code>private void activateMember(StatefulMember member) { StatefulMember existingMember = members.get(member.id()); if (existingMember == null) { member.setState(State.ACTIVE); LOGGER.info("{} - Member activated: {}", localMember.id(), member); members.put(member.id(), member); post(new ClusterMembershipEvent(ClusterMembershipEvent.Type.MEMBER_ADDED, member)); sendHeartbeat(member.address(), SERIALIZER.encode(new ClusterHeartbeat( localMember.id(), localMember.zone(), localMember.rack(), localMember.host(), localMember.metadata()))); <START> } else if (!existingMember.id().equals(localMember.id()) && existingMember.getState() == State.INACTIVE) { <END> LOGGER.info("{} - Member activated: {}", localMember.id(), existingMember); existingMember.setState(State.ACTIVE); post(new ClusterMembershipEvent(ClusterMembershipEvent.Type.MEMBER_ADDED, existingMember)); } else if (!existingMember.id().equals(localMember.id()) && !existingMember.metadata().equals(member.metadata())) { member.setState(State.ACTIVE); LOGGER.info("{} - Member updated: {}", localMember.id(), member); members.put(member.id(), member); post(new ClusterMembershipEvent(ClusterMembershipEvent.Type.MEMBER_UPDATED, member)); } }</code><technical_language>post update local map</technical_language>

Target:
private synchronized void activateMember(StatefulMember member) { StatefulMember existingMember = members.get(member.id()); if (existingMember == null) { member.setState(State.ACTIVE); LOGGER.info("{} - Member activated: {}", localMember.id(), member); members.put(member.id(), member); post(new ClusterMembershipEvent(ClusterMembershipEvent.Type.MEMBER_ADDED, member)); sendHeartbeat(member.address(), SERIALIZER.encode(new ClusterHeartbeat( localMember.id(), localMember.zone(), localMember.rack(), localMember.host(), localMember.metadata()))); } else if (existingMember.getState() == State.INACTIVE) { LOGGER.info("{} - Member activated: {}", localMember.id(), existingMember); existingMember.setState(State.ACTIVE); post(new ClusterMembershipEvent(ClusterMembershipEvent.Type.MEMBER_ADDED, existingMember)); } else if (!existingMember.metadata().equals(member.metadata())) { member.setState(State.ACTIVE); LOGGER.info("{} - Member updated: {}", localMember.id(), member); members.put(member.id(), member); post(new ClusterMembershipEvent(ClusterMembershipEvent.Type.MEMBER_UPDATED, member)); } }