Repository navigation
Conversation
Socket and syslog appenders were dropped when the configured host did not resolve at configuration time, so a host that only appeared in DNS later (a Kubernetes Service created after the JVM starts, for example) never recovered without a restart. Accept a syntactically valid host name that does not resolve yet, and let the existing reconnector resolve it again on every attempt. UDP appenders keep the host unresolved and retry it on each datagram.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4309.
@ValidHostandTcpSocketManagerFactoryboth treat a host that does not resolve now as invalid, so the appender is discarded at configuration time. A host that only appears in DNS later (a Kubernetes Service created after the JVM starts) never recovers without a restart, andreconnectionDelayMilliscannot help because no appender or manager is left.Changes
ValidHostValidatorstill rejects null, empty, malformed names and out-of-range IPv4 literals, but accepts a syntactically valid host name that does not resolve yet and logs a warning. The name is resolved when connecting.TcpSocketManagerFactoryno longer returnsnullonUnknownHostExceptionwhen a reconnection delay is configured; it creates a manager with no socket and lets the existingReconnectorresolve the host on every attempt. Appenders always get a delay (getSocketManagerdefaults it to 30s), so this also covers default configurations.DatagramSocketManager/DatagramOutputStreamresolve the host on the first datagram instead of failing construction, and retry while the host stays unresolved.AbstractSocketManager#getContentFormatfalls back to the host name while no address is known.@ValidHostJavadoc and the plugin manual.Tests
SocketAppenderReconnectTest#unresolvable_host_should_be_resolved_on_reconnectfails before the change (appender dropped for an unresolvable host) and passes after it.ValidHostValidatorTestcovers the accepted and rejected names, andDatagramOutputStreamTestcovers the UDP retry path.Targeted run: 82 tests in
SocketAppender*Test,SyslogAppender*Test,Tls*Test,SslSocketManagerTest,ValidHostValidatorTest,DatagramOutputStreamTest, 0 failures.spotless:checkpasses.