auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public UserResetTokenDTO createResetUserPasswordToken(final String username, final String email) throws UserRetrievalException { UserDTO foundUser = userDAO.findUserByNameAndEmail(username, email); if (foundUser == null) { throw new UserRetrievalException("Cannot find user with name " + username + " and email address " + email); } char[] buf = new char[GENERATED_PASSWORD_LENGTH]; for (int idx = 0; idx < buf.length; ++idx) { buf[idx] = SYMBOLS[random.nextInt(SYMBOLS.length)]; } String password = new String(buf); userResetTokenDAO.deletePreviousUserTokens(foundUser.getId()); UserResetTokenDTO userResetToken = userResetTokenDAO.create(password, foundUser.getId()); return userResetToken; }

Target:
public UserResetTokenDTO createResetUserPasswordToken(final String username, final String email) throws UserRetrievalException { UserDTO foundUser = userDAO.findUserByNameAndEmail(username, email); if (foundUser == null) { throw new UserRetrievalException("Cannot find user with name " + username + " and email address " + email); } String password = UUID.randomUUID().toString(); userResetTokenDAO.deletePreviousUserTokens(foundUser.getId()); UserResetTokenDTO userResetToken = userResetTokenDAO.create(password, foundUser.getId()); return userResetToken; }
Source:
void handleRevocation(final Collection<TopicPartition> revokedPartitions) { final Set<TaskId> revokedTasks = new HashSet<>(); final Set<TopicPartition> remainingPartitions = new HashSet<>(revokedPartitions); for (final Task task : tasks.values()) { if (remainingPartitions.containsAll(task.inputPartitions())) { revokedTasks.add(task.id()); } remainingPartitions.removeAll(task.inputPartitions()); } if (!remainingPartitions.isEmpty()) { log.info("The following partitions are missing from the task partitions. It is possible that" + "they have been cleaned up by the onAssignment callback", remainingPartitions); } for (final TaskId taskId : revokedTasks) { final Task task = tasks.get(taskId); task.suspend(); } }

Target:
void handleRevocation(final Collection<TopicPartition> revokedPartitions) { final Set<TaskId> revokedTasks = new HashSet<>(); final Set<TopicPartition> remainingPartitions = new HashSet<>(revokedPartitions); for (final Task task : tasks.values()) { if (remainingPartitions.containsAll(task.inputPartitions())) { revokedTasks.add(task.id()); } remainingPartitions.removeAll(task.inputPartitions()); } if (!remainingPartitions.isEmpty()) { log.warn("The following partitions are missing from the task partitions. It could potentially " + "due to race condition of consumer detecting the heartbeat failure, or the tasks " + "have been cleaned up by the handleAssignment callback.", remainingPartitions); } for (final TaskId taskId : revokedTasks) { final Task task = tasks.get(taskId); task.suspend(); } }
Source:
private String getString(String param) { return Constant.messages.getString(MESSAGE_PREFIX + param, ""); }

Target:
private String getString(String param) { return Constant.messages.getString(MESSAGE_PREFIX + param); }
Source:
public void dosCborObject() throws Throwable { if(true)throw new RuntimeException(); byte[] raw = ArrayOps.hexToBytes("5b0004000000000000"); try { CborObject.fromByteArray(raw); Assert.fail("Should have failed!"); } catch (RuntimeException e) }

Target:
public void dosCborObject() throws Throwable { byte[] raw = ArrayOps.hexToBytes("5b0004000000000000"); try { CborObject.fromByteArray(raw); Assert.fail("Should have failed!"); } catch (RuntimeException e) }
Source:
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) { return isInitialized == 1; } for (int i = 0; i < getLocationCount(); i++) { if (!getLocation(i).isInitialized()) { memoizedIsInitialized = 0; return false; } } memoizedIsInitialized = 1; return true; }

Target:
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; for (int i = 0; i < getLocationCount(); i++) { if (!getLocation(i).isInitialized()) { memoizedIsInitialized = 0; return false; } } memoizedIsInitialized = 1; return true; }
Source:
public static String getModString(int state) { StringBuilder sb = new StringBuilder(); for (GameMod mod : GameMod.values()) { if ((state & mod.getBit()) > 0) { sb.append(mod.getName()); sb.append(','); } } if (sb.length() > 0) { sb.setLength(sb.length() - 1); return sb.toString(); } return "None"; }

Target:
public static String getModString(int state) { StringBuilder sb = new StringBuilder(); for (GameMod mod : GameMod.values()) { if ((state & mod.getBit()) > 0) { sb.append(mod.getName()); sb.append(','); } } if (sb.length() > 0) { sb.setLength(sb.length() - 1); return sb.toString(); } else return "None"; }
Source:
public ListProjectsOptions id(String id) { this.queryParameters.replaceValues("id", ImmutableSet.of(id + "")); return this; }

Target:
public ListProjectsOptions id(String id) { this.queryParameters.replaceValues("id", ImmutableSet.of(id)); return this; }
Source:
protected Query<Map<String, Object>> createInactiveStatusesSinceQuery( Handle handle, DateTime timestamp, @Nullable Integer maxNumStatuses, @Nullable String datasource ) { final String whereStmt = getWhereClause(datasource); String sql = StringUtils.format( "SELECT " + " id, " + " status_payload, " + " created_date, " + " datasource, " + " payload " + "FROM " + " %s " + "WHERE " + whereStmt + "ORDER BY created_date DESC", getEntryTable() ); if (maxNumStatuses != null) { sql += " FETCH FIRST :n ROWS ONLY"; } Query<Map<String, Object>> query = handle.createQuery(sql).bind("start", timestamp.toString()); if (maxNumStatuses != null) { query = query.bind("n", maxNumStatuses); } if (datasource != null) { query = query.bind("ds", datasource); } return query; }

Target:
protected Query<Map<String, Object>> createInactiveStatusesSinceQuery( Handle handle, DateTime timestamp, @Nullable Integer maxNumStatuses, @Nullable String datasource ) { String sql = StringUtils.format( "SELECT " + " id, " + " status_payload, " + " created_date, " + " datasource, " + " payload " + "FROM " + " %s " + "WHERE " + getWhereClauseForInactiveStatusesSinceQuery(datasource) + "ORDER BY created_date DESC", getEntryTable() ); if (maxNumStatuses != null) { sql += " FETCH FIRST :n ROWS ONLY"; } Query<Map<String, Object>> query = handle.createQuery(sql).bind("start", timestamp.toString()); if (maxNumStatuses != null) { query = query.bind("n", maxNumStatuses); } if (datasource != null) { query = query.bind("ds", datasource); } return query; }
Source:
private boolean extractTextAndIndex(AbstractFile aFile, Map<String, String> extractedMetadata) throws IngesterException { ImageConfig imageConfig = new ImageConfig(); imageConfig.setOCREnabled(KeywordSearchSettings.getOcrOption()); List<ProcessTerminator> terminators = new ArrayList<>(); terminators.add(() -> context.fileIngestIsCancelled()); terminators.add(new TimedProcessTerminator(OCR_TIMEOUT_SECONDS)); HybridTerminator terminator = new HybridTerminator(terminators); Lookup extractionContext = Lookups.fixed(imageConfig, terminator); try { TextExtractor extractor = TextExtractorFactory.getExtractor(aFile, extractionContext); Reader fileText = extractor.getReader(); Reader finalReader; try { Map<String, String> metadata = extractor.getMetadata(); if (!metadata.isEmpty()) { extractedMetadata.putAll(metadata); } CharSource formattedMetadata = getMetaDataCharSource(metadata); finalReader = CharSource.concat(new CharSource() { @Override public Reader openStream() throws IOException { return fileText; } }, formattedMetadata).openStream(); } catch (IOException ex) { logger.log(Level.WARNING, String.format("Could not format extracted metadata for file %s [id=%d]", aFile.getName(), aFile.getId()), ex); finalReader = fileText; } return Ingester.getDefault().indexText(finalReader, aFile.getId(), aFile.getName(), aFile, context); } catch (TextExtractorFactory.NoTextExtractorFound | TextExtractor.InitReaderException ex) { return false; } }

Target:
private boolean extractTextAndIndex(AbstractFile aFile, Map<String, String> extractedMetadata) throws IngesterException { ImageConfig imageConfig = new ImageConfig(); imageConfig.setOCREnabled(KeywordSearchSettings.getOcrOption()); ProcessTerminator terminator = () -> context.fileIngestIsCancelled(); Lookup extractionContext = Lookups.fixed(imageConfig, terminator); try { TextExtractor extractor = TextExtractorFactory.getExtractor(aFile, extractionContext); Reader fileText = extractor.getReader(); Reader finalReader; try { Map<String, String> metadata = extractor.getMetadata(); if (!metadata.isEmpty()) { extractedMetadata.putAll(metadata); } CharSource formattedMetadata = getMetaDataCharSource(metadata); finalReader = CharSource.concat(new CharSource() { @Override public Reader openStream() throws IOException { return fileText; } }, formattedMetadata).openStream(); } catch (IOException ex) { logger.log(Level.WARNING, String.format("Could not format extracted metadata for file %s [id=%d]", aFile.getName(), aFile.getId()), ex); finalReader = fileText; } return Ingester.getDefault().indexText(finalReader, aFile.getId(), aFile.getName(), aFile, context); } catch (TextExtractorFactory.NoTextExtractorFound | TextExtractor.InitReaderException ex) { return false; } }
Source:
private SecurityGroup generateSecurityGroup(ClaudiaData claudiaData, TierInstance tierInstance) throws EntityNotFoundException { SecurityGroup securityGroup = new SecurityGroup(); securityGroup.setName("sg_" + claudiaData.getVdc() + "_" + tierInstance.getName()); log.info("Generate Object Security Group " + "sg_" + claudiaData.getService() + "_" + claudiaData.getVdc() + "_" + tierInstance.getTier().getRegion() + "_" + tierInstance.getName()); List<Rule> rules = getDefaultRules(); List<ProductRelease> productReleases = tierInstance.getTier().getProductReleases(); if (productReleases != null) { for (ProductRelease productRelease : tierInstance.getTier().getProductReleases()) { getRulesFromProduct(productRelease, rules); } } securityGroup.setRules(rules); return securityGroup; }

Target:
private SecurityGroup generateSecurityGroup(ClaudiaData claudiaData, TierInstance tierInstance) throws EntityNotFoundException { SecurityGroup securityGroup = new SecurityGroup(); String secGroupName = "sg_" + claudiaData.getVdc() + "_" + tierInstance.getName(); securityGroup.setName(secGroupName); log.info("Generate Object Security Group " + secGroupName); List<Rule> rules = getDefaultRules(); List<ProductRelease> productReleases = tierInstance.getTier().getProductReleases(); if (productReleases != null) { for (ProductRelease productRelease : tierInstance.getTier().getProductReleases()) { getRulesFromProduct(productRelease, rules); } } securityGroup.setRules(rules); return securityGroup; }
Source:
private HarvestedResource createHarvestedResource(File file) { try { return new HarvestedFile( new FileInputStream(file), file.getName(), file.toURI().toASCIIString()); } catch (FileNotFoundException e) { LOGGER.debug( "Failed to get input stream from file [{}]. Create event will not be sent to listener", file.toURI()); return null; } }

Target:
private HarvestedResource createHarvestedResource(File file) { try { return new HarvestedFile( new FileInputStream(file), file.getName(), file.toURI().toASCIIString()); } catch (FileNotFoundException e) { LOGGER.debug( "Failed to get input stream from file [{}]. Create event will not be sent to listener", file.toURI(), e); return null; } }
Source:
public void saveSearch(IAtsUser atsUser, AtsSearchData data) { ArtifactId userArt = atsUser.getStoreObject(); IAtsChangeSet changes = atsClient.getStoreService().createAtsChangeSet("Save ATS Search", atsClient.getUserService().getCurrentUser()); try { boolean found = false; for (IAttribute<Object> attr : atsClient.getAttributeResolver().getAttributes(userArt, AtsAttributeTypes.QuickSearch)) { String jsonValue = ((String) attr.getValue()); AtsSearchData existing = fromJson(jsonValue); if (existing.getUuid() == data.getUuid()) { changes.setAttribute(userArt, attr.getId(), getStoreString(data)); found = true; } } if (!found) { changes.addAttribute(atsUser, AtsAttributeTypes.QuickSearch, getStoreString(data)); } if (!changes.isEmpty()) { changes.execute(); } } catch (Exception ex) { throw new OseeCoreException("Unable to store ATS Search", ex); } }

Target:
public void saveSearch(IAtsUser atsUser, AtsSearchData data) { ArtifactId userArt = atsUser.getStoreObject(); IAtsChangeSet changes = atsClient.getStoreService().createAtsChangeSet("Save ATS Search", atsClient.getUserService().getCurrentUser()); try { IAttribute<Object> attr = getAttrById(userArt, data.getUuid()); if (attr == null) { changes.addAttribute(atsUser, AtsAttributeTypes.QuickSearch, getStoreString(data)); } else { changes.setAttribute(userArt, attr.getId(), getStoreString(data)); } if (!changes.isEmpty()) { changes.execute(); } } catch (Exception ex) { throw new OseeCoreException("Unable to store ATS Search", ex); } }
Source:
public CompletableFuture<Object> dispatch(Message request) throws Exception { ResponseFuture responseFuture = new ResponseFuture(fn -> request); Message requestMessage = composeRequest(request, responseFuture.correlationId()); String methodName = request.header(ServiceHeaders.METHOD); checkArgument(methodName != null, "Method name can't be null"); String serviceName = request.header(ServiceHeaders.SERVICE_REQUEST); checkArgument(serviceName != null, "Method name can't be null"); return futureInvoke(requestMessage, message -> message); }

Target:
public CompletableFuture<Object> dispatch(Message request) throws Exception { ServiceResponse responseFuture = new ServiceResponse(fn -> request); Message requestMessage = composeRequest(request, responseFuture.correlationId()); String methodName = request.header(ServiceHeaders.METHOD); checkArgument(methodName != null, "Method name can't be null"); String serviceName = request.header(ServiceHeaders.SERVICE_REQUEST); checkArgument(serviceName != null, "Method name can't be null"); return futureInvoke(requestMessage, message -> message); }
Source:
public static BasicEntityMemento.Builder newEntityMementoBuilder(Entity entity) { BasicEntityMemento.Builder builder = BasicEntityMemento.builder(); builder.id = entity.getId(); builder.displayName = entity.getDisplayName(); builder.type = entity.getClass().getName(); builder.isTopLevelApp = (entity instanceof Application && entity.getParent() == null); Map<ConfigKey<?>, Object> localConfig = ((EntityInternal)entity).getConfigMap().getLocalConfig(); for (Map.Entry<ConfigKey<?>, Object> entry : localConfig.entrySet()) { ConfigKey<?> key = checkNotNull(entry.getKey(), localConfig); Object value = entry.getValue(); if (value instanceof Task) { if (((Task)value).isDone()) { if (((Task)value).isError()) { value = null; } else { value = ((Task)value).getUnchecked(); } } else { value = null; } } builder.config.put(key, value); } Map<AttributeSensor, Object> allAttributes = ((EntityInternal)entity).getAllAttributes(); for (Map.Entry<AttributeSensor, Object> entry : allAttributes.entrySet()) { AttributeSensor<?> key = checkNotNull(entry.getKey(), allAttributes); Object value = entry.getValue(); builder.attributes.put((AttributeSensor<?>)key, value); } for (Location location : entity.getLocations()) { builder.locations.add(location.getId()); } for (Entity child : entity.getChildren()) { builder.children.add(child.getId()); } Entity parentEntity = entity.getParent(); builder.parent = (parentEntity != null) ? parentEntity.getId() : null; if (entity instanceof Group) { for (Entity member : ((Group)entity).getMembers()) { builder.members.add(member.getId()); } } return builder; }

Target:
public static BasicEntityMemento.Builder newEntityMementoBuilder(Entity entity) { BasicEntityMemento.Builder builder = BasicEntityMemento.builder(); builder.id = entity.getId(); builder.displayName = entity.getDisplayName(); builder.type = entity.getClass().getName(); builder.isTopLevelApp = (entity instanceof Application && entity.getParent() == null); Map<ConfigKey<?>, Object> localConfig = ((EntityInternal)entity).getConfigMap().getLocalConfig(); for (Map.Entry<ConfigKey<?>, Object> entry : localConfig.entrySet()) { ConfigKey<?> key = checkNotNull(entry.getKey(), localConfig); Object value = entry.getValue(); if (value instanceof Task) { Task task = (Task) value; if (task.isDone() && !task.isError()) { value = task.getUnchecked(); } else { value = null; } } builder.config.put(key, value); } Map<AttributeSensor, Object> allAttributes = ((EntityInternal)entity).getAllAttributes(); for (Map.Entry<AttributeSensor, Object> entry : allAttributes.entrySet()) { AttributeSensor<?> key = checkNotNull(entry.getKey(), allAttributes); Object value = entry.getValue(); builder.attributes.put((AttributeSensor<?>)key, value); } for (Location location : entity.getLocations()) { builder.locations.add(location.getId()); } for (Entity child : entity.getChildren()) { builder.children.add(child.getId()); } Entity parentEntity = entity.getParent(); builder.parent = (parentEntity != null) ? parentEntity.getId() : null; if (entity instanceof Group) { for (Entity member : ((Group)entity).getMembers()) { builder.members.add(member.getId()); } } return builder; }
Source:
private static InputSource sourceToInputSource(Source source) { if (source instanceof SAXSource) { return ((SAXSource) source).getInputSource(); } else if (source instanceof StreamSource) { StreamSource ss = (StreamSource) source; InputSource inputSource = new InputSource(ss.getSystemId()); inputSource.setByteStream(ss.getInputStream()); inputSource.setCharacterStream(ss.getReader()); inputSource.setPublicId(ss.getPublicId()); return inputSource; } else { return new InputSource(source.getSystemId()); } }

Target:
private static InputSource sourceToInputSource(Source source) { InputSource inputSource = SAXSource.sourceToInputSource(source); if (inputSource == null) { inputSource = new InputSource(source.getSystemId()); } return inputSource; }
Source:
public byte[] encrypt(byte[] plain) { try { byte[] salt = new byte[saltSize]; SecureRandom rnd = new SecureRandom(); rnd.nextBytes(salt); SecretKey tmp = getKeyFromPassword(passPhrase, salt); SecretKey secret = new SecretKeySpec(tmp.getEncoded(), cipherAlgName); Cipher ecipher = Cipher.getInstance(transformation); ecipher.init(Cipher.ENCRYPT_MODE, secret); return new EncryptedData( salt, ecipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV(), ecipher.doFinal(plain) ).toByteAray(); } catch (InvalidKeySpecException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidParameterSpecException | IllegalBlockSizeException | BadPaddingException ex) { throw new RuntimeException(ex); } }

Target:
public byte[] encrypt(byte[] plain) { try { byte[] salt = new byte[saltSize]; SECURE_RANDOM_INSTANCE.nextBytes(salt); SecretKey tmp = getKeyFromPassword(passPhrase, salt); SecretKey secret = new SecretKeySpec(tmp.getEncoded(), cipherAlgName); Cipher ecipher = Cipher.getInstance(transformation); ecipher.init(Cipher.ENCRYPT_MODE, secret); return new EncryptedData( salt, ecipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV(), ecipher.doFinal(plain) ).toByteAray(); } catch (InvalidKeySpecException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidParameterSpecException | IllegalBlockSizeException | BadPaddingException ex) { throw new RuntimeException(ex); } }
Source:
public void loadPageShouldThrowIllegalArgumentExceptionWhenParamOrderIsNull() throws Exception { this.mockMvc.perform(get(REQUEST_URL) .param("sort", NAME).param("order", null)); }

Target:
public void loadPageShouldThrowIllegalArgumentExceptionWhenParamOrderIsNull() throws Exception { this.mockMvc.perform(get(REQUEST_URL) .param(SORT, NAME).param(ORDER, null)); }
Source:
public void propertyChange(final PropertyChangeEvent event) { if(!"value".equals(event.getPropertyName())){ return; } final Stream<Boolean> evaluationStream = conditions.entrySet() .stream() .flatMap(e -> e.getValue() .stream()) .map(condition -> { final boolean negate = condition.isNegation(); return negate != Arrays.stream(condition.getValues()) .anyMatch(conditionValue -> evaluate( condition, conditionValue)); }); final boolean show = "OR".equalsIgnoreCase(operator) ? evaluationStream.anyMatch(i -> i) : evaluationStream.anyMatch(i -> i); sourceParameter.setShow(show); sourceParameter.redraw(); sourceParameter.firePropertyChange("show", null, show); }

Target:
public void propertyChange(final PropertyChangeEvent event) { if(!"value".equals(event.getPropertyName())){ return; } final boolean show = conditions.stream() .allMatch(group -> group.getAggregator().apply(group.getConditions().stream().map(this::evaluateCondition))); sourceParameter.setShow(show); sourceParameter.redraw(); sourceParameter.firePropertyChange("show", null, show); }
Source:
public void flush() { network.setDataCenterId(getSelectedDc().getId()); network.setName(getName().getEntity()); network.setStp(getIsStpEnabled().getEntity()); network.setDescription(getDescription().getEntity()); network.setComment(getComment().getEntity()); network.setVmNetwork(getIsVmNetwork().getEntity()); String label = getNetworkLabel().getSelectedItem(); if (getExternal().getEntity() && getPhysicalNetwork().getEntity()) { label = !getPhysicalNetworkDatacenter().getEntity() ? getNeutronPhysicalNetwork().getEntity() : null; } network.setLabel(label == null || !label.isEmpty() ? label : null); network.setMtu(0); if (getMtu().getIsChangable()) { network.setMtu(Integer.parseInt(getMtu().getEntity().toString())); } network.setDnsResolverConfiguration(getDnsConfigurationModel().flush()); network.setVlanId(null); if (getHasVLanTag().getEntity()) { network.setVlanId(Integer.parseInt(getVLanTag().getEntity().toString())); } for (VnicProfileModel profileModel : getProfiles().getItems()) { profileModel.flush(); } if (getQos().getIsChangable()) { HostNetworkQos qos = getQos().getSelectedItem(); network.setQosId(qos == EMPTY_HOST_NETWORK_QOS ? null : qos.getId()); } }

Target:
public void flush() { network.setDataCenterId(getSelectedDc().getId()); network.setName(getName().getEntity()); network.setStp(getIsStpEnabled().getEntity()); network.setDescription(getDescription().getEntity()); network.setComment(getComment().getEntity()); network.setVmNetwork(getIsVmNetwork().getEntity()); String label = getNetworkLabel().getSelectedItem(); if (getExternal().getEntity() && getPhysicalNetwork().getEntity()) { label = !getPhysicalNetworkDatacenter().getEntity() ? getNeutronPhysicalNetwork().getEntity() : null; } network.setLabel(StringHelper.isNotNullOrEmpty(label) ? label : null); network.setMtu(0); if (getMtu().getIsChangable()) { network.setMtu(Integer.parseInt(getMtu().getEntity().toString())); } network.setDnsResolverConfiguration(getDnsConfigurationModel().flush()); network.setVlanId(null); if (getHasVLanTag().getEntity()) { network.setVlanId(Integer.parseInt(getVLanTag().getEntity().toString())); } for (VnicProfileModel profileModel : getProfiles().getItems()) { profileModel.flush(); } if (getQos().getIsChangable()) { HostNetworkQos qos = getQos().getSelectedItem(); network.setQosId(qos == EMPTY_HOST_NETWORK_QOS ? null : qos.getId()); } }
Source:
public void testSkewedQuery() { int reservePool = 10; int generalPool = 12; ImmutableMap<String, Map<String, Long>> queries = ImmutableMap.<String, Map<String, Long>>builder() .put("q_1", ImmutableMap.of("n1", 0L, "n2", 8L, "n3", 0L, "n4", 0L, "n5", 0L)) .put("q_2", ImmutableMap.of("n1", 3L, "n2", 5L, "n3", 2L, "n4", 4L, "n5", 0L)) .put("q_3", ImmutableMap.of("n1", 0L, "n2", 0L, "n3", 9L, "n4", 0L, "n5", 0L)) .put("q_r", ImmutableMap.of("n1", 6L, "n2", 6L, "n3", 6L, "n4", 6L, "n5", 6L)) .build(); assertEquals( lowMemoryKiller.chooseQueryToKill( LowMemoryKillerTestingUtils.toQueryMemoryInfoList("q_r", queries), toNodeMemoryInfoList(reservePool, generalPool, "q_r", queries)), Optional.of(new QueryId("q_2"))); }

Target:
public void testSkewedQuery() { int reservePool = 10; int generalPool = 12; Map<String, Map<String, Long>> queries = ImmutableMap.<String, Map<String, Long>>builder() .put("q_1", ImmutableMap.of("n1", 0L, "n2", 8L, "n3", 0L, "n4", 0L, "n5", 0L)) .put("q_2", ImmutableMap.of("n1", 3L, "n2", 5L, "n3", 2L, "n4", 4L, "n5", 0L)) .put("q_3", ImmutableMap.of("n1", 0L, "n2", 0L, "n3", 9L, "n4", 0L, "n5", 0L)) .put("q_r", ImmutableMap.of("n1", 6L, "n2", 6L, "n3", 6L, "n4", 6L, "n5", 6L)) .build(); assertEquals( lowMemoryKiller.chooseQueryToKill( toQueryMemoryInfoList("q_r", queries), toNodeMemoryInfoList(reservePool, generalPool, "q_r", queries)), Optional.of(new QueryId("q_2"))); }
Source:
public void addTopicPartition(SystemStreamPartition ssp, long nextOffset) { LOG.info(String.format("Adding new topic and partition %s, offset = %s to queue for consumer %s", ssp, nextOffset, this)); topicPartitions2SSP.put(KafkaSystemConsumer.toTopicPartition(ssp), ssp); LOG.info(String.format("Got offset %s for new topic and partition %s.", nextOffset, ssp)); nextOffsets.put(ssp, nextOffset); kafkaConsumerMetrics.setTopicPartitionValue(metricName, nextOffsets.size()); }

Target:
public void addTopicPartition(SystemStreamPartition ssp, long nextOffset) { LOG.info(String.format("Adding new topicPartition %s with offset %s to queue for consumer %s", ssp, nextOffset, this)); topicPartitionToSSP.put(KafkaSystemConsumer.toTopicPartition(ssp), ssp); nextOffsets.put(ssp, nextOffset); kafkaConsumerMetrics.setNumTopicPartitions(metricName, nextOffsets.size()); }
Source:
private ClientRegistration.Builder createClientBuilder(String id) { ClientRegistration.Builder result = ClientRegistration.withRegistrationId(id); result.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE); result.redirectUriTemplate("{baseUrl}/login/oauth2/code/{registrationId}"); result.clientId(properties.getClientId()); result.clientSecret(properties.getClientSecret()); AuthorizationServerEndpoints endpoints = new AuthorizationServerEndpoints(properties.getAuthorizationServerUri()); result.authorizationUri(endpoints.authorizationEndpoint(properties.getTenantId())); result.tokenUri(endpoints.tokenEndpoint(properties.getTenantId())); result.jwkSetUri(endpoints.jwkSetEndpoint(properties.getTenantId())); Map<String, Object> configurationMetadata = new LinkedHashMap<>(); String tenantId = this.properties.getTenantId(); String endSessionEndpoint = String.format("<LINK_0>", StringUtils.hasText(tenantId) ? tenantId : "common"); configurationMetadata.put("end_session_endpoint", endSessionEndpoint); result.providerConfigurationMetadata(configurationMetadata); return result; }

Target:
private ClientRegistration.Builder createClientBuilder(String id) { ClientRegistration.Builder result = ClientRegistration.withRegistrationId(id); result.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE); result.redirectUriTemplate("{baseUrl}/login/oauth2/code/{registrationId}"); result.clientId(properties.getClientId()); result.clientSecret(properties.getClientSecret()); AuthorizationServerEndpoints endpoints = new AuthorizationServerEndpoints(properties.getAuthorizationServerUri()); result.authorizationUri(endpoints.authorizationEndpoint(properties.getTenantId())); result.tokenUri(endpoints.tokenEndpoint(properties.getTenantId())); result.jwkSetUri(endpoints.jwkSetEndpoint(properties.getTenantId())); Map<String, Object> configurationMetadata = new LinkedHashMap<>(); String endSessionEndpoint = endpoints.endSessionEndpoint(properties.getTenantId()); configurationMetadata.put("end_session_endpoint", endSessionEndpoint); result.providerConfigurationMetadata(configurationMetadata); return result; }
Source:
public BugzillaPeoplePart() { setPartName(Messages.BugzillaPeoplePart_People); }

Target:
public BugzillaPeoplePart() { }
Source:
private String getConnectorUlr(String accountId, List<Pair<String, String>> queryParams) { UriBuilder builder = UriBuilder .fromPath(connectorUrl) .path(format(CONNECTOR_CHARGES_RESOURCE, accountId)); queryParams.stream().forEach(pair -> { if (isNotBlank(pair.getRight())) { builder.queryParam(pair.getKey(), pair.getRight()); } }); return builder.toString(); }

Target:
private String getConnectorUlr(String accountId, List<Pair<String, String>> queryParams) { UriBuilder builder = UriBuilder .fromPath(connectorUrl) .path(format(CONNECTOR_CHARGES_RESOURCE, accountId)); queryParams.stream().forEach(pair -> { if (isNotBlank(pair.getRight())) { builder.queryParam(pair.getKey(), pair.getValue()); } }); return builder.toString(); }
Source:
public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); return dialog; }

Target:
public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreateDialog(savedInstanceState); Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); return dialog; }
Source:
@Override public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c, MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException { System.out.println("preBatchMutate my coproc " + this); throw new IOException(); }

Target:
public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c, MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException { throw new IOException(); }
Source:
public Sink<JetInputOutputFormat<KeyOut, ValueOut>> createDataSink(DataStore<KeyOut, ValueOut> dataOutStore) { JetEngine.dataOutStore = dataOutStore; Sink<JetInputOutputFormat<KeyOut, ValueOut>> sink = Sinks.fromProcessor("gora-jet-sink", new JetSink<KeyOut, ValueOut>()); return sink; }

Target:
public Sink<JetInputOutputFormat<KeyOut, ValueOut>> createDataSink(DataStore<KeyOut, ValueOut> dataOutStore) { JetEngine.dataOutStore = dataOutStore; return Sinks.fromProcessor("gora-jet-sink", new JetSink<KeyOut, ValueOut>()); }
Source:
private boolean hasUpServer(Guid clusterId) { if (getClusterUtils().hasMultipleServers(clusterId) && getClusterUtils().getUpServer(clusterId) == null) { addCanDoActionMessage(String.format("$clusterName %1$s", getVdsGroup(clusterId).getname())); addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NO_UP_SERVER_FOUND); return false; } return true; }

Target:
private boolean hasUpServer(Guid clusterId) { if (getClusterUtils().hasMultipleServers(clusterId) && getClusterUtils().getUpServer(clusterId) == null) { addCanDoActionMessage(String.format("$clusterName %1$s", getTargetCluster().getname())); addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NO_UP_SERVER_FOUND); return false; } return true; }
Source:
public void validate(Object target, Errors errors) { ConsentSignature sig = (ConsentSignature) target; if (Strings.isNullOrEmpty(sig.getName())) { errors.rejectValue("name", CANNOT_BE_BLANK); } if (minAgeOfConsent > 0) { if (Strings.isNullOrEmpty(sig.getBirthdate())) { errors.rejectValue("birthdate", CANNOT_BE_BLANK); } else { LocalDate birthdate = parseBirthday(errors, sig.getBirthdate()); if (birthdate != null) { LocalDate now = LocalDate.now(); Period period = new Period(birthdate, now); if (period.getYears() < minAgeOfConsent) { String message = String.format(TOO_YOUNG, minAgeOfConsent); errors.rejectValue("birthdate", message); } } } } else if (sig.getBirthdate() != null) { parseBirthday(errors, sig.getBirthdate()); } if (sig.getSignedOn() <= 0L) { errors.rejectValue("signedOn", "must be a valid signature timestamp"); } String imageData = sig.getImageData(); String imageMimeType = sig.getImageMimeType(); if (imageData != null && imageData.isEmpty()) { errors.rejectValue("imageData", CANNOT_BE_EMPTY_STRING); } if (imageMimeType != null && imageMimeType.isEmpty()) { errors.rejectValue("imageMimeType", CANNOT_BE_EMPTY_STRING); } if (imageData != null ^ imageMimeType != null) { errors.reject("must specify imageData and imageMimeType if you specify either of them"); } }

Target:
public void validate(Object target, Errors errors) { ConsentSignature sig = (ConsentSignature) target; if (Strings.isNullOrEmpty(sig.getName())) { errors.rejectValue("name", CANNOT_BE_BLANK); } if (Strings.isNullOrEmpty(sig.getBirthdate())) { if (minAgeOfConsent > 0) { errors.rejectValue("birthdate", CANNOT_BE_BLANK); } } else { LocalDate birthdate = parseBirthday(sig.getBirthdate()); if (birthdate == null) { errors.rejectValue("birthdate", "is invalid (required format: YYYY-MM-DD)"); } else if (minAgeOfConsent > 0) { LocalDate now = LocalDate.now(DateTimeZone.UTC); Period period = new Period(birthdate, now); if (period.getYears() < minAgeOfConsent) { String message = String.format(TOO_YOUNG, minAgeOfConsent); errors.rejectValue("birthdate", message); } } } if (sig.getSignedOn() <= 0L) { errors.rejectValue("signedOn", "must be a valid signature timestamp"); } String imageData = sig.getImageData(); String imageMimeType = sig.getImageMimeType(); if (imageData != null && imageData.isEmpty()) { errors.rejectValue("imageData", CANNOT_BE_EMPTY_STRING); } if (imageMimeType != null && imageMimeType.isEmpty()) { errors.rejectValue("imageMimeType", CANNOT_BE_EMPTY_STRING); } if (imageData != null ^ imageMimeType != null) { errors.reject("must specify imageData and imageMimeType if you specify either of them"); } }
Source:
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof IntegrationFlowBuilder.StandardIntegrationFlow) { return processStandardIntegrationFlow((IntegrationFlowBuilder.StandardIntegrationFlow) bean, beanName); } else if (bean instanceof IntegrationFlow) { return processLambdaIntegrationFlow((IntegrationFlow) bean, beanName); } return bean; }

Target:
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof IntegrationFlowBuilder.StandardIntegrationFlow) { return processStandardIntegrationFlow((IntegrationFlowBuilder.StandardIntegrationFlow) bean, beanName); } else if (bean instanceof IntegrationFlow) { return processIntegrationFlowImpl((IntegrationFlow) bean, beanName); } return bean; }
Source:
public void loadingStudyWithoutSignedConsentSmsTemplateAddsADefault() { Study study = TestUtils.getValidStudy(StudyServiceMockTest.class); study.setSignedConsentSmsTemplate(null); when(studyDao.getStudy("foo")).thenReturn(study); Study retStudy = service.getStudy("foo"); assertNotNull(retStudy.getAccountExistsSmsTemplate()); }

Target:
public void loadingStudyWithoutSignedConsentSmsTemplateAddsADefault() { Study study = TestUtils.getValidStudy(StudyServiceMockTest.class); study.setSignedConsentSmsTemplate(null); when(studyDao.getStudy("foo")).thenReturn(study); Study retStudy = service.getStudy("foo"); assertNotNull(retStudy.getSignedConsentSmsTemplate()); }
Source:
private boolean searchForDuplicatesWithExistingVmDevices(VmDevice vmDeviceToHotplug){ Map<String, String> addressMapToHotplug = XmlRpcStringUtils.string2Map(vmDeviceToHotplug.getAddress()); if (!addressMapToHotplug.containsKey("slot")){ return false; } List<VmDevice> allVmDevices = getVmDeviceDao().getVmDeviceByVmId(getVm().getId()); for (VmDevice vmDevice : allVmDevices) { if (vmDevice.getIsManaged() && !vmDeviceToHotplug.getId().equals(vmDevice.getId())){ Map<String, String> deviceAddressMap = XmlRpcStringUtils.string2Map(vmDevice.getAddress()); if(deviceAddressMap.equals(addressMapToHotplug)) { return true; } } } return false; }

Target:
private boolean searchForDuplicatesWithExistingVmDevices(VmDevice vmDeviceToHotplug){ String deviceAddress = vmDeviceToHotplug.getAddress(); if (StringUtils.isEmpty(deviceAddress)){ return false; } Map<String, String> addressMapToHotplug = XmlRpcStringUtils.string2Map(deviceAddress); List<VmDevice> allVmDevices = getVmDeviceDao().getVmDeviceByVmId(getVm().getId()); for (VmDevice vmDevice : allVmDevices) { if (!vmDeviceToHotplug.getId().equals(vmDevice.getId())){ Map<String, String> deviceAddressMap = XmlRpcStringUtils.string2Map(vmDevice.getAddress()); if(deviceAddressMap.equals(addressMapToHotplug)) { return true; } } } return false; }
Source:
public Object elementOfJsonPath(int index, String path) { List<Object> all = listJsonPathMatches(path); return all.size() > 0 ? all.get(index) : null; }

Target:
public Object elementOfJsonPath(int index, String path) { List<Object> all = listJsonPathMatches(path); return all.size() > index ? all.get(index) : null; }
Source:
public void testLoadBasicYamlFile() { final DirectoryYamlFlowLoader loader = new DirectoryYamlFlowLoader(new Props()); loader.loadProjectFlow(this.project, ExecutionsTestUtil.getFlowDir(BASIC_FLOW_YAML_DIR)); assertThat(loader.getErrors().size()).isEqualTo(0); assertThat(loader.getFlowMap().size()).isEqualTo(1); assertThat(loader.getFlowMap().containsKey(BASIC_FLOW_1)).isTrue(); final Flow flow = loader.getFlowMap().get(BASIC_FLOW_1); assertThat(flow.getNodes().size()).isEqualTo(4); assertThat(loader.getEdgeMap().size()).isEqualTo(1); assertFlowEdgeNoError(loader, flow, 3, BASIC_FLOW_1); }

Target:
public void testLoadBasicYamlFile() { final DirectoryYamlFlowLoader loader = new DirectoryYamlFlowLoader(new Props()); loader.loadProjectFlow(this.project, ExecutionsTestUtil.getFlowDir(BASIC_FLOW_YAML_DIR)); checkFlowLoaderProperties(loader, 0, 1, 1); checkFlowProperties(loader, BASIC_FLOW_1, 0, 4, 3, null); }
Source:
public <E> E get(String fieldName) { proxyState.getRealm$realm().checkIfValid(); long columnKey = proxyState.getRow$realm().getColumnKey(fieldName); if (proxyState.getRow$realm().isNull(columnKey)) { return null; } RealmFieldType type = proxyState.getRow$realm().getColumnType(columnKey); switch (type) { case BOOLEAN: return (E) Boolean.valueOf(proxyState.getRow$realm().getBoolean(columnKey)); case INTEGER: return (E) Long.valueOf(proxyState.getRow$realm().getLong(columnKey)); case FLOAT: return (E) Float.valueOf(proxyState.getRow$realm().getFloat(columnKey)); case DOUBLE: return (E) Double.valueOf(proxyState.getRow$realm().getDouble(columnKey)); case STRING: return (E) proxyState.getRow$realm().getString(columnKey); case BINARY: return (E) proxyState.getRow$realm().getBinaryByteArray(columnKey); case DATE: return (E) proxyState.getRow$realm().getDate(columnKey); case DECIMAL128: return (E) proxyState.getRow$realm().getDecimal128(columnKey); case OBJECT_ID: return (E) proxyState.getRow$realm().getObjectId(columnKey); case OBJECT: return (E) getObject(fieldName); case LIST: return (E) getList(fieldName); default: throw new IllegalStateException("Field type not supported: " + type); } }

Target:
public <E> E get(String fieldName) { proxyState.getRealm$realm().checkIfValid(); long columnKey = proxyState.getRow$realm().getColumnKey(fieldName); if (proxyState.getRow$realm().isNull(columnKey)) { return null; } RealmFieldType type = proxyState.getRow$realm().getColumnType(columnKey); switch (type) { case BOOLEAN: return (E) Boolean.valueOf(proxyState.getRow$realm().getBoolean(columnKey)); case INTEGER: return (E) Long.valueOf(proxyState.getRow$realm().getLong(columnKey)); case FLOAT: return (E) Float.valueOf(proxyState.getRow$realm().getFloat(columnKey)); case DOUBLE: return (E) Double.valueOf(proxyState.getRow$realm().getDouble(columnKey)); case STRING: return (E) proxyState.getRow$realm().getString(columnKey); case BINARY: return (E) proxyState.getRow$realm().getBinaryByteArray(columnKey); case DATE: return (E) proxyState.getRow$realm().getDate(columnKey); case OBJECT: return (E) getObject(fieldName); case LIST: return (E) getList(fieldName); default: throw new IllegalStateException("Field type not supported: " + type); } }
Source:
public boolean updateApi(String apiName, APIData apiData) throws APIException{ final Lock lock = getLock(); try { lock.lock(); assertNameNotEmpty(apiName); API oldAPI = null; API api = APIFactory.createAPI(RestApiAdminUtils.retrieveAPIOMElement(apiData)); SynapseConfiguration synapseConfiguration = getSynapseConfiguration(); oldAPI = synapseConfiguration.getAPI(apiName); if (oldAPI != null) { oldAPI.destroy(); api.setFileName(oldAPI.getFileName()); } synapseConfiguration.updateAPI(apiName, api); api.init(getSynapseEnvironment()); CAppArtifactDataService cAppArtifactDataService = ConfigHolder.getInstance(). getcAppArtifactDataService(); if (cAppArtifactDataService.isArtifactDeployedFromCApp(getTenantId(), ServiceBusConstants.API_TYPE + File.separator + apiName)) { cAppArtifactDataService.setEdited(getTenantId(), ServiceBusConstants.API_TYPE + File.separator + apiName); } else { MediationPersistenceManager pm = getMediationPersistenceManager(); String fileName = api.getFileName(); pm.deleteItem(apiName, fileName, ServiceBusConstants.ITEM_TYPE_REST_API); pm.saveItem(apiName, ServiceBusConstants.ITEM_TYPE_REST_API); } return true; } catch (Exception e) { e.printStackTrace(); return false; } finally { lock.unlock(); } }

Target:
public boolean updateApi(String apiName, APIData apiData) throws APIException{ final Lock lock = getLock(); try { lock.lock(); assertNameNotEmpty(apiName); API oldAPI = null; API api = APIFactory.createAPI(RestApiAdminUtils.retrieveAPIOMElement(apiData)); SynapseConfiguration synapseConfiguration = getSynapseConfiguration(); oldAPI = synapseConfiguration.getAPI(apiName); if (oldAPI != null) { oldAPI.destroy(); api.setFileName(oldAPI.getFileName()); } synapseConfiguration.updateAPI(apiName, api); api.init(getSynapseEnvironment()); CAppArtifactDataService cAppArtifactDataService = ConfigHolder.getInstance(). getcAppArtifactDataService(); String artifactName = getArtifactName(artifactType, apiName); if (cAppArtifactDataService.isArtifactDeployedFromCApp(getTenantId(), artifactName)) { cAppArtifactDataService.setEdited(getTenantId(), artifactName); } else { MediationPersistenceManager pm = getMediationPersistenceManager(); String fileName = api.getFileName(); pm.deleteItem(apiName, fileName, ServiceBusConstants.ITEM_TYPE_REST_API); pm.saveItem(apiName, ServiceBusConstants.ITEM_TYPE_REST_API); } return true; } catch (Exception e) { handleException(log, "Could not update API ", e); return false; } finally { lock.unlock(); } }
Source:
public String getNextName(IServer server, DockerConnectionManager mgr) { IDockerConnection[] cons = mgr.getConnections(); ArrayList<String> names = new ArrayList<String>(); for( int i = 0; i < cons.length; i++ ) { names.add(cons[i].getName()); } final String nameBase = server.getName(); String name = nameBase; int count = 0; boolean done = false; while(!done) { if( names.contains(name)) { count++; name = nameBase + " (" + count + ")"; } else { done = true; } } return name; }

Target:
public String getNextName(IServer server, DockerConnectionManager mgr) { IDockerConnection[] cons = mgr.getConnections(); List<String> names = Arrays.stream(cons).map(IDockerConnection::getName).collect(Collectors.toList()); final String nameBase = server.getName(); String name = nameBase; int count = 0; boolean done = false; while(!done) { if( names.contains(name)) { count++; name = nameBase + " (" + count + ")"; } else { done = true; } } return name; }
Source:
private <T> T errorReplicating(Throwable t) { log.unexpectedErrorReplicating(t); if (statisticsEnabled) replicationFailures.incrementAndGet(); return rethrowAsCacheException(t); }

Target:
private <T> T errorReplicating(Throwable t) { CLUSTER.unexpectedErrorReplicating(t); if (statisticsEnabled) replicationFailures.incrementAndGet(); return rethrowAsCacheException(t); }
Source:
public Long getBytes(Properties properties) { String value = getValue(properties); if (value.isEmpty()) { return null; } return ConfigurationTypeHelper.getMemoryAsBytes(value); }

Target:
public Long getBytes(Properties properties) { String value = getValue(properties); if (value.isEmpty()) { return null; } checkState(getType() == PropertyType.BYTES, "Invalid type getting bytes. Type must be " + PropertyType.BYTES + ", not " + getType()); return ConfigurationTypeHelper.getMemoryAsBytes(value); }
Source:
public boolean isSupported(Node node) { if (node == null) { return false; } if(node.getLookup().lookupAll(BlackboardArtifact.class).size() > 0) { return false; } AbstractFile file = node.getLookup().lookup(AbstractFile.class); if (file != null && file.getSize() > 0 && file.isFile()) { String acceptedMIMEType = NbBundle.getMessage(this.getClass(), "DataContentViewerHTML.acceptedMIMEType"); if(file.getMIMEType() == null) { if(fileTypeDetector == null) return false; try { return fileTypeDetector.detect(file).equals(acceptedMIMEType); } catch (TskCoreException ex) { Exceptions.printStackTrace(ex); return false; } } else return file.getMIMEType().equals(acceptedMIMEType); } return false; }

Target:
public boolean isSupported(Node node) { if (node == null) { return false; } if(node.getLookup().lookupAll(BlackboardArtifact.class).size() > 0) { return false; } AbstractFile file = node.getLookup().lookup(AbstractFile.class); if (file != null && file.getSize() > 0 && file.isFile()) { if(file.getMIMEType() == null) { if(fileTypeDetector == null) return false; try { return fileTypeDetector.detect(file).equals(acceptedMIMEType); } catch (TskCoreException ex) { logger.log(Level.WARNING, "An error occurred while detecting a file" + " type in the HTML content viewer.", ex); return false; } } else return file.getMIMEType().equals(acceptedMIMEType); } return false; }
Source:
public void start() { A.ensure(getSingleTupleExtractor() != null || getMultipleTupleExtractor() != null, "ZeroMq extractor."); log = getIgnite().log(); if (isStart) { log.info("Attempted to start an already started ZeroMQ streamer"); return; } isStart = true; ctx = ZMQ.context(ioThreads); socket = ctx.socket(socketType); socket.connect(addr); if (ZeroMqTypeSocket.SUB.getType() == socketType) socket.subscribe(topic); zeroMqExSrv = Executors.newFixedThreadPool(threadsCount); for (int i = 0; i < threadsCount; i++) { Callable<Boolean> task = new Callable<Boolean>() { @Override public Boolean call() { while (true) { if (ZeroMqTypeSocket.SUB.getType() == socketType) socket.recv(); addMessage(socket.recv()); } } }; zeroMqExSrv.submit(task); } }

Target:
public void start() { A.ensure(getSingleTupleExtractor() != null || getMultipleTupleExtractor() != null, "ZeroMq extractor."); log = getIgnite().log(); if (isStarted) { log.warning("Attempted to start an already started ZeroMQ streamer"); return; } isStarted = true; zeroMqExSrv = Executors.newSingleThreadExecutor(); ctx = ZMQ.context(ioThreads); zeroMqExSrv.execute(new Runnable() { @Override public void run() { ZMQ.Socket socket = ctx.socket(socketType); socket.connect(addr); if (ZeroMqTypeSocket.SUB.getType() == socketType) socket.subscribe(topic); while (isStarted) { try { if (ZeroMqTypeSocket.SUB.getType() == socketType) socket.recv(0); addMessage(socket.recv(0)); } catch (ZMQException e) { if (e.getErrorCode () == ZMQ.Error.ETERM.getCode ()) { break; } } } socket.close(); } }); }