-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing fluent initialization/setting of S3NioSpiConfiguration #114
Conversation
…t. It also cleans up a bit the code using proper type for properties S3_SPI_READ_MAX_FRAGMENT_SIZE_PROPERTY and S3_SPI_READ_MAX_FRAGMENT_NUMBER_PROPERTY
* | ||
*/ | ||
public class StringUtils { | ||
public static String join(String separator, String[] elements, int startAt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly you can do this with a stream and collector or reuse String.join()
with the sub array? https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#join-java.lang.CharSequence-java.lang.CharSequence...-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the JDK code I found there is a StringJoin that is supposed to do help in joining strings :) I would not complicate more the implementation as being a utility method I want to keep the implementation as most efficient as possible.
* TODO: to replace with Java11's isBlank when moving away from Java8 | ||
*/ | ||
public static boolean isBlank(final String s) { | ||
return s.replace(" ", "").replace("\n", "").replace("\r", "").replace("\t", "").isEmpty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using String.replaceAll("\p{javaWhitespace}", "")
to replace anything that is equivalent to java.lang.Character.isWhitespace()
. This will cover all kinds of form feed, line feed as well, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you could even use String.matches(regex)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uhhh... mine was a pretty bad implementation actually... I am replacing with a much more efficient version (with a simple loop... less is more...)
src/main/java/software/amazon/nio/spi/s3/config/S3NioSpiConfiguration.java
Outdated
Show resolved
Hide resolved
src/main/java/software/amazon/nio/spi/s3/config/S3NioSpiConfiguration.java
Outdated
Show resolved
Hide resolved
src/main/java/software/amazon/nio/spi/s3/config/S3NioSpiConfiguration.java
Show resolved
Hide resolved
src/main/java/software/amazon/nio/spi/s3/config/S3NioSpiConfiguration.java
Outdated
Show resolved
Hide resolved
src/main/java/software/amazon/nio/spi/s3/config/S3NioSpiConfiguration.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are getting there. A couple of changes still required.
src/main/java/software/amazon/nio/spi/s3/config/S3NioSpiConfiguration.java
Show resolved
Hide resolved
src/main/java/software/amazon/nio/spi/s3/config/S3NioSpiConfiguration.java
Outdated
Show resolved
Hide resolved
src/main/java/software/amazon/nio/spi/s3/config/S3NioSpiConfiguration.java
Outdated
Show resolved
Hide resolved
src/test/java/software/amazon/nio/spi/s3/config/S3NioSpiConfigurationTest.java
Outdated
Show resolved
Hide resolved
better implementation of withCredentials()
better implementation of withCredentials()
I should have resolved all comments, but see below. There is an odd issue with gradle... I do not know why it is complaining about the version of a class in the logback package....
I do not have the problem with maven and I am not a gradle expert. Can you give me some help?
I have implemented it as suggested for your review. However I am doubtful: this configuration class is mostly designed to glue envvar/syspro and simple configuration properties. WRT credentials the original implementation did not provide special support credentials because it delegated it to the underlying AWS library. To support 3rd party services we need instead to add a key/secret mechanism. The doubt is that support for different authentication means, usually AWS specific, can still be achieved without the need of withCredentials(AwsCredentials) just not setting any credentials. |
@markjschreiber any chances we can sort out this one? it would be very helpful to start to work on s3x provider |
Almost. I think that if you want to retain the Apart from that it looks good although one of the unit tests seems to be failing right now. |
@markjschreiber it should be ready to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for the PR!
It also cleans up a bit the code using proper type for properties S3_SPI_READ_MAX_FRAGMENT_SIZE_PROPERTY and S3_SPI_READ_MAX_FRAGMENT_NUMBER_PROPERTY
Issue #
#112
Description of changes:
See #112 for a description of the functionality introduced.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.