java - Spring Cloud Task:任务参数中的多个空格导致 StringIndexOutOfBoundsException
问题描述
我正在使用SCDF Java DSL以编程方式在 Kubernetes 上启动任务。我注意到StringIndexOutOfBoundsException
只要任务启动参数有多个空间,SCDF 服务器就会抛出一个。
例子 :
URI dataFlowUri = URI.create(dataFlowServerUri);
DataFlowOperations dataFlowOperations = new DataFlowTemplate(dataFlowUri);
Task task = Task.builder(dataFlowOperations).name(taskNameWithBatchIdInstanceId).definition(taskDefintion).description(taskDescription).build();
Map<String, String> taskLaunchProperties = new DeploymentPropertiesBuilder()
.put("deployer.task.kubernetes.limits.cpu", cpuLimit)
.put("deployer.task.kubernetes.limits.memory", memoryLimit)
.put("deployer.task.kubernetes.requests.cpu", cpuRequest)
.put("deployer.task.kubernetes.requests.memory", memoryRequest).build();
task.launch(taskLaunchProperties, Arrays.asList("inputArgument=ABC CDE FGH"));
我们可以看到上面的最后一行inputArguments=ABC CDE FGH
作为参数传递。启动此任务会导致 SCDF 服务器上显示以下异常:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1967) ~[na:1.8.0_281]
at org.springframework.cloud.deployer.spi.kubernetes.DefaultContainerFactory.lambda$createCommandArgs$0(DefaultContainerFactory.java:236) ~[spring-cloud-deployer-kubernetes-2.3.3.RELEASE.jar!/:2.3.3.RELEASE]
在客户端,由于SCDF 服务器遇到,调用 会task.launch
导致500 [no body]
服务器响应。StringIndexOutOfBoundsException
经过大量试验,我意识到只有在任务输入参数中有多个空格时才会发生此异常。StringIndexOutOfBoundsException
如果输入参数的空格少于 2 个并且在这种情况下不再看到,我可以启动任务。
task.launch(taskLaunchProperties, Arrays.asList("inputArgument=ABC CDE"));
问题:如何将具有多个空格的输入参数传递给 SCDF 任务?为什么 SCDF 不允许有多个空格的参数?这是一个错误吗?
解决方案
推荐阅读
- html - 如何通过 datepicker 为 django 正确格式化日期
- google-cloud-ml - CloudML在线预测实例最大内存使用量
- c# - 使用 int 和 float 中的字符串进行类型转换的问题
- python - 使用 Python 和 openCV 通过 http 进行 Gstreaming
- c# - 在一个列表中映射不同的值
- rust - 通过多个级别的 crates denedicies 导出共享库路径
- android - FAILURE:构建失败,出现异常 react-native using firebase
- firebase - 消息负载包含无效的“android”属性。有效属性是“数据”和“通知”
- python - 列必须与键长度相同
- svn - 是否可以在不提交的情况下使用 propset 设置 SVN 属性?