Skip to content

Commit e9afa9b

Browse files
authored
Error Prone PMD rules (#15010)
* Implement ErrorProne PMD rules: AssignmentInOperand AvoidAccessibilityAlteration AvoidBranchingStatementAsLastInLoop AvoidCatchingNPE AvoidCatchingThrowable AvoidDuplicateLiterals rule
1 parent c536e51 commit e9afa9b

File tree

93 files changed

+1410
-1207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1410
-1207
lines changed

airbyte-analytics/src/test/java/io/airbyte/analytics/SegmentTrackingClientTest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class SegmentTrackingClientTest {
3535
private static final TrackingIdentity IDENTITY = new TrackingIdentity(AIRBYTE_VERSION, UUID.randomUUID(), EMAIL, false, false, true);
3636
private static final UUID WORKSPACE_ID = UUID.randomUUID();
3737
private static final Function<UUID, TrackingIdentity> MOCK_TRACKING_IDENTITY = (workspaceId) -> IDENTITY;
38+
private static final String AIRBYTE_VERSION_KEY = "airbyte_version";
39+
private static final String JUMP = "jump";
3840

3941
private Analytics analytics;
4042
private SegmentTrackingClient segmentTrackingClient;
@@ -61,7 +63,7 @@ void testIdentify() {
6163
final IdentifyMessage actual = mockBuilder.getValue().build();
6264
final Map<String, Object> expectedTraits = ImmutableMap.<String, Object>builder()
6365
.put("anonymized", IDENTITY.isAnonymousDataCollection())
64-
.put("airbyte_version", AIRBYTE_VERSION.serialize())
66+
.put(AIRBYTE_VERSION_KEY, AIRBYTE_VERSION.serialize())
6567
.put("deployment_env", DEPLOYMENT.getDeploymentEnv())
6668
.put("deployment_mode", DEPLOYMENT.getDeploymentMode())
6769
.put("deployment_id", DEPLOYMENT.getDeploymentId())
@@ -87,7 +89,7 @@ void testIdentifyWithRole() {
8789
final IdentifyMessage actual = mockBuilder.getValue().build();
8890
final Map<String, Object> expectedTraits = ImmutableMap.<String, Object>builder()
8991
.put("airbyte_role", "role")
90-
.put("airbyte_version", AIRBYTE_VERSION.serialize())
92+
.put(AIRBYTE_VERSION_KEY, AIRBYTE_VERSION.serialize())
9193
.put("anonymized", IDENTITY.isAnonymousDataCollection())
9294
.put("deployment_env", DEPLOYMENT.getDeploymentEnv())
9395
.put("deployment_mode", DEPLOYMENT.getDeploymentMode())
@@ -104,13 +106,13 @@ void testIdentifyWithRole() {
104106
void testTrack() {
105107
final ArgumentCaptor<TrackMessage.Builder> mockBuilder = ArgumentCaptor.forClass(TrackMessage.Builder.class);
106108
final ImmutableMap<String, Object> metadata =
107-
ImmutableMap.of("airbyte_version", AIRBYTE_VERSION.serialize(), "user_id", IDENTITY.getCustomerId());
109+
ImmutableMap.of(AIRBYTE_VERSION_KEY, AIRBYTE_VERSION.serialize(), "user_id", IDENTITY.getCustomerId());
108110

109-
segmentTrackingClient.track(WORKSPACE_ID, "jump");
111+
segmentTrackingClient.track(WORKSPACE_ID, JUMP);
110112

111113
verify(analytics).enqueue(mockBuilder.capture());
112114
final TrackMessage actual = mockBuilder.getValue().build();
113-
assertEquals("jump", actual.event());
115+
assertEquals(JUMP, actual.event());
114116
assertEquals(IDENTITY.getCustomerId().toString(), actual.userId());
115117
assertEquals(metadata, filterTrackedAtProperty(Objects.requireNonNull(actual.properties())));
116118
}
@@ -119,16 +121,16 @@ void testTrack() {
119121
void testTrackWithMetadata() {
120122
final ArgumentCaptor<TrackMessage.Builder> mockBuilder = ArgumentCaptor.forClass(TrackMessage.Builder.class);
121123
final ImmutableMap<String, Object> metadata = ImmutableMap.of(
122-
"airbyte_version", AIRBYTE_VERSION.serialize(),
124+
AIRBYTE_VERSION_KEY, AIRBYTE_VERSION.serialize(),
123125
"email", EMAIL,
124126
"height", "80 meters",
125127
"user_id", IDENTITY.getCustomerId());
126128

127-
segmentTrackingClient.track(WORKSPACE_ID, "jump", metadata);
129+
segmentTrackingClient.track(WORKSPACE_ID, JUMP, metadata);
128130

129131
verify(analytics).enqueue(mockBuilder.capture());
130132
final TrackMessage actual = mockBuilder.getValue().build();
131-
assertEquals("jump", actual.event());
133+
assertEquals(JUMP, actual.event());
132134
assertEquals(IDENTITY.getCustomerId().toString(), actual.userId());
133135
assertEquals(metadata, filterTrackedAtProperty(Objects.requireNonNull(actual.properties())));
134136
}

airbyte-bootloader/src/test/java/io/airbyte/bootloader/BootloaderAppTest.java

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,18 @@ class BootloaderAppTest {
5959
private PostgreSQLContainer container;
6060
private DataSource configsDataSource;
6161
private DataSource jobsDataSource;
62+
private static final String DOCKER = "docker";
63+
private static final String VERSION_0330_ALPHA = "0.33.0-alpha";
64+
private static final String VERSION_0320_ALPHA = "0.32.0-alpha";
65+
private static final String VERSION_0321_ALPHA = "0.32.1-alpha";
66+
private static final String VERSION_0170_ALPHA = "0.17.0-alpha";
6267

6368
@BeforeEach
6469
void setup() {
6570
container = new PostgreSQLContainer<>("postgres:13-alpine")
6671
.withDatabaseName("public")
67-
.withUsername("docker")
68-
.withPassword("docker");
72+
.withUsername(DOCKER)
73+
.withPassword(DOCKER);
6974
container.start();
7075

7176
configsDataSource =
@@ -86,16 +91,14 @@ void cleanup() throws Exception {
8691

8792
@Test
8893
void testBootloaderAppBlankDb() throws Exception {
89-
val version = "0.33.0-alpha";
90-
9194
val mockedConfigs = mock(Configs.class);
9295
when(mockedConfigs.getConfigDatabaseUrl()).thenReturn(container.getJdbcUrl());
9396
when(mockedConfigs.getConfigDatabaseUser()).thenReturn(container.getUsername());
9497
when(mockedConfigs.getConfigDatabasePassword()).thenReturn(container.getPassword());
9598
when(mockedConfigs.getDatabaseUrl()).thenReturn(container.getJdbcUrl());
9699
when(mockedConfigs.getDatabaseUser()).thenReturn(container.getUsername());
97100
when(mockedConfigs.getDatabasePassword()).thenReturn(container.getPassword());
98-
when(mockedConfigs.getAirbyteVersion()).thenReturn(new AirbyteVersion(version));
101+
when(mockedConfigs.getAirbyteVersion()).thenReturn(new AirbyteVersion(VERSION_0330_ALPHA));
99102
when(mockedConfigs.runDatabaseMigrationOnStartup()).thenReturn(true);
100103
when(mockedConfigs.getConfigsDatabaseInitializationTimeoutMs()).thenReturn(60000L);
101104
when(mockedConfigs.getJobsDatabaseInitializationTimeoutMs()).thenReturn(60000L);
@@ -107,8 +110,8 @@ void testBootloaderAppBlankDb() throws Exception {
107110
// Although we are able to inject mocked configs into the Bootloader, a particular migration in the
108111
// configs database
109112
// requires the env var to be set. Flyway prevents injection, so we dynamically set this instead.
110-
environmentVariables.set("DATABASE_USER", "docker");
111-
environmentVariables.set("DATABASE_PASSWORD", "docker");
113+
environmentVariables.set("DATABASE_USER", DOCKER);
114+
environmentVariables.set("DATABASE_PASSWORD", DOCKER);
112115
environmentVariables.set("DATABASE_URL", container.getJdbcUrl());
113116

114117
try (val configsDslContext = DSLContextFactory.create(configsDataSource, SQLDialect.POSTGRES);
@@ -133,24 +136,22 @@ void testBootloaderAppBlankDb() throws Exception {
133136
assertEquals("0.39.17.001", configsMigrator.getLatestMigration().getVersion().getVersion());
134137

135138
val jobsPersistence = new DefaultJobPersistence(jobDatabase);
136-
assertEquals(version, jobsPersistence.getVersion().get());
139+
assertEquals(VERSION_0330_ALPHA, jobsPersistence.getVersion().get());
137140

138141
assertNotEquals(Optional.empty(), jobsPersistence.getDeployment().get());
139142
}
140143
}
141144

142145
@Test
143146
void testBootloaderAppRunSecretMigration() throws Exception {
144-
val version = "0.33.0-alpha";
145-
146147
val mockedConfigs = mock(Configs.class);
147148
when(mockedConfigs.getConfigDatabaseUrl()).thenReturn(container.getJdbcUrl());
148149
when(mockedConfigs.getConfigDatabaseUser()).thenReturn(container.getUsername());
149150
when(mockedConfigs.getConfigDatabasePassword()).thenReturn(container.getPassword());
150151
when(mockedConfigs.getDatabaseUrl()).thenReturn(container.getJdbcUrl());
151152
when(mockedConfigs.getDatabaseUser()).thenReturn(container.getUsername());
152153
when(mockedConfigs.getDatabasePassword()).thenReturn(container.getPassword());
153-
when(mockedConfigs.getAirbyteVersion()).thenReturn(new AirbyteVersion(version));
154+
when(mockedConfigs.getAirbyteVersion()).thenReturn(new AirbyteVersion(VERSION_0330_ALPHA));
154155
when(mockedConfigs.runDatabaseMigrationOnStartup()).thenReturn(true);
155156
when(mockedConfigs.getSecretPersistenceType()).thenReturn(TESTING_CONFIG_DB_TABLE);
156157
when(mockedConfigs.getConfigsDatabaseInitializationTimeoutMs()).thenReturn(60000L);
@@ -181,8 +182,8 @@ void testBootloaderAppRunSecretMigration() throws Exception {
181182
// Although we are able to inject mocked configs into the Bootloader, a particular migration in the
182183
// configs database requires the env var to be set. Flyway prevents injection, so we dynamically set
183184
// this instead.
184-
environmentVariables.set("DATABASE_USER", "docker");
185-
environmentVariables.set("DATABASE_PASSWORD", "docker");
185+
environmentVariables.set("DATABASE_USER", DOCKER);
186+
environmentVariables.set("DATABASE_PASSWORD", DOCKER);
186187
environmentVariables.set("DATABASE_URL", container.getJdbcUrl());
187188

188189
// Bootstrap the database for the test
@@ -265,37 +266,35 @@ void testBootloaderAppRunSecretMigration() throws Exception {
265266
void testIsLegalUpgradePredicate() {
266267
// starting from no previous version is always legal.
267268
assertTrue(BootloaderApp.isLegalUpgrade(null, new AirbyteVersion("0.17.1-alpha")));
268-
assertTrue(BootloaderApp.isLegalUpgrade(null, new AirbyteVersion("0.32.0-alpha")));
269-
assertTrue(BootloaderApp.isLegalUpgrade(null, new AirbyteVersion("0.32.1-alpha")));
269+
assertTrue(BootloaderApp.isLegalUpgrade(null, new AirbyteVersion(VERSION_0320_ALPHA)));
270+
assertTrue(BootloaderApp.isLegalUpgrade(null, new AirbyteVersion(VERSION_0321_ALPHA)));
270271
assertTrue(BootloaderApp.isLegalUpgrade(null, new AirbyteVersion("0.33.1-alpha")));
271272
// starting from a version that is pre-breaking migration cannot go past the breaking migration.
272-
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion("0.17.0-alpha"), new AirbyteVersion("0.17.1-alpha")));
273-
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion("0.17.0-alpha"), new AirbyteVersion("0.18.0-alpha")));
274-
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion("0.17.0-alpha"), new AirbyteVersion("0.32.0-alpha")));
275-
assertFalse(BootloaderApp.isLegalUpgrade(new AirbyteVersion("0.17.0-alpha"), new AirbyteVersion("0.32.1-alpha")));
276-
assertFalse(BootloaderApp.isLegalUpgrade(new AirbyteVersion("0.17.0-alpha"), new AirbyteVersion("0.33.0-alpha")));
273+
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion(VERSION_0170_ALPHA), new AirbyteVersion("0.17.1-alpha")));
274+
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion(VERSION_0170_ALPHA), new AirbyteVersion("0.18.0-alpha")));
275+
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion(VERSION_0170_ALPHA), new AirbyteVersion(VERSION_0320_ALPHA)));
276+
assertFalse(BootloaderApp.isLegalUpgrade(new AirbyteVersion(VERSION_0170_ALPHA), new AirbyteVersion(VERSION_0321_ALPHA)));
277+
assertFalse(BootloaderApp.isLegalUpgrade(new AirbyteVersion(VERSION_0170_ALPHA), new AirbyteVersion(VERSION_0330_ALPHA)));
277278
// any migration starting at the breaking migration or after it can upgrade to anything.
278-
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion("0.32.0-alpha"), new AirbyteVersion("0.32.1-alpha")));
279-
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion("0.32.0-alpha"), new AirbyteVersion("0.33.0-alpha")));
280-
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion("0.32.1-alpha"), new AirbyteVersion("0.32.1-alpha")));
281-
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion("0.32.1-alpha"), new AirbyteVersion("0.33.0-alpha")));
282-
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion("0.33.0-alpha"), new AirbyteVersion("0.33.1-alpha")));
283-
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion("0.33.0-alpha"), new AirbyteVersion("0.34.0-alpha")));
279+
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion(VERSION_0320_ALPHA), new AirbyteVersion(VERSION_0321_ALPHA)));
280+
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion(VERSION_0320_ALPHA), new AirbyteVersion(VERSION_0330_ALPHA)));
281+
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion(VERSION_0321_ALPHA), new AirbyteVersion(VERSION_0321_ALPHA)));
282+
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion(VERSION_0321_ALPHA), new AirbyteVersion(VERSION_0330_ALPHA)));
283+
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion(VERSION_0330_ALPHA), new AirbyteVersion("0.33.1-alpha")));
284+
assertTrue(BootloaderApp.isLegalUpgrade(new AirbyteVersion(VERSION_0330_ALPHA), new AirbyteVersion("0.34.0-alpha")));
284285
}
285286

286287
@Test
287288
void testPostLoadExecutionExecutes() throws Exception {
288289
final var testTriggered = new AtomicBoolean();
289-
val version = "0.33.0-alpha";
290-
291290
val mockedConfigs = mock(Configs.class);
292291
when(mockedConfigs.getConfigDatabaseUrl()).thenReturn(container.getJdbcUrl());
293292
when(mockedConfigs.getConfigDatabaseUser()).thenReturn(container.getUsername());
294293
when(mockedConfigs.getConfigDatabasePassword()).thenReturn(container.getPassword());
295294
when(mockedConfigs.getDatabaseUrl()).thenReturn(container.getJdbcUrl());
296295
when(mockedConfigs.getDatabaseUser()).thenReturn(container.getUsername());
297296
when(mockedConfigs.getDatabasePassword()).thenReturn(container.getPassword());
298-
when(mockedConfigs.getAirbyteVersion()).thenReturn(new AirbyteVersion(version));
297+
when(mockedConfigs.getAirbyteVersion()).thenReturn(new AirbyteVersion(VERSION_0330_ALPHA));
299298
when(mockedConfigs.runDatabaseMigrationOnStartup()).thenReturn(true);
300299
when(mockedConfigs.getConfigsDatabaseInitializationTimeoutMs()).thenReturn(60000L);
301300
when(mockedConfigs.getJobsDatabaseInitializationTimeoutMs()).thenReturn(60000L);

airbyte-commons-cli/src/test/java/io/airbyte/commons/cli/ClisTest.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616

1717
class ClisTest {
1818

19+
private static final String ALPHA = "alpha";
20+
private static final String BETA = "beta";
21+
1922
@Test
2023
void testCreateOptionGroup() {
21-
final Option optionA = new Option("a", "alpha");
22-
final Option optionB = new Option("b", "beta");
24+
final Option optionA = new Option("a", ALPHA);
25+
final Option optionB = new Option("b", BETA);
2326
final OptionGroup optionGroupExpected = new OptionGroup();
2427
optionGroupExpected.addOption(optionA);
2528
optionGroupExpected.addOption(optionB);
@@ -38,18 +41,18 @@ void testParse() {
3841
final Option optionA = Option.builder("a").required(true).hasArg(true).build();
3942
final Option optionB = Option.builder("b").required(true).hasArg(true).build();
4043
final Options options = new Options().addOption(optionA).addOption(optionB);
41-
final String[] args = {"-a", "alpha", "-b", "beta"};
44+
final String[] args = {"-a", ALPHA, "-b", BETA};
4245
final CommandLine parsed = Clis.parse(args, options, new DefaultParser());
43-
assertEquals("alpha", parsed.getOptions()[0].getValue());
44-
assertEquals("beta", parsed.getOptions()[1].getValue());
46+
assertEquals(ALPHA, parsed.getOptions()[0].getValue());
47+
assertEquals(BETA, parsed.getOptions()[1].getValue());
4548
}
4649

4750
@Test
4851
void testParseNonConforming() {
4952
final Option optionA = Option.builder("a").required(true).hasArg(true).build();
5053
final Option optionB = Option.builder("b").required(true).hasArg(true).build();
5154
final Options options = new Options().addOption(optionA).addOption(optionB);
52-
final String[] args = {"-a", "alpha", "-b", "beta", "-c", "charlie"};
55+
final String[] args = {"-a", ALPHA, "-b", BETA, "-c", "charlie"};
5356
assertThrows(IllegalArgumentException.class, () -> Clis.parse(args, options, new DefaultParser()));
5457
}
5558

@@ -58,7 +61,7 @@ void testParseNonConformingWithSyntax() {
5861
final Option optionA = Option.builder("a").required(true).hasArg(true).build();
5962
final Option optionB = Option.builder("b").required(true).hasArg(true).build();
6063
final Options options = new Options().addOption(optionA).addOption(optionB);
61-
final String[] args = {"-a", "alpha", "-b", "beta", "-c", "charlie"};
64+
final String[] args = {"-a", ALPHA, "-b", BETA, "-c", "charlie"};
6265
assertThrows(IllegalArgumentException.class, () -> Clis.parse(args, options, new DefaultParser(), "search"));
6366
}
6467

@@ -67,10 +70,10 @@ void testRelaxedParser() {
6770
final Option optionA = Option.builder("a").required(true).hasArg(true).build();
6871
final Option optionB = Option.builder("b").required(true).hasArg(true).build();
6972
final Options options = new Options().addOption(optionA).addOption(optionB);
70-
final String[] args = {"-a", "alpha", "-b", "beta", "-c", "charlie"};
73+
final String[] args = {"-a", ALPHA, "-b", BETA, "-c", "charlie"};
7174
final CommandLine parsed = Clis.parse(args, options, Clis.getRelaxedParser());
72-
assertEquals("alpha", parsed.getOptions()[0].getValue());
73-
assertEquals("beta", parsed.getOptions()[1].getValue());
75+
assertEquals(ALPHA, parsed.getOptions()[0].getValue());
76+
assertEquals(BETA, parsed.getOptions()[1].getValue());
7477
}
7578

7679
}

airbyte-commons/src/main/java/io/airbyte/commons/io/Archives.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ private static void compressFile(final Path file, final Path filename, final Tar
4949
public static void extractArchive(final Path archiveFile, final Path destinationFolder) throws IOException {
5050
final TarArchiveInputStream archive =
5151
new TarArchiveInputStream(new GzipCompressorInputStream(new BufferedInputStream(Files.newInputStream(archiveFile))));
52-
ArchiveEntry entry;
53-
while ((entry = archive.getNextEntry()) != null) {
52+
ArchiveEntry entry = archive.getNextEntry();
53+
while (entry != null) {
5454
final Path newPath = zipSlipProtect(entry, destinationFolder);
5555
if (entry.isDirectory()) {
5656
Files.createDirectories(newPath);
@@ -63,6 +63,7 @@ public static void extractArchive(final Path archiveFile, final Path destination
6363
}
6464
Files.copy(archive, newPath, StandardCopyOption.REPLACE_EXISTING);
6565
}
66+
entry = archive.getNextEntry();
6667
}
6768
}
6869

airbyte-commons/src/main/java/io/airbyte/commons/io/IOs.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ public static List<String> getTail(final int numLines, final Path path) throws I
8888
try (final ReversedLinesFileReader fileReader = new ReversedLinesFileReader(file, Charsets.UTF_8)) {
8989
final List<String> lines = new ArrayList<>();
9090

91-
String line;
92-
while ((line = fileReader.readLine()) != null && lines.size() < numLines) {
91+
String line = fileReader.readLine();
92+
while (line != null && lines.size() < numLines) {
9393
lines.add(line);
94+
line = fileReader.readLine();
9495
}
9596

9697
Collections.reverse(lines);

airbyte-commons/src/main/java/io/airbyte/commons/io/LineGobbler.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
public class LineGobbler implements VoidCallable {
2121

2222
private final static Logger LOGGER = LoggerFactory.getLogger(LineGobbler.class);
23+
private final static String GENERIC = "generic";
2324

2425
public static void gobble(final InputStream is, final Consumer<String> consumer) {
25-
gobble(is, consumer, "generic", MdcScope.DEFAULT_BUILDER);
26+
gobble(is, consumer, GENERIC, MdcScope.DEFAULT_BUILDER);
2627
}
2728

2829
public static void gobble(final InputStream is, final Consumer<String> consumer, final MdcScope.Builder mdcScopeBuilder) {
29-
gobble(is, consumer, "generic", mdcScopeBuilder);
30+
gobble(is, consumer, GENERIC, mdcScopeBuilder);
3031
}
3132

3233
public static void gobble(final InputStream is, final Consumer<String> consumer, final String caller, final MdcScope.Builder mdcScopeBuilder) {
@@ -47,15 +48,15 @@ public static void gobble(final InputStream is, final Consumer<String> consumer,
4748
final Consumer<String> consumer,
4849
final ExecutorService executor,
4950
final Map<String, String> mdc) {
50-
this(is, consumer, executor, mdc, "generic", MdcScope.DEFAULT_BUILDER);
51+
this(is, consumer, executor, mdc, GENERIC, MdcScope.DEFAULT_BUILDER);
5152
}
5253

5354
LineGobbler(final InputStream is,
5455
final Consumer<String> consumer,
5556
final ExecutorService executor,
5657
final Map<String, String> mdc,
5758
final MdcScope.Builder mdcScopeBuilder) {
58-
this(is, consumer, executor, mdc, "generic", mdcScopeBuilder);
59+
this(is, consumer, executor, mdc, GENERIC, mdcScopeBuilder);
5960
}
6061

6162
LineGobbler(final InputStream is,
@@ -76,11 +77,12 @@ public static void gobble(final InputStream is, final Consumer<String> consumer,
7677
public void voidCall() {
7778
MDC.setContextMap(mdc);
7879
try {
79-
String line;
80-
while ((line = is.readLine()) != null) {
80+
String line = is.readLine();
81+
while (line != null) {
8182
try (final var mdcScope = containerLogMdcBuilder.build()) {
8283
consumer.accept(line);
8384
}
85+
line = is.readLine();
8486
}
8587
} catch (final IOException i) {
8688
LOGGER.warn("{} gobbler IOException: {}. Typically happens when cancelling a job.", caller, i.getMessage());

0 commit comments

Comments
 (0)