Skip to content

Commit 6c109b6

Browse files
committed
Add missing option localInfileBufferSize
1 parent 087f412 commit 6c109b6

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/main/java/io/asyncer/r2dbc/mysql/MySqlConnectionFactoryProvider.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@ public final class MySqlConnectionFactoryProvider implements ConnectionFactoryPr
203203
public static final Option<String> ALLOW_LOAD_LOCAL_INFILE_IN_PATH =
204204
Option.valueOf("allowLoadLocalInfileInPath");
205205

206+
/**
207+
* Option to set the buffer size for local infile. Default to {@code 8192}.
208+
*
209+
* @since 1.1.2
210+
*/
211+
public static final Option<Integer> LOCAL_INFILE_BUFFER_SIZE =
212+
Option.valueOf("localInfileBufferSize");
213+
206214
/**
207215
* Option to set compression algorithms. Default to [{@link CompressionAlgorithm#UNCOMPRESSED}].
208216
* <p>
@@ -314,6 +322,8 @@ static MySqlConnectionConfiguration setup(ConnectionFactoryOptions options) {
314322
builder::useServerPrepareStatement, builder::useServerPrepareStatement);
315323
mapper.optional(ALLOW_LOAD_LOCAL_INFILE_IN_PATH).asString()
316324
.to(builder::allowLoadLocalInfileInPath);
325+
mapper.optional(LOCAL_INFILE_BUFFER_SIZE).asInt()
326+
.to(builder::localInfileBufferSize);
317327
mapper.optional(QUERY_CACHE_SIZE).asInt()
318328
.to(builder::queryCacheSize);
319329
mapper.optional(PREPARE_CACHE_SIZE).asInt()

src/test/java/io/asyncer/r2dbc/mysql/MySqlConnectionFactoryProviderTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import javax.net.ssl.HostnameVerifier;
3636
import javax.net.ssl.SSLSession;
3737
import java.io.UnsupportedEncodingException;
38+
import java.lang.reflect.Method;
39+
import java.lang.reflect.Modifier;
3840
import java.net.URLEncoder;
3941
import java.time.Duration;
4042
import java.time.ZoneId;
@@ -44,6 +46,7 @@
4446
import java.util.Set;
4547
import java.util.function.Function;
4648
import java.util.function.Predicate;
49+
import java.util.stream.Collectors;
4750
import java.util.stream.Stream;
4851

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

456+
@Test
457+
void allConfigurationOptions() {
458+
List<String> exceptConfigs = Arrays.asList(
459+
"extendWith",
460+
"username",
461+
"zeroDateOption");
462+
List<String> exceptOptions = Arrays.asList(
463+
"driver",
464+
"ssl",
465+
"protocol",
466+
"zeroDate",
467+
"lockWaitTimeout",
468+
"statementTimeout");
469+
Set<String> allOptions = Stream.concat(
470+
Arrays.stream(ConnectionFactoryOptions.class.getFields()),
471+
Arrays.stream(MySqlConnectionFactoryProvider.class.getFields())
472+
)
473+
.filter(field -> Modifier.isStatic(field.getModifiers()) && field.getType() == Option.class)
474+
.map(field -> {
475+
try {
476+
return ((Option<?>) field.get(null)).name();
477+
} catch (IllegalAccessException e) {
478+
throw new RuntimeException(e);
479+
}
480+
})
481+
.filter(name -> !exceptOptions.contains(name))
482+
.collect(Collectors.toSet());
483+
Set<String> allBuilderOptions = Arrays.stream(MySqlConnectionConfiguration.Builder.class.getMethods())
484+
.filter(method -> method.getParameterCount() >= 1 &&
485+
method.getReturnType() == MySqlConnectionConfiguration.Builder.class &&
486+
!exceptConfigs.contains(method.getName()))
487+
.map(Method::getName)
488+
.collect(Collectors.toSet());
489+
490+
assertThat(allBuilderOptions).containsExactlyInAnyOrderElementsOf(allOptions);
491+
}
492+
453493
@ParameterizedTest
454494
@MethodSource
455495
void sessionVariables(String input, List<String> expected) {

0 commit comments

Comments
 (0)