auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public List<SchemaTableName> getTableNames(@Nullable String schema) { try (Connection connection = driver.connect(connectionUrl, connectionProperties)) { DatabaseMetaData metadata = connection.getMetaData(); schema = finalizeSchemaName(metadata, schema); Map<String, Map<String, String>> schemaMappedNames = new HashMap<>(); ImmutableList.Builder<SchemaTableName> list = ImmutableList.builder(); for (CaseSensitiveMappedSchemaTableName table : getOriginalTablesWithSchema(connection, schema)) { Map<String, String> mappedNames = schemaMappedNames.computeIfAbsent(table.getSchemaName(), s -> new HashMap<>()); mappedNames.put(table.getSchemaNameLower(), table.getTableName()); list.add(new SchemaTableName(table.getSchemaNameLower(), table.getTableNameLower())); } for (Map.Entry<String, Map<String, String>> entry : schemaMappedNames.entrySet()) { updateTableMapping(entry.getKey(), entry.getValue()); } return list.build(); } catch (SQLException e) { throw new PrestoException(JDBC_ERROR, e); } }

Target:
public List<SchemaTableName> getTableNames(@Nullable String schema) { try (Connection connection = driver.connect(connectionUrl, connectionProperties)) { DatabaseMetaData metadata = connection.getMetaData(); schema = finalizeSchemaName(metadata, schema); Map<String, Map<String, String>> schemaMappedNames = new HashMap<>(); ImmutableList.Builder<SchemaTableName> tableNameList = ImmutableList.builder(); for (CaseSensitiveMappedSchemaTableName table : getOriginalTablesWithSchema(connection, schema)) { Map<String, String> mappedNames = schemaMappedNames.computeIfAbsent(table.getSchemaName(), s -> new HashMap<>()); mappedNames.put(table.getSchemaNameLower(), table.getTableName()); tableNameList.add(new SchemaTableName(table.getSchemaNameLower(), table.getTableNameLower())); } for (Map.Entry<String, Map<String, String>> entry : schemaMappedNames.entrySet()) { updateTableMapping(entry.getKey(), entry.getValue()); } return tableNameList.build(); } catch (SQLException e) { throw new PrestoException(JDBC_ERROR, e); } }
Source:
public Attribute getAttributeValue(PerunSessionImpl sess, User user, AttributeDefinition attributeDefinition) throws InternalErrorException { Attribute attribute = new Attribute(attributeDefinition); List<String> groupNames = new ArrayList<>(); List<Map<String, Object>> names = sess.getPerunBl().getDatabaseManagerBl().getJdbcPerunTemplate().queryForList("SELECT" + " DISTINCT vos.short_name AS vo_short_name, groups.name AS group_name" + " FROM" + " members" + " JOIN vos ON vos.id = members.vo_id" + " JOIN groups_members ON groups_members.member_id = members.id" + " JOIN groups ON groups_members.group_id = groups.id" + " WHERE" + " groups_members.source_group_status = ?" + " AND members.user_id = ?", MemberGroupStatus.VALID.getCode(), user.getId()); Set<String> voNames = new HashSet<>(); for (Map<String, Object> one : names) { if (!VosManager.MEMBERS_GROUP.equals(one.get("group_name"))) { String voShortName = (String) one.get("vo_short_name"); voNames.add(voShortName); String groupName = (String) one.get("group_name"); groupNames.add(voShortName + ":" + groupName); } } groupNames.addAll(voNames); attribute.setValue(groupNames); return attribute; }

Target:
public Attribute getAttributeValue(PerunSessionImpl sess, User user, AttributeDefinition attributeDefinition) throws InternalErrorException { Attribute attribute = new Attribute(attributeDefinition); Set<String> groupNames = new TreeSet<>(); List<Pair<String, String>> names; try { names = sess.getPerunBl().getDatabaseManagerBl().getJdbcPerunTemplate().query( "SELECT" + " DISTINCT vos.short_name AS vo_short_name, groups.name AS group_name" + " FROM" + " members" + " JOIN vos ON vos.id = members.vo_id AND members.user_id = ?" + " JOIN groups_members ON groups_members.member_id = members.id AND groups_members.source_group_status = ?" + " JOIN groups ON groups_members.group_id = groups.id" + " ORDER BY vo_short_name, group_name", ROW_MAPPER, user.getId(), MemberGroupStatus.VALID.getCode()); } catch(EmptyResultDataAccessException e) { names = new ArrayList<>(); } catch (RuntimeException e) { throw new InternalErrorException(e); } for (Pair<String, String> one : names) { String voShortName = one.getLeft(); groupNames.add(voShortName); if (!VosManager.MEMBERS_GROUP.equals(one.getRight())) { String groupName = one.getRight(); groupNames.add(voShortName + ":" + groupName); } } attribute.setValue(new ArrayList<>(groupNames)); return attribute; }
Source:
public SerializationSchema<Row> createSerializationSchema(Map<String, String> properties) { final DescriptorProperties descriptorProperties = getValidatedProperties(properties); final CsvRowSerializationSchema.Builder schemaBuilder = new CsvRowSerializationSchema.Builder( createTypeInformation(descriptorProperties)); descriptorProperties.getOptionalCharacter(CsvValidator.FORMAT_FIELD_DELIMITER) .ifPresent(schemaBuilder::setFieldDelimiter); if (descriptorProperties.getOptionalBoolean(CsvValidator.FORMAT_DISABLE_QUOTE_CHARACTER).orElse(false)) { schemaBuilder.disableQuoteCharacter(); } else { descriptorProperties.getOptionalCharacter(CsvValidator.FORMAT_QUOTE_CHARACTER).ifPresent(schemaBuilder::setQuoteCharacter); } descriptorProperties.getOptionalString(CsvValidator.FORMAT_ARRAY_ELEMENT_DELIMITER) .ifPresent(schemaBuilder::setArrayElementDelimiter); descriptorProperties.getOptionalCharacter(CsvValidator.FORMAT_ESCAPE_CHARACTER) .ifPresent(schemaBuilder::setEscapeCharacter); descriptorProperties.getOptionalString(CsvValidator.FORMAT_NULL_LITERAL) .ifPresent(schemaBuilder::setNullLiteral); return schemaBuilder.build(); }

Target:
public SerializationSchema<Row> createSerializationSchema(Map<String, String> properties) { final DescriptorProperties descriptorProperties = getValidatedProperties(properties); final CsvRowSerializationSchema.Builder schemaBuilder = new CsvRowSerializationSchema.Builder( createTypeInformation(descriptorProperties)); descriptorProperties.getOptionalCharacter(CsvValidator.FORMAT_FIELD_DELIMITER) .ifPresent(schemaBuilder::setFieldDelimiter); descriptorProperties.getOptionalString(CsvValidator.FORMAT_LINE_DELIMITER) .ifPresent(schemaBuilder::setLineDelimiter); if (descriptorProperties.getOptionalBoolean(CsvValidator.FORMAT_DISABLE_QUOTE_CHARACTER).orElse(false)) { schemaBuilder.disableQuoteCharacter(); } else { descriptorProperties.getOptionalCharacter(CsvValidator.FORMAT_QUOTE_CHARACTER).ifPresent(schemaBuilder::setQuoteCharacter); } descriptorProperties.getOptionalString(CsvValidator.FORMAT_ARRAY_ELEMENT_DELIMITER) .ifPresent(schemaBuilder::setArrayElementDelimiter); descriptorProperties.getOptionalCharacter(CsvValidator.FORMAT_ESCAPE_CHARACTER) .ifPresent(schemaBuilder::setEscapeCharacter); descriptorProperties.getOptionalString(CsvValidator.FORMAT_NULL_LITERAL) .ifPresent(schemaBuilder::setNullLiteral); return schemaBuilder.build(); }
Source:
protected void onFetchVms() { logBuilder = new StringBuilder(String.format("Poll %s:", vdsManager.getVdsId())); super.onFetchVms(); logBuilder.append(String.format("(%d VMs)", vmsCounter)); log.info(logBuilder.toString()); }

Target:
protected void onFetchVms() { logBuilder = new StringBuilder(String.format("Poll %s:", vdsManager.getVdsId())); super.onFetchVms(); logBuilder.append(String.format("(%d VMs)", changedVms.size())); log.info(logBuilder.toString()); }
Source:
private static List<IResource> getReadonlyFiles(IResource[] resources) { List<IResource> readOnlyFiles= new ArrayList<IResource>(); for (int i= 0; i < resources.length; i++) { IResource resource= resources[i]; ResourceAttributes resourceAttributes= resource.getResourceAttributes(); if (resource.getType() == IResource.FILE && resourceAttributes != null && resourceAttributes.isReadOnly()) readOnlyFiles.add(resource); } return readOnlyFiles; }

Target:
private static List<IResource> getReadonlyFiles(IResource[] resources) { List<IResource> readOnlyFiles= new ArrayList<>(); for (IResource resource : resources) { ResourceAttributes resourceAttributes= resource.getResourceAttributes(); if (resource.getType() == IResource.FILE && resourceAttributes != null && resourceAttributes.isReadOnly()) readOnlyFiles.add(resource); } return readOnlyFiles; }
Source:
default String getTaskGroupId(DatastreamTask task, Optional<Logger> logger) { Set<String> groupIds = DatastreamUtils.getMetadataGroupIDs(task.getDatastreams()); if (!groupIds.isEmpty()) { if (groupIds.size() != 1) { String errMsg = String.format("Found multiple consumer group ids for connector task: %s. Group IDs: %s. Datastreams: %s", task.getId(), groupIds, task.getDatastreams()); throw new DatastreamRuntimeException(errMsg); } if (logger.isPresent()) { logger.get().info("Found overridden group ID for Kafka datastream task: . Overridden group id: Datastreams: %s", task.getId(), groupIds.toArray()[0], task.getDatastreams()); } return (String) groupIds.toArray()[0]; } else { String groupId = constructGroupId(task); if (logger.isPresent()) { logger.get().info(String.format("Constructed group ID: %s for task: %s", groupId, task.getId())); } return groupId; } }

Target:
default String getTaskGroupId(DatastreamTask task, Optional<Logger> logger) { Set<String> groupIds = DatastreamUtils.getMetadataGroupIDs(task.getDatastreams()); if (!groupIds.isEmpty()) { if (groupIds.size() != 1) { String errMsg = String.format("Found multiple consumer group ids for connector task: %s. Group IDs: %s. Datastreams: %s", task.getId(), groupIds, task.getDatastreams()); throw new DatastreamRuntimeException(errMsg); } logger.ifPresent(log -> log.info( "Found overridden group ID for Kafka datastream task: . Overridden group id: Datastreams: {}", task.getId(), groupIds.toArray()[0], task.getDatastreams())); return (String) groupIds.toArray()[0]; } else { String groupId = constructGroupId(task); logger.ifPresent(log -> log.info("Constructed group ID: for task: {}", groupId, task.getId())); return groupId; } }
Source:
public double injectEnergy( EnumFacing directionFrom, double amount, double voltage ) { TunnelCollection<PartP2PIC2Power> outs; try { outs = this.getOutputs(); } catch( GridAccessException e ) { return amount; } if( outs.isEmpty() ) { return amount; } LinkedList<PartP2PIC2Power> options = new LinkedList<>(); for( PartP2PIC2Power o : outs ) { if( o.OutputEnergyA <= 0.01 ) { options.add( o ); } } if( options.isEmpty() ) { for( PartP2PIC2Power o : outs ) { if( o.OutputEnergyB <= 0.01 ) { options.add( o ); } } } if( options.isEmpty() ) { for( PartP2PIC2Power o : outs ) { options.add( o ); } } if( options.isEmpty() ) { return amount; } PartP2PIC2Power x = Platform.pickRandom( options ); if( x != null && x.OutputEnergyA <= 0.001 ) { this.queueTunnelDrain( PowerUnits.EU, amount ); x.OutputEnergyA = amount; x.OutputVoltageA = voltage; return 0; } if( x != null && x.OutputEnergyB <= 0.001 ) { this.queueTunnelDrain( PowerUnits.EU, amount ); x.OutputEnergyB = amount; x.OutputVoltageB = voltage; return 0; } return amount; }

Target:
public double injectEnergy( EnumFacing directionFrom, double amount, double voltage ) { TunnelCollection<PartP2PIC2Power> outs; try { outs = this.getOutputs(); } catch( GridAccessException e ) { return amount; } if( outs.isEmpty() ) { return amount; } LinkedList<PartP2PIC2Power> options = new LinkedList<>(); for( PartP2PIC2Power o : outs ) { if( o.bufferedEnergy1 <= 0.01 ) { options.add( o ); } } if( options.isEmpty() ) { for( PartP2PIC2Power o : outs ) { if( o.bufferedEnergy2 <= 0.01 ) { options.add( o ); } } } if( options.isEmpty() ) { for( PartP2PIC2Power o : outs ) { options.add( o ); } } if( options.isEmpty() ) { return amount; } PartP2PIC2Power x = Platform.pickRandom( options ); if( x != null && x.bufferedEnergy1 <= 0.001 ) { this.queueTunnelDrain( PowerUnits.EU, amount ); x.bufferedEnergy1 = amount; x.bufferedVoltage1 = voltage; return 0; } if( x != null && x.bufferedEnergy2 <= 0.001 ) { this.queueTunnelDrain( PowerUnits.EU, amount ); x.bufferedEnergy2 = amount; x.bufferedVoltage2 = voltage; return 0; } return amount; }
Source:
public static void setup(Level level, String logLocation) { if (logLocation != null && !ConsoleAppender.SYSTEM_ERR.equals(logLocation) && !ConsoleAppender.SYSTEM_OUT.equals(logLocation)) { RollingFileAppender fa = new RollingFileAppender(); fa.setName("FileLogger"); fa.setFile(logLocation); fa.setMaxFileSize("5MB"); fa.setMaxBackupIndex(1); fa.setLayout(new PatternLayout(LOGGER_LAYOUT)); fa.setThreshold(level); fa.setAppend(true); fa.activateOptions(); Logger.getRootLogger().addAppender(fa); LOGGER.info("File Handler set"); } else { ConsoleAppender consoleAppender = new ConsoleAppender(new PatternLayout(LOGGER_LAYOUT), logLocation); if (logLocation != null) { consoleAppender.setTarget(logLocation); } consoleAppender.setThreshold(level); Logger.getRootLogger().addAppender(consoleAppender); } }

Target:
public static void setup(Level level, String logLocation) { if (logLocation != null && !ConsoleAppender.SYSTEM_ERR.equals(logLocation) && !ConsoleAppender.SYSTEM_OUT.equals(logLocation)) { RollingFileAppender fa = new RollingFileAppender(); fa.setName("FileLogger"); fa.setFile(logLocation); fa.setMaxFileSize("5MB"); fa.setMaxBackupIndex(1); fa.setLayout(new PatternLayout(LOGGER_LAYOUT)); fa.setThreshold(level); fa.setAppend(true); fa.activateOptions(); Logger.getRootLogger().addAppender(fa); LOGGER.info("File Handler set"); } else { ConsoleAppender consoleAppender = new ConsoleAppender(new PatternLayout(LOGGER_LAYOUT)); if (logLocation != null) { consoleAppender.setTarget(logLocation); } consoleAppender.setThreshold(level); Logger.getRootLogger().addAppender(consoleAppender); } }
Source:
public Iterator<T> iterator() { return new Iterator<T>() { int a = start; T prev = null; T next = null; private void peekNext() { while (next == null && a < start + size) { T e = (T) data[++a - 1]; if (toRemove.remove(e)) { dataAsSet.remove(e); data[--a] = data[start + --size]; } else { next = e; } } } @Override public boolean hasNext() { peekNext(); return next != null; } @Override public T next() { peekNext(); if (next == null) throw new ArrayIndexOutOfBoundsException(); prev = next; next = null; return prev; } @Override public void remove() { dataAsSet.remove(prev); data[--a] = data[start + --size]; } }; }

Target:
public Iterator<T> iterator() { return new Iterator<T>() { int i = start; T prev = null; T next = null; private void peekNext() { while (next == null && i < start + size) { T e = (T) data[i++]; if (!toRemove.contains(e)) { next = e; } } } @Override public boolean hasNext() { peekNext(); return next != null; } @Override public T next() { peekNext(); if (next == null) throw new ArrayIndexOutOfBoundsException(); prev = next; next = null; return prev; } @Override public void remove() { toRemove.add(prev); } }; }
Source:
public DbUser(DbUser dbUser) { id = dbUser.getId(); externalId = dbUser.getExternalId(); domain = dbUser.getDomain(); namespace = dbUser.getNamespace(); loginName = dbUser.getLoginName(); firstName = dbUser.getFirstName(); lastName = dbUser.getLastName(); department = dbUser.getDepartment(); email = dbUser.getEmail(); note = dbUser.getNote(); groupIds = new ArrayList<>(dbUser.getGroupIds()); groupNames = new ArrayList<>(dbUser.getGroupNames()); isAdmin = dbUser.isAdmin(); }

Target:
public DbUser(DbUser dbUser) { if (dbUser == null) { loginName = ""; firstName = ""; lastName = ""; department = ""; groupNames = Collections.emptyList(); groupIds = Collections.emptyList(); note = ""; } else { id = dbUser.getId(); externalId = dbUser.getExternalId(); domain = dbUser.getDomain(); namespace = dbUser.getNamespace(); loginName = dbUser.getLoginName(); firstName = dbUser.getFirstName(); lastName = dbUser.getLastName(); department = dbUser.getDepartment(); email = dbUser.getEmail(); note = dbUser.getNote(); groupIds = new ArrayList<>(dbUser.getGroupIds()); groupNames = new ArrayList<>(dbUser.getGroupNames()); isAdmin = dbUser.isAdmin(); } }
Source:
public int compareTo(ComparableSplit other) { try { long cmp = rawInputSplit.getLength() - other.rawInputSplit.getLength(); return cmp == 0 ? (id == other.id ? 0 : id < other.id ? -1 : 1) : cmp < 0 ? 1 : -1; } catch (IOException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } }

Target:
public int compareTo(ComparableSplit other) { try { int cmp = -Long.signum(rawInputSplit.getLength() - other.rawInputSplit.getLength()); return cmp == 0 ? Long.signum(id - other.id) : cmp; } catch (IOException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } }
Source:
public Cluster getSingleCluster() { Preconditions.checkState(getClusters().getClustersCount() != 0, "There must be at least one matching cluster for this method to work"); Preconditions.checkState(getClusters().getClustersCount() == 1, "There can only be one cluster for this method to work."); return getClusters().getClusters(0); }

Target:
public Cluster getSingleCluster() { ListClustersResponse response = getClusters(); Preconditions.checkState(response.getClustersCount() != 0, "The instance does not exist."); Preconditions.checkState(response.getClustersCount() == 1, "There can only be one cluster for this method to work."); return response.getClusters(0); }
Source:
public static double getNightFactor(final double value, final World world) { if (isNight(world)) { return getConfig().getDouble("Properties.Water.NightFactor") * value; } else { return value; } }

Target:
public static double getNightFactor(final double value, final World world) { if (isNight(world)) { return value * getNightFactor(); } return value; }
Source:
public void removeContainer(final String containerId, final RemoveContainerParam... params) throws DockerException, InterruptedException { try { WebTarget resource = resource().path("containers").path(containerId); for (final RemoveContainerParam param : params) { resource = resource.queryParam(param.name().toLowerCase(Locale.ROOT), param.value()); } request(DELETE, resource, resource.request(APPLICATION_JSON_TYPE)); } catch (DockerRequestException e) { switch (e.status()) { case 404: throw new ContainerNotFoundException(containerId, e); default: throw e; } } }

Target:
public void removeContainer(final String containerId, final RemoveContainerParam... params) throws DockerException, InterruptedException { try { WebTarget resource = resource().path("containers").path(containerId); for (final RemoveContainerParam param : params) { resource = resource.queryParam(param.name(), param.value()); } request(DELETE, resource, resource.request(APPLICATION_JSON_TYPE)); } catch (DockerRequestException e) { switch (e.status()) { case 404: throw new ContainerNotFoundException(containerId, e); default: throw e; } } }
Source:
protected void runTask() { OwlTelescopeReporter telescope = OwlTelescopeReporterFactory.getInstance().getTelescopeReporter( OwlTelescopeReporters.AMAZON_UNBOX_UPDATE_TASK, Event.Type.INGEST ); telescope.startReporting(); try { AmazonUnboxProcessor<UpdateProgress> processor = processor(itemPreProcessor, telescope); ImmutableList<AmazonUnboxItem> items = feedSupplier.get(); for (AmazonUnboxItem item : items) { processor.process(item); } itemPreProcessor.finish(telescope); reportStatus("Preprocessor: " + processor.getResult().toString()); processor = processor(itemProcessor, telescope); for (AmazonUnboxItem item : items) { processor.process(item); } itemProcessor.finish(telescope); reportStatus(processor.getResult().toString()); } catch (Exception e) { telescope.reportFailedEvent(e.getMessage()); reportStatus(e.getMessage()); Throwables.propagate(e); } finally { telescope.endReporting(); } }

Target:
protected void runTask() { OwlTelescopeReporter telescope = OwlTelescopeReporterFactory.getInstance().getTelescopeReporter( OwlTelescopeReporters.AMAZON_UNBOX_UPDATE_TASK, Event.Type.INGEST ); telescope.startReporting(); try { AmazonUnboxProcessor<UpdateProgress> processor = processor(itemPreProcessor, telescope); ImmutableList<AmazonUnboxItem> items = feedSupplier.get(); for (AmazonUnboxItem item : items) { processor.process(item); } itemPreProcessor.finish(telescope); reportStatus("Preprocessor: " + processor.getResult().toString()); processor = processor(itemProcessor, telescope); for (AmazonUnboxItem item : items) { processor.process(item); } itemProcessor.finish(telescope); reportStatus(processor.getResult().toString()); } catch (Exception e) { telescope.reportFailedEvent("An exception has prevented this task from completing properly (" + e.getMessage() + ")"); reportStatus(e.getMessage()); Throwables.propagate(e); } telescope.endReporting(); }
Source:
void configureWithCustomSetIntervalProperties() { this.contextRunner.withPropertyValues("spring.elasticsearch.rest.sniffInterval=15s, " + "spring.elasticsearch.rest.sniffFailureDelay=15s").run((context) -> { Assert.assertNotNull(context.getBean(Sniffer.class)); }); }

Target:
void configureWithCustomSetIntervalProperties() { this.contextRunner.withPropertyValues( "spring.elasticsearch.rest.sniffInterval=1m, " + "spring.elasticsearch.rest.sniffFailureDelay=1m") .run((context) -> { Assert.assertNotNull(context.getBean(Sniffer.class)); assertThat(context).hasSingleBean(RestHighLevelClient.class); RestHighLevelClient restClient = context.getBean(RestHighLevelClient.class); assertThat(restClient.getLowLevelClient()).extracting("spring.elasticsearch.rest.sniffInterval") .isEqualTo(Math.toIntExact(Duration.ofMinutes(1L).toMillis())); assertThat(restClient.getLowLevelClient()).extracting("spring.elasticsearch.rest.sniffFailureDelay") .isEqualTo(Math.toIntExact(Duration.ofMinutes(1L).toMillis())); }); }
Source:
public void onConfigureClusterSnapshotOptions() { GlusterClusterSnapshotConfigModel clusterSnapshotConfigModel = (GlusterClusterSnapshotConfigModel) getWindow(); if (!clusterSnapshotConfigModel.validate()) { return; } Guid clusterId = clusterSnapshotConfigModel.getClusters().getSelectedItem().getId(); List<GlusterVolumeSnapshotConfig> vdsParams = new ArrayList<GlusterVolumeSnapshotConfig>(); for (EntityModel<GlusterVolumeSnapshotConfig> clusterCfg : clusterSnapshotConfigModel.getClusterConfigOptions() .getItems()) { vdsParams.add(new GlusterVolumeSnapshotConfig(clusterId, null, clusterCfg.getEntity().getParamName(), clusterCfg.getEntity().getParamValue())); } Frontend.getInstance().runAction(VdcActionType.UpdateGlusterVolumeSnapshotConfig, new UpdateGlusterVolumeSnapshotConfigParameters(clusterId, null, vdsParams), new IFrontendActionAsyncCallback() { @Override public void executed(FrontendActionAsyncResult result) { if (result.getReturnValue() != null && result.getReturnValue().getSucceeded()) { cancel(); } if (getConfirmWindow() != null) { setConfirmWindow(null); } } }, this); }

Target:
public void onConfigureClusterSnapshotOptions() { GlusterClusterSnapshotConfigModel clusterSnapshotConfigModel = (GlusterClusterSnapshotConfigModel) getWindow(); Guid clusterId = clusterSnapshotConfigModel.getClusters().getSelectedItem().getId(); List<GlusterVolumeSnapshotConfig> vdsParams = new ArrayList<GlusterVolumeSnapshotConfig>(); for (EntityModel<GlusterVolumeSnapshotConfig> clusterCfg : clusterSnapshotConfigModel.getClusterConfigOptions() .getItems()) { vdsParams.add(new GlusterVolumeSnapshotConfig(clusterId, null, clusterCfg.getEntity().getParamName(), clusterCfg.getEntity().getParamValue())); } Frontend.getInstance().runAction(VdcActionType.UpdateGlusterVolumeSnapshotConfig, new UpdateGlusterVolumeSnapshotConfigParameters(clusterId, null, vdsParams), new IFrontendActionAsyncCallback() { @Override public void executed(FrontendActionAsyncResult result) { if (result.getReturnValue() != null && result.getReturnValue().getSucceeded()) { cancel(); } if (getConfirmWindow() != null) { setConfirmWindow(null); } } }, this); }
Source:
public XmlWorkflowItem createWorkflowItem(Context context, Request currentRequest) throws SQLException, AuthorizeException, WorkflowException { Reader reader = null; XmlWorkflowItem wi = null; try { reader = currentRequest.getHttpServletRequest().getReader(); char[] arr = new char[1024]; StringBuilder buffer = new StringBuilder(); int numCharsRead = reader.read(arr, 0, arr.length); buffer.append(arr, 0, numCharsRead); if (numCharsRead == arr.length) { throw new RuntimeException("Malformed body... too long"); } String regex = "\\/api\\/" + WorkspaceItemRest.CATEGORY + "\\/" + English.plural(WorkspaceItemRest.NAME) + "\\/"; String[] split = buffer.toString().split(regex, 2); if (split.length != 2) { throw new RuntimeException("Malformed body..." + buffer); } WorkspaceItem wsi = workspaceItemService.find(context, Integer.parseInt(split[1])); if (!workspaceItemConverter.convert(wsi).getErrors().isEmpty()) { throw new UnprocessableEntityException( "Start workflow failed due to validation error on workspaceitem"); } wi = workflowService.start(context, wsi); context.addEvent(new Event(Event.MODIFY, Constants.ITEM, wi.getItem().getID(), null, itemService.getIdentifiers(context, wi.getItem()))); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } } } return wi; }

Target:
public XmlWorkflowItem createWorkflowItem(Context context, Request currentRequest) throws SQLException, AuthorizeException, WorkflowException { Reader reader = null; XmlWorkflowItem wi = null; try { reader = currentRequest.getHttpServletRequest().getReader(); char[] arr = new char[1024]; StringBuilder buffer = new StringBuilder(); int numCharsRead = reader.read(arr, 0, arr.length); if (numCharsRead > 0) { buffer.append(arr, 0, numCharsRead); } if (numCharsRead == arr.length) { throw new UnprocessableEntityException("Malformed body... too long"); } String regex = "\\/api\\/" + WorkspaceItemRest.CATEGORY + "\\/" + English.plural(WorkspaceItemRest.NAME) + "\\/"; String[] split = buffer.toString().split(regex, 2); if (split.length != 2) { throw new UnprocessableEntityException("Malformed body..." + buffer); } END FIXME WorkspaceItem wsi = null; try { wsi = workspaceItemService.find(context, Integer.parseInt(split[1])); } catch (NumberFormatException e) { throw new UnprocessableEntityException("The provided workspaceitem URI is not valid"); } if (wsi == null) { throw new UnprocessableEntityException("Workspace item is not found"); } if (!workspaceItemConverter.convert(wsi).getErrors().isEmpty()) { throw new UnprocessableEntityException( "Start workflow failed due to validation error on workspaceitem"); } wi = workflowService.start(context, wsi); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } } } return wi; }
Source:
protected void executeCommand() { VmDevice watchdogDevice = new VmDevice(); watchdogDevice.setId(new VmDeviceId(new Guid(), getParameters().getId())); watchdogDevice.setDevice(VmDeviceType.WATCHDOG.getName()); watchdogDevice.setType(VmDeviceType.WATCHDOG.getName()); watchdogDevice.setAddress(StringUtils.EMPTY); watchdogDevice.setSpecParams(getSpecParams()); getVmDeviceDao().save(watchdogDevice); setSucceeded(true); setActionReturnValue(watchdogDevice); }

Target:
protected void executeCommand() { VmDevice watchdogDevice = new VmDevice(); watchdogDevice.setId(new VmDeviceId(new Guid(), getParameters().getId())); watchdogDevice.setDevice(VmDeviceType.WATCHDOG.getName()); watchdogDevice.setType(VmDeviceGeneralType.WATCHDOG); watchdogDevice.setAddress(StringUtils.EMPTY); watchdogDevice.setSpecParams(getSpecParams()); getVmDeviceDao().save(watchdogDevice); setSucceeded(true); setActionReturnValue(watchdogDevice.getId()); }
Source:
private void threadSummary() { List<String> prefixes = Lists.newArrayList("HTTP", "IntraLineDiff", "ReceiveCommits", "SSH git-receive-pack", "SSH git-upload-pack", "SSH-Interactive-Worker", "SSH-Stream-Worker", "SshCommandStart"); Runtime r = Runtime.getRuntime(); ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); stdout.format("Threads: %d CPUs available, %d threads\n", r.availableProcessors(), threadMXBean.getThreadCount()); if (showThreads) { Table<String, Thread.State, Integer> count = HashBasedTable.create(); for (long id : threadMXBean.getAllThreadIds()) { ThreadInfo info = threadMXBean.getThreadInfo(id); if (info == null) { continue; } String name = info.getThreadName(); for (String p : prefixes) { if (name.startsWith(p)) { Thread.State state = info.getThreadState(); Integer c = count.get(p, state); count.put(p, info.getThreadState(), c != null ? c++ : 1); } } } stdout.print(String.format(" %22s", "")); for (Thread.State s : Thread.State.values()) { stdout.print(String.format(" %14s", s.name())); } stdout.print('\n'); for (String p : prefixes) { stdout.print(String.format(" %-22s", p)); for (Thread.State s : Thread.State.values()) { stdout.print(String.format(" %14d", nullToZero(count.get(p, s)))); } stdout.print('\n'); } } stdout.print('\n'); }

Target:
private void threadSummary() { List<String> prefixes = Lists.newArrayList("HTTP", "IntraLineDiff", "ReceiveCommits", "SSH git-receive-pack", "SSH git-upload-pack", "SSH-Interactive-Worker", "SSH-Stream-Worker", "SshCommandStart"); String other = "Other"; Runtime r = Runtime.getRuntime(); ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); stdout.format("Threads: %d CPUs available, %d threads\n", r.availableProcessors(), threadMXBean.getThreadCount()); if (showThreads) { Table<String, Thread.State, Integer> count = HashBasedTable.create(); threadLoop: for (long id : threadMXBean.getAllThreadIds()) { ThreadInfo info = threadMXBean.getThreadInfo(id); if (info == null) { continue; } String name = info.getThreadName(); Thread.State state = info.getThreadState(); for (String p : prefixes) { if (name.startsWith(p)) { Integer c = count.get(p, state); count.put(p, info.getThreadState(), c != null ? c + 1 : 1); continue threadLoop; } } Integer c = count.get(other, state); count.put(other, info.getThreadState(), c != null ? c + 1 : 1); } stdout.print(String.format(" %22s", "")); for (Thread.State s : Thread.State.values()) { stdout.print(String.format(" %14s", s.name())); } stdout.print('\n'); for (String p : prefixes) { stdout.print(String.format(" %-22s", p)); for (Thread.State s : Thread.State.values()) { stdout.print(String.format(" %14d", nullToZero(count.get(p, s)))); } stdout.print('\n'); } stdout.print(String.format(" %-22s", other)); for (Thread.State s : Thread.State.values()) { stdout.print(String.format(" %14d", nullToZero(count.get(other, s)))); } stdout.print('\n'); } stdout.print('\n'); }
Source:
public void getApplicationByCandidateIdShouldReturnOneElementListOfApplicationDTOWhenCandidateIdExists() { List<ApplicationEntity> applicationEntities = Collections.singletonList(applicationEntity); List<CandidateApplicationDTO> candidateApplicationDTOs = Collections.singletonList(dummyCandidateApplicationDTO); given(candidateRepository.findOne(CANDIDATE_ID)).willReturn(candidateEntity); given(applicationsRepository.findByCandidateEntity(candidateEntity, DEFAULT_PAGE_REQUEST)) .willReturn(new PageImpl<ApplicationEntity>(applicationEntities)); given(converterService.convert(applicationEntities, CandidateApplicationDTO.class)) .willReturn(candidateApplicationDTOs); PagingResponse<CandidateApplicationDTO> result = applicationsService .getApplicationsByCandidateId(CANDIDATE_ID, PAGE_NUMBER_ZERO, PAGE_SIZE_TEN); assertThat(result.getTotal(), is(1L)); assertThat(result.getRows(), equalTo(candidateApplicationDTOs)); }

Target:
public void getApplicationByCandidateIdShouldReturnOneElementListOfApplicationDTOWhenCandidateIdExists() { final List<ApplicationEntity> applicationEntities = Collections.singletonList(applicationEntity); final List<CandidateApplicationDTO> candidateApplicationDTOs = Collections.singletonList(dummyCandidateApplicationDTO); given(candidateRepository.findOne(CANDIDATE_ID)).willReturn(candidateEntity); given(applicationsRepository.findByCandidateEntity(candidateEntity, DEFAULT_PAGE_REQUEST)) .willReturn(new PageImpl<ApplicationEntity>(applicationEntities)); given(converterService.convert(applicationEntities, CandidateApplicationDTO.class)) .willReturn(candidateApplicationDTOs); final PagingResponse<CandidateApplicationDTO> result = applicationsService .getApplicationsByCandidateId(CANDIDATE_ID, PAGE_NUMBER_ZERO, PAGE_SIZE_TEN); assertThat(result.getTotal(), is(1L)); assertThat(result.getRows(), equalTo(candidateApplicationDTOs)); }
Source:
public CommandResult<CanvasViolation> execute(AbstractCanvasHandler context) { this.commands = new CompositeCommandImpl.CompositeCommandBuilder<AbstractCanvasHandler, CanvasViolation>() .reverse() .build(); CommandResult<CanvasViolation> rootResult = super.execute(context); if (CommandUtils.isError(rootResult)) { return rootResult; } if (GraphUtils.hasChildren(getCandidate())) { Graph graph = context.getGraphIndex().getGraph(); childrenTraverseProcessor.consume(graph, getCandidate(), node -> { commands.addCommand(new CloneCanvasNodeCommand(getCandidate(), node, getShapeSetId())); }); childrenTraverseProcessor.consume(graph, getCandidate(), node -> { node.getOutEdges() .stream() .filter(edge -> edge.getContent() instanceof Dock) .forEach(edge -> commands.addCommand(new CanvasDockNodeCommand(edge.getSourceNode(), edge.getTargetNode()))); node.getOutEdges() .stream() .filter(edge -> edge.getContent() instanceof ViewConnector) .forEach(edge -> commands.addCommand(new AddCanvasConnectorCommand((Edge) edge, getShapeSetId()))); }); } if (GraphUtils.hasDockedNodes(getCandidate())) { List<Edge> edges = getCandidate().getOutEdges(); edges.stream() .filter(edge -> edge.getContent() instanceof Dock) .map(edge -> edge.getTargetNode()) .forEach(targetNode -> { commands.addCommand(new AddCanvasChildNodeCommand(getParent(), targetNode, getShapeSetId())); commands.addCommand(new CanvasDockNodeCommand(getCandidate(), targetNode)); }); } return commands.execute(context); }

Target:
public CommandResult<CanvasViolation> execute(AbstractCanvasHandler context) { commands = new CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation>() .reverse() .build(); commands.addCommand(createAddCanvasChildNodeCommand(getParent(), getCandidate(), getShapeSetId())); if (GraphUtils.hasChildren(getCandidate())) { Graph graph = context.getGraphIndex().getGraph(); List<Edge> clonedEdges = new ArrayList<>(); childrenTraverseProcessor.get() .setRootUUID(getCandidate().getUUID()) .traverse(graph, new AbstractChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public boolean startNodeTraversal(List<Node<View, Edge>> parents, Node<View, Edge> node) { commands.addCommand(createCloneCanvasNodeCommand(getCandidate(), node, getShapeSetId())); clonedEdges.addAll(node.getOutEdges()); return false; } }); clonedEdges.stream() .filter(edge -> edge.getContent() instanceof Dock) .forEach(edge -> commands.addCommand(new CanvasDockNodeCommand(edge.getSourceNode(), edge.getTargetNode()))); clonedEdges .stream() .filter(edge -> edge.getContent() instanceof ViewConnector) .forEach(edge -> commands.addCommand(new AddCanvasConnectorCommand((Edge) edge, getShapeSetId()))); } if (GraphUtils.hasDockedNodes(getCandidate())) { List<Edge> edges = getCandidate().getOutEdges(); edges.stream() .filter(edge -> edge.getContent() instanceof Dock) .map(edge -> edge.getTargetNode()) .forEach(targetNode -> { commands.addCommand(new AddCanvasChildNodeCommand(getParent(), targetNode, getShapeSetId())); commands.addCommand(new CanvasDockNodeCommand(getCandidate(), targetNode)); }); } return commands.execute(context); }
Source:
private Metacard generateMetacard(MimeType mimeType, InputStream message) throws MetacardCreationException { LOGGER.trace("ENTERING: generateMetacard"); TransformResponse transformResponse = transform.transform(mimeType, null, null, message, null, Collections.emptyMap()); Optional<Metacard> optionalMetacard = transformResponse.getParentMetacard(); if (!optionalMetacard.isPresent()) { throw new MetacardCreationException("Could not create metacard with mimeType " + mimeType); } return optionalMetacard.get(); }

Target:
private Metacard generateMetacard(MimeType mimeType, InputStream message) throws MetacardCreationException { LOGGER.trace("ENTERING: generateMetacard"); TransformResponse transformResponse = transform.transform(mimeType, null, null, message, null, Collections.emptyMap()); Optional<Metacard> optionalMetacard = transformResponse.getParentMetacard(); return optionalMetacard.orElseThrow( () -> new MetacardCreationException("Could not create metacard with mimeType " + mimeType)); }
Source:
private static void heapHistogramDump(int numLines, boolean liveObjectsOnly, PrintStream printStream, String jmapPath) { try { String args = liveObjectsOnly ? LIVE_HISTO_OPTION : ARGS; String cmd = jmapPath.isEmpty() ? CMD : (jmapPath + CMD); Process p = Runtime.getRuntime().exec(cmd + args + getProcessId()); BufferedReader in = new BufferedReader( new InputStreamReader(p.getInputStream(), Charset.defaultCharset())); printStream.println("JMap " + (liveObjectsOnly ? "histo:live" : "histo") + " dump at " + new Date()); String line = in.readLine(); for (int i = 0; i < numLines && line != null; ++i) { printStream.println("--\t" + line); line = in.readLine(); } in.close(); } catch (IOException e) { e.printStackTrace(); } }

Target:
private static void heapHistogramDump(int numLines, boolean liveObjectsOnly, PrintStream printStream, String jmapPath) { try { String args = liveObjectsOnly ? LIVE_HISTO_OPTION : ARGS; Process p = Runtime.getRuntime().exec(jmapPath + args + getProcessId()); BufferedReader in = new BufferedReader( new InputStreamReader(p.getInputStream(), Charset.defaultCharset())); printStream.println("JMap " + (liveObjectsOnly ? "histo:live" : "histo") + " dump at " + new Date()); String line = in.readLine(); for (int i = 0; i < numLines && line != null; ++i) { printStream.println("--\t" + line); line = in.readLine(); } in.close(); } catch (IOException e) { e.printStackTrace(); } }
Source:
public void run(PresentationConfiguration configuration, Environment environment) throws Exception { DBIFactory dbiFactory = new DBIFactory(); DBI jdbi = dbiFactory.build(environment, configuration.getDatabase(), "postgres"); RecentEntryIndexUpdateDAO updateDAO = jdbi.onDemand(RecentEntryIndexUpdateDAO.class); RecentEntryIndexQueryDAO queryDAO = jdbi.onDemand(RecentEntryIndexQueryDAO.class); ExecutorService executorService = Executors.newSingleThreadExecutor(); executorService.execute(new ConsumerRunnable(configuration, updateDAO)); DropwizardResourceConfig resourceConfig = environment.jersey().getResourceConfig(); ImmutableMap<String, MediaType> representations = ImmutableMap.of( "csv", ExtraMediaType.TEXT_CSV_TYPE, "tsv", ExtraMediaType.TEXT_TSV_TYPE, "ttl", ExtraMediaType.TEXT_TTL_TYPE, "html", MediaType.TEXT_HTML_TYPE, "json", MediaType.APPLICATION_JSON_TYPE ); resourceConfig.property(ServerProperties.MEDIA_TYPE_MAPPINGS, representations); environment.jersey().register(new CsvWriter()); environment.jersey().register(new TsvWriter()); environment.jersey().register(new TurtleWriter()); JerseyEnvironment jersey = environment.jersey(); jersey.register(new DataResource(queryDAO)); jersey.register(new HomePageResource()); jersey.register(new SearchResource(queryDAO)); MutableServletContextHandler applicationContext = environment.getApplicationContext(); setCorsPreflight(applicationContext); }

Target:
public void run(PresentationConfiguration configuration, Environment environment) throws Exception { DBIFactory dbiFactory = new DBIFactory(); DBI jdbi = dbiFactory.build(environment, configuration.getDatabase(), "postgres"); RecentEntryIndexUpdateDAO updateDAO = jdbi.onDemand(RecentEntryIndexUpdateDAO.class); RecentEntryIndexQueryDAO queryDAO = jdbi.onDemand(RecentEntryIndexQueryDAO.class); ExecutorService executorService = Executors.newSingleThreadExecutor(); executorService.execute(new ConsumerRunnable(configuration, updateDAO)); DropwizardResourceConfig resourceConfig = environment.jersey().getResourceConfig(); ImmutableMap<String, MediaType> representations = ImmutableMap.of( "csv", ExtraMediaType.TEXT_CSV_TYPE, "tsv", ExtraMediaType.TEXT_TSV_TYPE, "ttl", ExtraMediaType.TEXT_TTL_TYPE, "json", MediaType.APPLICATION_JSON_TYPE ); resourceConfig.property(ServerProperties.MEDIA_TYPE_MAPPINGS, representations); environment.jersey().register(new CsvWriter()); environment.jersey().register(new TsvWriter()); environment.jersey().register(new TurtleWriter()); JerseyEnvironment jersey = environment.jersey(); jersey.register(new DataResource(queryDAO)); jersey.register(new HomePageResource()); jersey.register(new SearchResource(queryDAO)); MutableServletContextHandler applicationContext = environment.getApplicationContext(); setCorsPreflight(applicationContext); }
Source:
public static Map<String, String> maskPasswordInPropertyMap(Map<String, String> propertyMap) { if (null == propertyMap) { return null; } final Map<String, String> maskedMap = new HashMap<>(); for (Map.Entry<String, String> property : propertyMap.entrySet()) { String value = property.getKey().toLowerCase().contains(PASSWORD_TEXT) || property.getKey().toLowerCase().contains(PASSWD_TEXT) ? secretPrefix : property.getValue(); maskedMap.put(property.getKey(), value); } return maskedMap; }

Target:
public static Map<String, String> maskPasswordInPropertyMap(Map<String, String> propertyMap) { if (null == propertyMap) { return null; } final Map<String, String> maskedMap = new HashMap<>(); for (Map.Entry<String, String> property : propertyMap.entrySet()) { String value = isPassword(property.getKey()) ? secretPrefix : property.getValue(); maskedMap.put(property.getKey(), value); } return maskedMap; }
Source:
void listEntitiesWithTopAsync() { final String partitionKeyValue = testResourceNamer.randomName("partitionKey", 20); final String rowKeyValue = testResourceNamer.randomName("rowKey", 20); final String rowKeyValue2 = testResourceNamer.randomName("rowKey", 20); final String rowKeyValue3 = testResourceNamer.randomName("rowKey", 20); ListEntitiesOptions options = new ListEntitiesOptions().setTop(2); tableClient.createEntity(new TableEntity(partitionKeyValue, rowKeyValue)).block(TIMEOUT); tableClient.createEntity(new TableEntity(partitionKeyValue, rowKeyValue2)).block(TIMEOUT); tableClient.createEntity(new TableEntity(partitionKeyValue, rowKeyValue3)).block(TIMEOUT); StepVerifier.create(tableClient.listEntities(options)) .expectNextCount(2) .thenConsumeWhile(x -> true) .expectComplete() .verify(); }

Target:
void listEntitiesWithTopAsync() { final String partitionKeyValue = testResourceNamer.randomName("partitionKey", 20); final String rowKeyValue = testResourceNamer.randomName("rowKey", 20); final String rowKeyValue2 = testResourceNamer.randomName("rowKey", 20); final String rowKeyValue3 = testResourceNamer.randomName("rowKey", 20); ListEntitiesOptions options = new ListEntitiesOptions().setTop(2); Mono.when( tableClient.createEntity(new TableEntity(partitionKeyValue, rowKeyValue)), tableClient.createEntity(new TableEntity(partitionKeyValue, rowKeyValue2)), tableClient.createEntity(new TableEntity(partitionKeyValue, rowKeyValue3)) ).block(TIMEOUT); StepVerifier.create(tableClient.listEntities(options)) .expectNextCount(2) .thenConsumeWhile(x -> true) .expectComplete() .verify(); }
Source:
private void visitSymbol(Symbol symbol) { Usage firstDeclaration = null; for (Usage usage : symbol.usages()) { if (firstDeclaration == null) { if ((usage.isDeclaration() || usage.kind() == Usage.Kind.LEXICAL_DECLARATION)) { firstDeclaration = usage; } } else if (usage.isDeclaration()) { getContext().addIssue(this, usage.symbolTree(), String.format(MESSAGE, symbol.name(), ((JavaScriptTree) firstDeclaration.symbolTree()).getLine())); } } }

Target:
private void visitSymbol(Symbol symbol) { Usage firstDeclaration = null; for (Usage usage : symbol.usages()) { if (firstDeclaration == null) { if ((usage.isDeclaration() || usage.kind() == Usage.Kind.LEXICAL_DECLARATION)) { firstDeclaration = usage; } } else if (usage.isDeclaration()) { getContext().addIssue(this, usage.identifierTree(), String.format(MESSAGE, symbol.name(), ((JavaScriptTree) firstDeclaration.identifierTree()).getLine())); } } }
Source:
public void sendRequest(Exchange exchange, Request request) { Request req = request; if (shouldProtectRequest(request)) { try { String uri = request.getURI(); final OSCoreCtxDB db = HashMapCtxDB.getInstance(); if (uri == null) { LOGGER.error(Error.URI_NULL); throw new OSException(Error.URI_NULL); } if (db == null) { LOGGER.error(Error.DB_NULL); throw new OSException(Error.DB_NULL); } final OSCoreCtx ctx = db.getContext(uri); if (ctx == null) { LOGGER.error(Error.CTX_NULL); throw new OSException(Error.CTX_NULL); } exchange.setCryptographicContextID(ctx.getRecipientId()); final int seqByToken = ctx.getSenderSeq(); final Request preparedRequest = prepareSend(request, ctx); preparedRequest.addMessageObserver(new MessageObserverAdapter() { @Override public void onReadyToSend() { Token token = preparedRequest.getToken(); db.addContext(token, ctx); db.addSeqByToken(token, seqByToken); } }); req = preparedRequest; if (req.getToken() != null) { db.addContext(request.getToken(), ctx); db.addSeqByToken(request.getToken(), seqByToken); } } catch (OSException e) { LOGGER.error("Error sending request: " + e.getMessage()); return; } catch (IllegalArgumentException e) { LOGGER.error("Unable to send request because of illegal argument: " + e.getMessage()); return; } } LOGGER.info("Request: " + exchange.getRequest().toString()); super.sendRequest(exchange, req); }

Target:
public void sendRequest(Exchange exchange, Request request) { Request req = request; if (shouldProtectRequest(request)) { try { String uri = request.getURI(); final OSCoreCtxDB db = HashMapCtxDB.getInstance(); if (uri == null) { LOGGER.error(ErrorDescriptions.URI_NULL); throw new OSException(ErrorDescriptions.URI_NULL); } if (db == null) { LOGGER.error(ErrorDescriptions.DB_NULL); throw new OSException(ErrorDescriptions.DB_NULL); } final OSCoreCtx ctx = db.getContext(uri); if (ctx == null) { LOGGER.error(ErrorDescriptions.CTX_NULL); throw new OSException(ErrorDescriptions.CTX_NULL); } exchange.setCryptographicContextID(ctx.getRecipientId()); final int seqByToken = ctx.getSenderSeq(); final Request preparedRequest = prepareSend(request, ctx); preparedRequest.addMessageObserver(new MessageObserverAdapter() { @Override public void onReadyToSend() { Token token = preparedRequest.getToken(); db.addContext(token, ctx); db.addSeqByToken(token, seqByToken); } }); req = preparedRequest; } catch (OSException e) { LOGGER.error("Error sending request: " + e.getMessage()); return; } catch (IllegalArgumentException e) { LOGGER.error("Unable to send request because of illegal argument: " + e.getMessage()); return; } } LOGGER.info("Request: " + exchange.getRequest().toString()); super.sendRequest(exchange, req); }
Source:
private static Double attemptDateConversion(String s) { if (s.length() == 0) { throw new XPathTypeMismatchException(); } return toNumeric(toDate(s)); }

Target:
private static Double attemptDateConversion(String s) { Object o = toDate(s); if (o instanceof Date) { return toNumeric(o); } else { throw new XPathTypeMismatchException(); } }