Skip to content

Commit 298f309

Browse files
authored
Fix InlineFormatString Error Prone checks (#37768)
1 parent dfc0bd1 commit 298f309

5 files changed

Lines changed: 9 additions & 15 deletions

File tree

buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,6 @@ class BeamModulePlugin implements Plugin<Project> {
15451545
"EqualsUnsafeCast",
15461546
"EscapedEntity",
15471547
"ExtendsAutoValue",
1548-
"InlineFormatString",
15491548
"InlineMeSuggester",
15501549
"InvalidBlockTag",
15511550
"InvalidInlineTag",

it/common/src/main/java/org/apache/beam/it/common/TestProperties.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ private TestProperties() {}
6767
public static final String DEFAULT_REGION = "us-central1";
6868

6969
// Error messages
70-
private static final String CLI_ERR_MSG = "-D%s is required on the command line";
71-
private static final String ENV_VAR_MSG = "%s is required as an environment variable";
7270

7371
private static final Logger LOG = LoggerFactory.getLogger(TestProperties.class);
7472

@@ -170,8 +168,8 @@ private static String getProperty(String name, Type type, boolean required) {
170168
if (required) {
171169
String errMsg =
172170
type == Type.PROPERTY
173-
? String.format(CLI_ERR_MSG, name)
174-
: String.format(ENV_VAR_MSG, name);
171+
? String.format("-D%s is required on the command line", name)
172+
: String.format("%s is required as an environment variable", name);
175173
checkState(value != null, errMsg);
176174
}
177175

runners/samza/src/main/java/org/apache/beam/runners/samza/metrics/SamzaTransformMetrics.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class SamzaTransformMetrics implements Serializable {
3737

3838
private static final int DEFAULT_LOOKBACK_TIMER_WINDOW_SIZE_MS = 180000;
3939
private static final String GROUP = "SamzaBeamTransformMetrics";
40-
private static final String METRIC_NAME_PATTERN = "%s-%s";
4140
private static final String TRANSFORM_LATENCY_METRIC = "handle-message-ns";
4241
private static final String TRANSFORM_WATERMARK_PROGRESS = "output-watermark-ms";
4342
private static final String TRANSFORM_IP_THROUGHPUT = "num-input-messages";
@@ -138,6 +137,6 @@ private static Timer getTimerWithCustomizedLookBackWindow(String transformName)
138137
private static String getMetricNameWithPrefix(String metricName, String transformName) {
139138
// Replace all non-alphanumeric characters with underscore
140139
final String samzaSafeMetricName = transformName.replaceAll("[^A-Za-z0-9_]", "_");
141-
return String.format(METRIC_NAME_PATTERN, samzaSafeMetricName, metricName);
140+
return String.format("%s-%s", samzaSafeMetricName, metricName);
142141
}
143142
}

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,10 +1389,6 @@ private BigQueryStorageQuerySource<T> createStorageQuerySource(
13891389
getDirectReadPicosTimestampPrecision());
13901390
}
13911391

1392-
private static final String QUERY_VALIDATION_FAILURE_ERROR =
1393-
"Validation of query \"%1$s\" failed. If the query depends on an earlier stage of the"
1394-
+ " pipeline, This validation can be disabled using #withoutValidation.";
1395-
13961392
@Override
13971393
public void validate(PipelineOptions options) {
13981394
// Even if existence validation is disabled, we need to make sure that the BigQueryIO
@@ -1452,7 +1448,11 @@ public void validate(PipelineOptions options) {
14521448
getQueryLocation());
14531449
} catch (Exception e) {
14541450
throw new IllegalArgumentException(
1455-
String.format(QUERY_VALIDATION_FAILURE_ERROR, getQuery().get()), e);
1451+
String.format(
1452+
"Validation of query \"%1$s\" failed. If the query depends on an earlier stage of the"
1453+
+ " pipeline, This validation can be disabled using #withoutValidation.",
1454+
getQuery().get()),
1455+
e);
14561456
}
14571457

14581458
// If the user provided a temp dataset, check if the dataset exists before launching the

sdks/java/io/splunk/src/main/java/org/apache/beam/sdk/io/splunk/HttpEventPublisher.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ abstract class HttpEventPublisher {
9393
private static final String CONTENT_TYPE =
9494
Joiner.on('/').join(MEDIA_TYPE.getType(), MEDIA_TYPE.getSubType());
9595

96-
private static final String AUTHORIZATION_SCHEME = "Splunk %s";
97-
9896
private static final String HTTPS_PROTOCOL_PREFIX = "https";
9997

10098
/** Provides a builder for creating a {@link HttpEventPublisher}. */
@@ -184,7 +182,7 @@ void close() throws IOException {
184182
* @param token Splunk's HEC authorization token
185183
*/
186184
private void setHeaders(HttpRequest request, String token) {
187-
request.getHeaders().setAuthorization(String.format(AUTHORIZATION_SCHEME, token));
185+
request.getHeaders().setAuthorization(String.format("Splunk %s", token));
188186

189187
if (enableGzipHttpCompression()) {
190188
request.getHeaders().setContentEncoding("gzip");

0 commit comments

Comments
 (0)