Skip to content

Commit

Permalink
Add missing option localInfileBufferSize
Browse files Browse the repository at this point in the history
  • Loading branch information
mirromutth committed Feb 16, 2024
1 parent 087f412 commit 6c109b6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ public final class MySqlConnectionFactoryProvider implements ConnectionFactoryPr
public static final Option<String> ALLOW_LOAD_LOCAL_INFILE_IN_PATH =
Option.valueOf("allowLoadLocalInfileInPath");

/**
* Option to set the buffer size for local infile. Default to {@code 8192}.
*
* @since 1.1.2
*/
public static final Option<Integer> LOCAL_INFILE_BUFFER_SIZE =
Option.valueOf("localInfileBufferSize");

/**
* Option to set compression algorithms. Default to [{@link CompressionAlgorithm#UNCOMPRESSED}].
* <p>
Expand Down Expand Up @@ -314,6 +322,8 @@ static MySqlConnectionConfiguration setup(ConnectionFactoryOptions options) {
builder::useServerPrepareStatement, builder::useServerPrepareStatement);
mapper.optional(ALLOW_LOAD_LOCAL_INFILE_IN_PATH).asString()
.to(builder::allowLoadLocalInfileInPath);
mapper.optional(LOCAL_INFILE_BUFFER_SIZE).asInt()
.to(builder::localInfileBufferSize);
mapper.optional(QUERY_CACHE_SIZE).asInt()
.to(builder::queryCacheSize);
mapper.optional(PREPARE_CACHE_SIZE).asInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URLEncoder;
import java.time.Duration;
import java.time.ZoneId;
Expand All @@ -44,6 +46,7 @@
import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static io.asyncer.r2dbc.mysql.MySqlConnectionFactoryProvider.PASSWORD_PUBLISHER;
Expand Down Expand Up @@ -450,6 +453,43 @@ void validPasswordSupplier() {
assertThat(ConnectionFactories.get(options)).isExactlyInstanceOf(MySqlConnectionFactory.class);
}

@Test
void allConfigurationOptions() {
List<String> exceptConfigs = Arrays.asList(
"extendWith",
"username",
"zeroDateOption");
List<String> exceptOptions = Arrays.asList(
"driver",
"ssl",
"protocol",
"zeroDate",
"lockWaitTimeout",
"statementTimeout");
Set<String> allOptions = Stream.concat(
Arrays.stream(ConnectionFactoryOptions.class.getFields()),
Arrays.stream(MySqlConnectionFactoryProvider.class.getFields())
)
.filter(field -> Modifier.isStatic(field.getModifiers()) && field.getType() == Option.class)
.map(field -> {
try {
return ((Option<?>) field.get(null)).name();
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
})
.filter(name -> !exceptOptions.contains(name))
.collect(Collectors.toSet());
Set<String> allBuilderOptions = Arrays.stream(MySqlConnectionConfiguration.Builder.class.getMethods())
.filter(method -> method.getParameterCount() >= 1 &&
method.getReturnType() == MySqlConnectionConfiguration.Builder.class &&
!exceptConfigs.contains(method.getName()))
.map(Method::getName)
.collect(Collectors.toSet());

assertThat(allBuilderOptions).containsExactlyInAnyOrderElementsOf(allOptions);
}

@ParameterizedTest
@MethodSource
void sessionVariables(String input, List<String> expected) {
Expand Down

0 comments on commit 6c109b6

Please sign in to comment.