1
0
mirror of synced 2025-12-25 02:09:19 -05:00

add final for params, local variables, and fields (#7084)

This commit is contained in:
Charles
2021-10-15 16:41:04 -07:00
committed by GitHub
parent 592f7fe2b2
commit ba44f700b9
747 changed files with 5815 additions and 5580 deletions

View File

@@ -12,7 +12,7 @@ public class PostgresDataAdapter extends DataAdapter {
public PostgresDataAdapter() {
super(jsonNode -> jsonNode.isTextual() && jsonNode.textValue().contains("\u0000"),
jsonNode -> {
String textValue = jsonNode.textValue().replaceAll("\\u0000", "");
final String textValue = jsonNode.textValue().replaceAll("\\u0000", "");
return Jsons.jsonNode(textValue);
});
}

View File

@@ -9,7 +9,7 @@ import io.airbyte.integrations.destination.ExtendedNameTransformer;
public class PostgresSQLNameTransformer extends ExtendedNameTransformer {
@Override
protected String applyDefaultCase(String input) {
protected String applyDefaultCase(final String input) {
return input.toLowerCase();
}

View File

@@ -25,7 +25,10 @@ public class PostgresSqlOperations extends JdbcSqlOperations {
private static final Logger LOGGER = LoggerFactory.getLogger(PostgresSqlOperations.class);
@Override
public void insertRecordsInternal(JdbcDatabase database, List<AirbyteRecordMessage> records, String schemaName, String tmpTableName)
public void insertRecordsInternal(final JdbcDatabase database,
final List<AirbyteRecordMessage> records,
final String schemaName,
final String tmpTableName)
throws SQLException {
if (records.isEmpty()) {
return;
@@ -37,18 +40,18 @@ public class PostgresSqlOperations extends JdbcSqlOperations {
tmpFile = Files.createTempFile(tmpTableName + "-", ".tmp").toFile();
writeBatchToFile(tmpFile, records);
var copyManager = new CopyManager(connection.unwrap(BaseConnection.class));
var sql = String.format("COPY %s.%s FROM stdin DELIMITER ',' CSV", schemaName, tmpTableName);
var bufferedReader = new BufferedReader(new FileReader(tmpFile));
final var copyManager = new CopyManager(connection.unwrap(BaseConnection.class));
final var sql = String.format("COPY %s.%s FROM stdin DELIMITER ',' CSV", schemaName, tmpTableName);
final var bufferedReader = new BufferedReader(new FileReader(tmpFile));
copyManager.copyIn(sql, bufferedReader);
} catch (Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
} finally {
try {
if (tmpFile != null) {
Files.delete(tmpFile.toPath());
}
} catch (IOException e) {
} catch (final IOException e) {
throw new RuntimeException(e);
}
}

View File

@@ -24,7 +24,7 @@ public class PostgresDestinationAcceptanceTest extends DestinationAcceptanceTest
private static final JSONFormat JSON_FORMAT = new JSONFormat().recordFormat(RecordFormat.OBJECT);
private PostgreSQLContainer<?> db;
private ExtendedNameTransformer namingResolver = new ExtendedNameTransformer();
private final ExtendedNameTransformer namingResolver = new ExtendedNameTransformer();
@Override
protected String getImageName() {
@@ -58,10 +58,10 @@ public class PostgresDestinationAcceptanceTest extends DestinationAcceptanceTest
}
@Override
protected List<JsonNode> retrieveRecords(TestDestinationEnv env,
String streamName,
String namespace,
JsonNode streamSchema)
protected List<JsonNode> retrieveRecords(final TestDestinationEnv env,
final String streamName,
final String namespace,
final JsonNode streamSchema)
throws Exception {
return retrieveRecordsFromTable(namingResolver.getRawTableName(streamName), namespace)
.stream()
@@ -85,9 +85,9 @@ public class PostgresDestinationAcceptanceTest extends DestinationAcceptanceTest
}
@Override
protected List<JsonNode> retrieveNormalizedRecords(TestDestinationEnv env, String streamName, String namespace)
protected List<JsonNode> retrieveNormalizedRecords(final TestDestinationEnv env, final String streamName, final String namespace)
throws Exception {
String tableName = namingResolver.getIdentifier(streamName);
final String tableName = namingResolver.getIdentifier(streamName);
// Temporarily disabling the behavior of the ExtendedNameTransformer, see (issue #1785) so we don't
// use quoted names
// if (!tableName.startsWith("\"")) {
@@ -98,7 +98,7 @@ public class PostgresDestinationAcceptanceTest extends DestinationAcceptanceTest
}
@Override
protected List<String> resolveIdentifier(String identifier) {
protected List<String> resolveIdentifier(final String identifier) {
final List<String> result = new ArrayList<>();
final String resolved = namingResolver.getIdentifier(identifier);
result.add(identifier);
@@ -110,7 +110,7 @@ public class PostgresDestinationAcceptanceTest extends DestinationAcceptanceTest
return result;
}
private List<JsonNode> retrieveRecordsFromTable(String tableName, String schemaName) throws SQLException {
private List<JsonNode> retrieveRecordsFromTable(final String tableName, final String schemaName) throws SQLException {
return Databases.createPostgresDatabase(db.getUsername(), db.getPassword(),
db.getJdbcUrl()).query(
ctx -> ctx
@@ -122,13 +122,13 @@ public class PostgresDestinationAcceptanceTest extends DestinationAcceptanceTest
}
@Override
protected void setup(TestDestinationEnv testEnv) {
protected void setup(final TestDestinationEnv testEnv) {
db = new PostgreSQLContainer<>("postgres:13-alpine");
db.start();
}
@Override
protected void tearDown(TestDestinationEnv testEnv) {
protected void tearDown(final TestDestinationEnv testEnv) {
db.stop();
db.close();
}