Skip to content

Commit 0152e13

Browse files
authored
Fixes code inspections on database module (#38761)
1 parent 52b2bf7 commit 0152e13

10 files changed

Lines changed: 20 additions & 34 deletions

File tree

database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/option/sqlbatch/DialectSQLBatchOption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import lombok.RequiredArgsConstructor;
2222

2323
/**
24-
* Dialect sql batch option.
24+
* Dialect SQL batch option.
2525
*/
2626
@RequiredArgsConstructor
2727
@Getter

database/connector/dialect/mysql/src/test/java/org/apache/shardingsphere/database/connector/mysql/metadata/identifier/MySQLIdentifierCaseRuleProviderTest.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void assertProvide(final String name, final IdentifierCaseRuleProviderContext co
7171

7272
@Test
7373
void assertProvideWithQuotedTableName() throws SQLException {
74-
IdentifierCaseRule actual = provider.provide(new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(true, 1)))
74+
IdentifierCaseRule actual = provider.provide(new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(true, 1)))
7575
.map(ruleSet -> ruleSet.getRule(IdentifierScope.TABLE)).orElseThrow(AssertionError::new);
7676
assertThat(actual.getLookupMode(QuoteCharacter.BACK_QUOTE), is(LookupMode.NORMALIZED));
7777
assertThat(actual.matches("t_mask", "T_MASK", QuoteCharacter.BACK_QUOTE), is(Boolean.TRUE));
@@ -96,20 +96,20 @@ private void assertLookupMode(final IdentifierCaseRule actual, final QuoteCharac
9696
private static Stream<Arguments> provideArguments() throws SQLException {
9797
return Stream.of(
9898
Arguments.of("null_data_source", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, null), null, null, null),
99-
Arguments.of("null_connection", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockNullConnectionDataSource()), null, null, null),
100-
Arguments.of("lower_case_table_names_0", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(true, 0)),
99+
Arguments.of("null_connection", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new NullConnectionFixtureDataSource()), null, null, null),
100+
Arguments.of("lower_case_table_names_0", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(true, 0)),
101101
LookupMode.EXACT, LookupMode.EXACT, Boolean.FALSE),
102-
Arguments.of("lower_case_table_names_1", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(true, 1)),
102+
Arguments.of("lower_case_table_names_1", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(true, 1)),
103103
LookupMode.NORMALIZED, LookupMode.NORMALIZED, Boolean.TRUE),
104-
Arguments.of("lower_case_table_names_2", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(true, 2)),
104+
Arguments.of("lower_case_table_names_2", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(true, 2)),
105105
LookupMode.NORMALIZED, LookupMode.NORMALIZED, Boolean.TRUE),
106-
Arguments.of("no_result_row", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(false, 0)), null, null, null),
107-
Arguments.of("sql_exception", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockFailingDataSource()), null, null, null));
106+
Arguments.of("no_result_row", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(false, 0)), null, null, null),
107+
Arguments.of("sql_exception", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FailingFixtureDataSource()), null, null, null));
108108
}
109109

110110
@Test
111111
void assertProvideWithLowerCaseTableNamesZeroUsesScopedRules() throws SQLException {
112-
IdentifierCaseRuleProviderContext context = new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(true, 0));
112+
IdentifierCaseRuleProviderContext context = new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(true, 0));
113113
IdentifierCaseRuleSet actual = provider.provide(context).orElseThrow(AssertionError::new);
114114
assertThat(actual.getRule(IdentifierScope.SCHEMA).matches("foo_schema", "FOO_SCHEMA", QuoteCharacter.NONE), is(Boolean.TRUE));
115115
assertThat(actual.getRule(IdentifierScope.TABLE).matches("foo_tbl", "FOO_TBL", QuoteCharacter.NONE), is(Boolean.FALSE));
@@ -118,18 +118,6 @@ void assertProvideWithLowerCaseTableNamesZeroUsesScopedRules() throws SQLExcepti
118118
assertThat(actual.getRule(IdentifierScope.INDEX).matches("foo_idx", "FOO_IDX", QuoteCharacter.NONE), is(Boolean.TRUE));
119119
}
120120

121-
private static DataSource mockDataSource(final boolean hasResultSetRow, final int lowerCaseTableNames) throws SQLException {
122-
return new FixtureDataSource(hasResultSetRow, lowerCaseTableNames);
123-
}
124-
125-
private static DataSource mockFailingDataSource() throws SQLException {
126-
return new FailingFixtureDataSource();
127-
}
128-
129-
private static DataSource mockNullConnectionDataSource() {
130-
return new NullConnectionFixtureDataSource();
131-
}
132-
133121
private static Object getDefaultValue(final Class<?> returnType) {
134122
if (!returnType.isPrimitive()) {
135123
return null;

database/exception/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/exception/postgresql/exception/PostgreSQLException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.text.MessageFormat;
2626

2727
/**
28-
* Replacement for {@link org.postgresql.util.PSQLException}.
28+
* PostgreSQL exception.
2929
*/
3030
@Getter
3131
public final class PostgreSQLException extends SQLException {

database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/info/type/blob/FirebirdBlobInfoReturnPacket.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ private void parseBlobInfo(final FirebirdPacketPayload payload, final FirebirdBl
5656
writeIntValue(payload, type, getSegmentCount());
5757
return;
5858
case MAX_SEGMENT:
59-
writeIntValue(payload, type, getSegmentLength());
60-
return;
6159
case TOTAL_LENGTH:
6260
writeIntValue(payload, type, getSegmentLength());
6361
return;

database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/handshake/FirebirdAcceptPacket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public FirebirdAcceptPacket(final List<FirebirdProtocol> userProtocols) {
6060
}
6161

6262
/**
63-
* Set accept data packet.
63+
* Set accepted data packet.
6464
*
6565
* @param salt salt value
6666
* @param publicKey public key

database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/handshake/FirebirdConnectPacket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private void parseUserInfo(final ByteBuf userInfo) {
7272
int length = userInfo.readUnsignedByte();
7373
ByteBuf data = userInfo.readSlice(length);
7474
if (type == FirebirdUserDataType.CNCT_SPECIFIC_DATA) {
75-
// specific data can be split into chunks and (i think) can be in payload in random order
75+
// specific data can be split into chunks and (I think) can be in payload in random order
7676
int step = data.readUnsignedByte();
7777
pendingData.put(step, data.toString(StandardCharsets.US_ASCII));
7878
} else {

database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLNoDataPacket.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public final class PostgreSQLNoDataPacket extends PostgreSQLPacket {
3434
private static final PostgreSQLNoDataPacket INSTANCE = new PostgreSQLNoDataPacket();
3535

3636
/**
37-
* Get instance of {@link PostgreSQLNoDataPacket}.
37+
* Get instance of PostgreSQL no data packet.
3838
*
39-
* @return instance of {@link PostgreSQLNoDataPacket}
39+
* @return got instance
4040
*/
4141
public static PostgreSQLNoDataPacket getInstance() {
4242
return INSTANCE;

database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLBindCompletePacket.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public final class PostgreSQLBindCompletePacket extends PostgreSQLPacket {
3434
private static final PostgreSQLBindCompletePacket INSTANCE = new PostgreSQLBindCompletePacket();
3535

3636
/**
37-
* Get instance of {@link PostgreSQLBindCompletePacket}.
37+
* Get instance of PostgreSQL bind complete packet.
3838
*
39-
* @return instance of {@link PostgreSQLBindCompletePacket}
39+
* @return got instance
4040
*/
4141
public static PostgreSQLBindCompletePacket getInstance() {
4242
return INSTANCE;

database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/close/PostgreSQLCloseCompletePacket.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public final class PostgreSQLCloseCompletePacket extends PostgreSQLPacket {
3131
private static final PostgreSQLCloseCompletePacket INSTANCE = new PostgreSQLCloseCompletePacket();
3232

3333
/**
34-
* Get instance of {@link PostgreSQLCloseCompletePacket}.
34+
* Get instance of PostgreSQL close complete packet.
3535
*
36-
* @return instance of {@link PostgreSQLCloseCompletePacket}
36+
* @return got instance
3737
*/
3838
public static PostgreSQLCloseCompletePacket getInstance() {
3939
return INSTANCE;

database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/parse/PostgreSQLParseCompletePacket.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public final class PostgreSQLParseCompletePacket extends PostgreSQLPacket {
3434
private static final PostgreSQLParseCompletePacket INSTANCE = new PostgreSQLParseCompletePacket();
3535

3636
/**
37-
* Get instance of {@link PostgreSQLParseCompletePacket}.
37+
* Get instance of PostgreSQL parse complete packet.
3838
*
39-
* @return instance of {@link PostgreSQLParseCompletePacket}
39+
* @return got instance
4040
*/
4141
public static PostgreSQLParseCompletePacket getInstance() {
4242
return INSTANCE;

0 commit comments

Comments
 (0)