-
Notifications
You must be signed in to change notification settings - Fork 404
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
Eager validation of configuration parameters #576
Conversation
…eption when invalid - Config params should be validated eagerly in setter method and an IllegalArgumentException thrown in case of failure - Add missing test cases and validations
e354c1b
to
6fe955b
Compare
Also stopping the AbstractNestedJsonProvider before the wrapped providers prevents usage during the shutdown process (at least if a isStarted() guard was present). Anyway, stopping in the reverse start order is always a good advice.
- check for null config params - guard start/stop with isStarted() - delay creation of NullJsonFactory/Generator until start
I'm ok with changing it to throw if null in this major release, but this will need to be mentioned in the backwards incompatibilities in the release notes. Create a separate PR if you change this.
I think IllegalStateException was used because it indicates that the value is only invalid due to the current state of the object (i.e. the same value could be valid if the object was in a different state). Whereas IllegalArgumentException means the given argument is never valid, regardless of the object state.
I'm ok with changing the default since this is a major release, but it will need to be mentioned in backwards incompatibilities section. Create a separate PR if you change this.
queueSize is leftover from before the appender used the disruptor. I'm fine with marking as deprecated. The unfortunate thing about deprecating parameters is that the user gets no indication of deprecation (like via javac or ide), since these parameters are usually set via xml configuration. We could add a warning to provide more visibility.
Sure, feel free to update.
Feel free to deprecate, and add a warning for visibility. |
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.
All changes so far look great!
According to me this property should not be repeated inside the
I propose to remove it from With this change, configuration of the "primary" strategy will follow the same principles as others like the "roundrobin" strategy for instance. |
|
Since the class name is AsyncDisruptorAppender, and the disruptor uses a ring buffer, not a queue, I think ringBufferSize is more appropriate. It also implicitly explains the reason why the value must be a power of 2, since that is a constraint of the disruptor ring buffer. |
849b9aa
to
6186157
Compare
It's in AbstractLogstashTcpSocketAppender for backwards compatibility purposes from before the connection strategies were implemented in #195 in 4.10. Previously (< 4.10) the concept of a connection strategy did not exist, and secondaryConnectionTTL was a just property on the appender. In 4.10, connection strategies were implemented, and the property remained on the appender for backwards compatibility.
I disagree with removing without deprecating first. For better usability, logstash-logback-encoder should always strive to deprecate first before removal. Not everyone will notice the deprecation warning, but some people will, and it provides a better experience for them.
I agree with the change, as long as the existing behavior is kept in a deprecated fashion until the next major release (8.0) |
Configuration parameters should be validated eagerly by the setter method and an IllegalArgumentException thrown in case of failure. This PR targets the parameters that do not follow this strategy + some additional test cases to cover missing cases.
Reviewing the code raises the following additional questions:
(1)
AbstractLogstashTcpSocketAppender#setWriteTimeout(Duration)
acceptsnull
as argument but converts it to the default value instead. I personally don't like this approach and prefer when "get" behaves the opposite of "set", i.e. returns the same value. The javadoc does not explicitly state thatnull
is a valid value (0
should be used to disable the feature)... I think we should simply refuse it and throw an exception. Ifnull
must remain a valid option, then I would rather handle the case withinisWriteTimeoutEnabled()
just like what is done forkeepAliveDuration
.(2)
AbstractLogstashTcpSocketAppender#setSecondaryConnectionTTL()
should probably throw anIllegalArgumentException
instead ofIllegalStateException
just like the other setter methods.(3) The default keep alive message uses the platform line ending. However, recipient like Elastic Logstash use
\n
by default (Unix style). Don't you think we should use the same default as well?(4) AsyncDisruptorAppender uses
ringBufferSize
butAbstractLogstashTcpSocketAppender
also declaresqueueSize
as an alias for the same property. Don't you think we should stick to one and deprecate the other?(5) The javadoc describing each parameter is often declared on the field itself rather than the setter. Shouldn't we at least have a "user friendly" version on the setter and keep a "developer" version on the field?
(6) I think it would be better to rename
AbstractLogstashTcpSocketAppender#acceptConnectionTimeout
toconnectTimeout
to best represent the actual use of the property (and deprecate the old name).Note: don't merge this PR yet - I'd like to keep it open to discuss other additional points with you...