Repository: netty/netty
Issue: epoll_wait produces an EINVAL error since 4.1.30
Labels: defect

### Expected behavior
epoll_wait should work in 4.1.30 like it did in 4.1.29

### Actual behavior
Since switching to 4.1.30, `EpollEventLoop`'s `handleLoopException` is triggered with 
 `io.netty.channel.ChannelException: timerfd_settime() failed: Invalid argument`, which points to `timerfd_settime`. This causes an epoll thread to be "blocked" sleeping.

The issue is visible in a Spring Boot test dealing with bad SSL certificates, which uses reactor/reactor-netty.

While investigating this remotely with limited resources (partial access to the logs and reproduction case, no local linux machine to test on), I found that the 4.1.30 suspiciously contained an issue related to epoll_wait.

Looking at the PR I think I might have found the regression:

https://github.com/netty/netty/pull/7816/files#diff-db3e069239a403b954e3ebc024ba9507R251

`Integer.MAX_VALUE` should be `MAX_SCHEDULED_TIMERFD_NS` (`999,999,999`) like it was before the PR, else `timerfd_settime` might return `EINVAL` if it is too large.

### Steps to reproduce
The issue is triggered during tests of Spring Boot, but this is a smaller reproduction snippet that is using Spring Framework 5:

```java
@Test
    public void strippedDown() {
        assertThatExceptionOfType(RuntimeException.class)
                .isThrownBy(() -> WebClient.create().get()
                        .uri("https://" + "self-signed.badssl.com/").exchange()
                        .block(Duration.ofSeconds(10)))
                .withCauseInstanceOf(SSLException.class);
    }
```

I can try to spin up a repository with a maven project that reproduces the issue and can be run without set up if you need.

### Netty version
4.1.30

### JVM version (e.g. `java -version`)
??

### OS version (e.g. `uname -a`)
??

Issue comments:
I can fill in some of the blanks about the environment where we've seen the issue:

### JVM version (e.g. java -version)

```
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-1~deb9u1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
```

### OS version (e.g. name -a)

```
Linux e4fff31d-4e97-44d3-5088-942369c43954 4.4.0-134-generic #160~14.04.1-Ubuntu SMP Fri Aug 17 11:07:07 UTC 2018 x86_64 GNU/Linux
```


@wilkinsona this sounds right... would you be able to submit a PR to fix it with a unit test included.

/cc @simonbasle 

Also @carl-mastrangelo as he did the pr...
I'm releasing reactor-netty today and will submit a PR for the fix right after, once I got a Linux VM set up to reproduce and verify the fix
@simonbasle thanks a lot! 
@simonbasle I can lend a hand, standby.
@normanmaurer there's something funky with the caught exception, IDE doesn't show anything, and when you try and access it, it throws another invisible exception..
![screenshot from 2018-10-11 12-13-30](https://user-images.githubusercontent.com/323497/46797313-20ba7080-cd4f-11e8-8326-ae7d34081c25.png)

oh wait it uses the compiled class from the jar iirc, need to reinstall the artifact each time changes are made for the debugger to work correctly.
Created PR https://github.com/netty/netty/pull/8350
@simonbasle @wilkinsona could you verify https://github.com/netty/netty/pull/8350 ?
@normanmaurer any easier way of obtaining a snapshot of that branch other than building locally? (knowing that the issue manifested in CI)
@simonbasle I just pushed a snapshot with the fix included to oss.sonatype.org. 4.1.31.Final-SNAPSHOT should have it. 
outstanding, thanks @normanmaurer we'll look at the snapshot to validate the fix
Unfortunately, I'm still seeing the hang with 4.1.31.Final-SNAPSHOT. The log output produced by the test that hangs:

```
2018-10-19 11:36:37.884  INFO ${sys:PID} --- [           main] ationConfigReactiveWebApplicationContext : Registering annotated classes: [class org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfig
uration,class org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,class org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration,class org.springframework.boot.actuate.autoconfigur
e.health.HealthIndicatorAutoConfiguration,class org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration,class org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.ReactiveClo
udFoundryActuatorAutoConfiguration,class org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.ReactiveCloudFoundryActuatorAutoConfigurationTests$WebClientCustomizerConfig,class org.springframework.boot.ac
tuate.autoconfigure.endpoint.EndpointAutoConfiguration,class org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration,class org.springframework.boot.autoconfigure.http.HttpMessageConverter
sAutoConfiguration,class org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration,class org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfigurati
on,class org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration,class org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration]
2018-10-19 11:36:38.379  INFO ${sys:PID} --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.ReactiveCloudFoundryActuatorAutoConfigu
ration$IgnoredPathsSecurityConfiguration' of type [org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.ReactiveCloudFoundryActuatorAutoConfiguration$IgnoredPathsSecurityConfiguration$$EnhancerBySpringCGL
IB$$fcdef00b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-10-19 11:36:39.646  INFO ${sys:PID} --- [           main] ctiveUserDetailsServiceAutoConfiguration : 

Using generated security password: 94605c80-ffae-4448-8f75-ac3e6d06e1b4

2018-10-19 11:36:39.689  INFO ${sys:PID} --- [           main] o.h.v.i.u.Version                        : HV000001: Hibernate Validator 6.0.13.Final
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.11.1/log4j-slf4j-impl-2.11.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
11:36:40.044 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
11:36:40.063 [main] DEBUG io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false
11:36:40.063 [main] DEBUG io.netty.util.internal.PlatformDependent0 - Java version: 8
11:36:40.065 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
11:36:40.065 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
11:36:40.066 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
11:36:40.066 [main] DEBUG io.netty.util.internal.PlatformDependent0 - direct buffer constructor: available
11:36:40.067 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true
11:36:40.067 [main] DEBUG io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable prior to Java9
11:36:40.067 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): available
11:36:40.067 [main] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
11:36:40.068 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: /tmp (java.io.tmpdir)
11:36:40.068 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
11:36:40.069 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: 954728448 bytes
11:36:40.069 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1
11:36:40.070 [main] DEBUG io.netty.util.internal.CleanerJava6 - java.nio.ByteBuffer.cleaner(): available
11:36:40.070 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
11:36:40.081 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple
11:36:40.081 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.targetRecords: 4
11:36:40.084 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 9
11:36:40.084 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 9
11:36:40.084 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
11:36:40.084 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11
11:36:40.084 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216
11:36:40.084 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512
11:36:40.084 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
11:36:40.084 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
11:36:40.084 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
11:36:40.084 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
11:36:40.084 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.useCacheForAllThreads: true
11:36:40.088 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024
11:36:40.088 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096
11:36:40.096 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false
11:36:40.096 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false
11:36:40.097 [main] DEBUG io.netty.util.NetUtil - Loopback interface: lo (lo, 127.0.0.1)
11:36:40.098 [main] DEBUG io.netty.util.NetUtil - /proc/sys/net/core/somaxconn: 128
11:36:40.102 [main] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
11:36:40.132 [main] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 12
11:36:40.154 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
11:36:40.154 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
11:36:40.161 [main] DEBUG io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available
11:36:40.177 [main] WARN reactor.netty.tcp.TcpResources - [http] resources will use the default LoopResources: DefaultLoopResources {prefix=reactor-http, daemon=true, selectCount=6, workerCount=6}
11:36:40.177 [main] WARN reactor.netty.tcp.TcpResources - [http] resources will use the default ConnectionProvider: PooledConnectionProvider {name=http, poolFactory=reactor.netty.resources.ConnectionProvider$$Lambda$270/
21063905@16a5c7e4}
2018-10-19 11:36:40.282  INFO ${sys:PID} --- [           main] o.s.b.a.e.w.EndpointLinksResolver        : Exposing 1 endpoint(s) beneath base path '/actuator'
11:36:40.571 [main] DEBUG io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.workdir: /tmp (io.netty.tmpdir)
11:36:40.571 [main] DEBUG io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.deleteLibAfterLoading: true
11:36:40.571 [main] DEBUG io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.tryPatchShadedId: true
11:36:40.574 [main] DEBUG io.netty.util.internal.NativeLibraryLoader - Unable to load the library 'netty_transport_native_epoll_x86_64', trying other loading mechanism.
java.lang.UnsatisfiedLinkError: no netty_transport_native_epoll_x86_64 in java.library.path
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
	at java.lang.Runtime.loadLibrary0(Runtime.java:870)
	at java.lang.System.loadLibrary(System.java:1122)
	at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:336)
	at java.security.AccessController.doPrivileged(Native Method)
	at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:328)
	at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:306)
	at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)
	at io.netty.channel.epoll.Native.loadNativeLibrary(Native.java:198)
	at io.netty.channel.epoll.Native.<clinit>(Native.java:61)
	at io.netty.channel.epoll.Epoll.<clinit>(Epoll.java:38)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at reactor.netty.resources.DefaultLoopEpoll.<clinit>(DefaultLoopEpoll.java:47)
	at reactor.netty.resources.LoopResources.preferNative(LoopResources.java:216)
	at reactor.netty.resources.DefaultLoopResources.onClient(DefaultLoopResources.java:156)
	at reactor.netty.tcp.TcpResources.onClient(TcpResources.java:168)
	at reactor.netty.http.client.HttpClientConnect$HttpTcpClient.connect(HttpClientConnect.java:141)
	at reactor.netty.tcp.TcpClientOperator.connect(TcpClientOperator.java:43)
	at reactor.netty.tcp.TcpClientOperator.connect(TcpClientOperator.java:43)
	at reactor.netty.tcp.TcpClientOperator.connect(TcpClientOperator.java:43)
	at reactor.netty.tcp.TcpClientOperator.connect(TcpClientOperator.java:43)
	at reactor.netty.tcp.TcpClientOperator.connect(TcpClientOperator.java:43)
	at reactor.netty.tcp.TcpClient.connect(TcpClient.java:185)
	at reactor.netty.http.client.HttpClientFinalizer.connect(HttpClientFinalizer.java:68)
	at reactor.netty.http.client.HttpClientFinalizer.responseConnection(HttpClientFinalizer.java:85)
	at org.springframework.http.client.reactive.ReactorClientHttpConnector.connect(ReactorClientHttpConnector.java:111)
	at org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.exchange(ExchangeFunctions.java:103)
	at org.springframework.web.reactive.function.client.DefaultWebClient$DefaultRequestBodyUriSpec.exchange(DefaultWebClient.java:321)
	at org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.ReactiveCloudFoundryActuatorAutoConfigurationTests.lambda$sslValidationNotSkippedByDefault$13(ReactiveCloudFoundryActuatorAutoConfigurationT
ests.java:339)
	at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.accept(AbstractApplicationContextRunner.java:346)
	at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.lambda$null$0(AbstractApplicationContextRunner.java:280)
	at org.springframework.boot.test.util.TestPropertyValues.applyToSystemProperties(TestPropertyValues.java:130)
	at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.lambda$run$1(AbstractApplicationContextRunner.java:278)
	at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.withContextClassLoader(AbstractApplicationContextRunner.java:290)
	at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.run(AbstractApplicationContextRunner.java:277)
	at org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.ReactiveCloudFoundryActuatorAutoConfigurationTests.sslValidationNotSkippedByDefault(ReactiveCloudFoundryActuatorAutoConfigurationTests.java:
327)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
11:36:40.575 [main] DEBUG io.netty.util.internal.NativeLibraryLoader - netty_transport_native_epoll_x86_64 cannot be loaded from java.libary.path, now trying export to -Dio.netty.native.workdir: /tmp
java.lang.UnsatisfiedLinkError: no netty_transport_native_epoll_x86_64 in java.library.path
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
	at java.lang.Runtime.loadLibrary0(Runtime.java:870)
	at java.lang.System.loadLibrary(System.java:1122)
	at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
	at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:316)
	at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)
	at io.netty.channel.epoll.Native.loadNativeLibrary(Native.java:198)
	at io.netty.channel.epoll.Native.<clinit>(Native.java:61)
	at io.netty.channel.epoll.Epoll.<clinit>(Epoll.java:38)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at reactor.netty.resources.DefaultLoopEpoll.<clinit>(DefaultLoopEpoll.java:47)
	at reactor.netty.resources.LoopResources.preferNative(LoopResources.java:216)
	at reactor.netty.resources.DefaultLoopResources.onClient(DefaultLoopResources.java:156)
	at reactor.netty.tcp.TcpResources.onClient(TcpResources.java:168)
	at reactor.netty.http.client.HttpClientConnect$HttpTcpClient.connect(HttpClientConnect.java:141)
	at reactor.netty.tcp.TcpClientOperator.connect(TcpClientOperator.java:43)
	at reactor.netty.tcp.TcpClientOperator.connect(TcpClientOperator.java:43)
	at reactor.netty.tcp.TcpClientOperator.connect(TcpClientOperator.java:43)
	at reactor.netty.tcp.TcpClientOperator.connect(TcpClientOperator.java:43)
	at reactor.netty.tcp.TcpClientOperator.connect(TcpClientOperator.java:43)
	at reactor.netty.tcp.TcpClient.connect(TcpClient.java:185)
	at reactor.netty.http.client.HttpClientFinalizer.connect(HttpClientFinalizer.java:68)
	at reactor.netty.http.client.HttpClientFinalizer.responseConnection(HttpClientFinalizer.java:85)
	at org.springframework.http.client.reactive.ReactorClientHttpConnector.connect(ReactorClientHttpConnector.java:111)
	at org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.exchange(ExchangeFunctions.java:103)
	at org.springframework.web.reactive.function.client.DefaultWebClient$DefaultRequestBodyUriSpec.exchange(DefaultWebClient.java:321)
	at org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.ReactiveCloudFoundryActuatorAutoConfigurationTests.lambda$sslValidationNotSkippedByDefault$13(ReactiveCloudFoundryActuatorAutoConfigurationT
ests.java:339)
	at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.accept(AbstractApplicationContextRunner.java:346)
	at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.lambda$null$0(AbstractApplicationContextRunner.java:280)
	at org.springframework.boot.test.util.TestPropertyValues.applyToSystemProperties(TestPropertyValues.java:130)
	at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.lambda$run$1(AbstractApplicationContextRunner.java:278)
	at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.withContextClassLoader(AbstractApplicationContextRunner.java:290)
	at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.run(AbstractApplicationContextRunner.java:277)
	at org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.ReactiveCloudFoundryActuatorAutoConfigurationTests.sslValidationNotSkippedByDefault(ReactiveCloudFoundryActuatorAutoConfigurationTests.java:
327)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
	Suppressed: java.lang.UnsatisfiedLinkError: no netty_transport_native_epoll_x86_64 in java.library.path
		at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
		at java.lang.Runtime.loadLibrary0(Runtime.java:870)
		at java.lang.System.loadLibrary(System.java:1122)
		at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:336)
		at java.security.AccessController.doPrivileged(Native Method)
		at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:328)
		at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:306)
		... 56 common frames omitted
11:36:40.586 [main] DEBUG io.netty.util.internal.NativeLibraryLoader - Successfully loaded the library /tmp/libnetty_transport_native_epoll_x86_641906979574480854256.so
11:36:40.586 [main] DEBUG reactor.netty.resources.DefaultLoopEpoll - Default Epoll support : true
11:36:40.587 [main] DEBUG reactor.netty.resources.DefaultLoopKQueue - Default KQueue support : false
11:36:40.637 [main] DEBUG io.netty.handler.ssl.OpenSsl - netty-tcnative not in the classpath; OpenSslEngine will be unavailable.
11:36:40.756 [main] DEBUG io.netty.handler.ssl.JdkSslContext - Default protocols (JDK): [TLSv1.2, TLSv1.1, TLSv1] 
11:36:40.756 [main] DEBUG io.netty.handler.ssl.JdkSslContext - Default cipher suites (JDK): [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_EC
DHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA]
11:36:40.780 [main] DEBUG reactor.netty.resources.PooledConnectionProvider - Creating new client pool [http] for self-signed.badssl.com:443
11:36:40.795 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.processId: 8426 (auto-detected)
11:36:40.797 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.machineId: 02:42:ac:ff:fe:11:00:02 (auto-detected)
11:36:40.820 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled
11:36:40.820 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0
11:36:40.820 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384
11:36:40.835 [reactor-http-client-epoll-10] DEBUG reactor.netty.resources.PooledConnectionProvider - [id: 0x07b0bdab] Created new pooled channel, now 0 active connections and 1 inactive connections
11:36:40.864 [reactor-http-client-epoll-10] DEBUG io.netty.buffer.AbstractByteBuf - -Dio.netty.buffer.checkAccessible: true
11:36:40.864 [reactor-http-client-epoll-10] DEBUG io.netty.buffer.AbstractByteBuf - -Dio.netty.buffer.checkBounds: true
11:36:40.865 [reactor-http-client-epoll-10] DEBUG io.netty.util.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector@5b2d4d1e
11:36:40.883 [reactor-http-client-epoll-10] DEBUG reactor.netty.tcp.SslProvider - [id: 0x07b0bdab] SSL enabled using engine SSLEngineImpl and SNI self-signed.badssl.com:443
11:36:40.890 [reactor-http-client-epoll-10] DEBUG reactor.netty.channel.BootstrapHandlers - [id: 0x07b0bdab] Initialized pipeline DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (react
or.left.sslReader = reactor.netty.tcp.SslProvider$SslReadHandler), (BootstrapHandlers$BootstrapInitializerHandler#0 = reactor.netty.channel.BootstrapHandlers$BootstrapInitializerHandler), (SimpleChannelPool$1#0 = io.nett
y.channel.pool.SimpleChannelPool$1), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.left.decompressor = io.netty.handler.codec.http.HttpContentDecompressor), (reactor.right.reactiveBridg
e = reactor.netty.channel.ChannelOperationsHandler)}
11:36:41.028 [reactor-http-client-epoll-10] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxCapacityPerThread: 4096
11:36:41.029 [reactor-http-client-epoll-10] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxSharedCapacityFactor: 2
11:36:41.029 [reactor-http-client-epoll-10] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.linkCapacity: 16
11:36:41.029 [reactor-http-client-epoll-10] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.ratio: 8
11:36:41.041 [reactor-http-client-epoll-10] DEBUG reactor.netty.resources.PooledConnectionProvider - [id: 0x07b0bdab, L:/172.17.0.2:50472 - R:self-signed.badssl.com/104.154.89.105:443] Registering pool release on close e
vent for channel
11:36:41.042 [reactor-http-client-epoll-10] DEBUG reactor.netty.resources.PooledConnectionProvider - [id: 0x07b0bdab, L:/172.17.0.2:50472 - R:self-signed.badssl.com/104.154.89.105:443] Channel connected, now 1 active con
nections and 0 inactive connections
11:36:41.042 [reactor-http-client-epoll-10] WARN io.netty.channel.epoll.EpollEventLoop - Unexpected exception in the selector loop.
io.netty.channel.ChannelException: timerfd_settime() failed: Invalid argument
	at io.netty.channel.epoll.Native.epollWait0(Native Method)
	at io.netty.channel.epoll.Native.epollWait(Native.java:114)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:253)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:278)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
	at java.lang.Thread.run(Thread.java:748)
11:36:42.045 [reactor-http-client-epoll-10] WARN io.netty.channel.epoll.EpollEventLoop - Unexpected exception in the selector loop.
io.netty.channel.ChannelException: timerfd_settime() failed: Invalid argument
	at io.netty.channel.epoll.Native.epollWait0(Native Method)
	at io.netty.channel.epoll.Native.epollWait(Native.java:114)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:253)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:278)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
	at java.lang.Thread.run(Thread.java:748)
11:36:43.047 [reactor-http-client-epoll-10] WARN io.netty.channel.epoll.EpollEventLoop - Unexpected exception in the selector loop.
io.netty.channel.ChannelException: timerfd_settime() failed: Invalid argument
	at io.netty.channel.epoll.Native.epollWait0(Native Method)
	at io.netty.channel.epoll.Native.epollWait(Native.java:114)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:253)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:278)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
	at java.lang.Thread.run(Thread.java:748)
11:36:44.050 [reactor-http-client-epoll-10] WARN io.netty.channel.epoll.EpollEventLoop - Unexpected exception in the selector loop.
io.netty.channel.ChannelException: timerfd_settime() failed: Invalid argument
	at io.netty.channel.epoll.Native.epollWait0(Native Method)
	at io.netty.channel.epoll.Native.epollWait(Native.java:114)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:253)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:278)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
	at java.lang.Thread.run(Thread.java:748)
11:36:45.052 [reactor-http-client-epoll-10] WARN io.netty.channel.epoll.EpollEventLoop - Unexpected exception in the selector loop.
io.netty.channel.ChannelException: timerfd_settime() failed: Invalid argument
	at io.netty.channel.epoll.Native.epollWait0(Native Method)
	at io.netty.channel.epoll.Native.epollWait(Native.java:114)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:253)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:278)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
	at java.lang.Thread.run(Thread.java:748)
11:36:46.053 [reactor-http-client-epoll-10] WARN io.netty.channel.epoll.EpollEventLoop - Unexpected exception in the selector loop.
io.netty.channel.ChannelException: timerfd_settime() failed: Invalid argument
	at io.netty.channel.epoll.Native.epollWait0(Native Method)
	at io.netty.channel.epoll.Native.epollWait(Native.java:114)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:253)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:278)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
	at java.lang.Thread.run(Thread.java:748)
11:36:47.056 [reactor-http-client-epoll-10] WARN io.netty.channel.epoll.EpollEventLoop - Unexpected exception in the selector loop.
io.netty.channel.ChannelException: timerfd_settime() failed: Invalid argument
	at io.netty.channel.epoll.Native.epollWait0(Native Method)
	at io.netty.channel.epoll.Native.epollWait(Native.java:114)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:253)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:278)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
	at java.lang.Thread.run(Thread.java:748)
11:36:48.058 [reactor-http-client-epoll-10] WARN io.netty.channel.epoll.EpollEventLoop - Unexpected exception in the selector loop.
io.netty.channel.ChannelException: timerfd_settime() failed: Invalid argument
	at io.netty.channel.epoll.Native.epollWait0(Native Method)
	at io.netty.channel.epoll.Native.epollWait(Native.java:114)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:253)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:278)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
	at java.lang.Thread.run(Thread.java:748)
```

I realise this isn't much to go on. I'll see if I can set up an environment where I can more easily attach a debugger and see exactly what's happening.
I am doubting myself now. I have set up an Ubuntu VM and, while the test still hangs, I am not seeing the `io.netty.channel.ChannelException`. Please disregard the above for the time being at least.

I still suspect that the hang is due to something that's changed in Netty as it does not occur with 4.1.29.Final but I don't yet know what the cause is.
Ok, I've recreated the `io.netty.channel.ChannelException` with the debugger attached using 4.1.31.Final-SNAPSHOT. When it happens, `EpollEventLoop.epollWait(boolean)` calls `Native.epollWait(FileDescriptor, EpollEventArray, FileDescriptor, int, int)` passing in `-1` for both `timeoutSec` and `timeoutNs`. That points to #7816 again as it introduced [the if-branch](https://github.com/netty/netty/pull/7816/files#diff-db3e069239a403b954e3ebc024ba9507R244) that results in `-1` being used.
@carl-mastrangelo can you take a look ?
@normanmaurer I can take a look, but i'm in a crunch time for the next few days.  I'll put it on my todo
@normanmaurer Is it worth opening a separate issue for the on-going problem or perhaps re-opening this one?
@wilkinsona I would open a new one as the error itself is gone (I was also not able to reproduce yet :( ).

Pull request review comments:

Patch that resolved the issue:
diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollEventLoop.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollEventLoop.java
index a2707d96a99..33adf862796 100644
--- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollEventLoop.java
+++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollEventLoop.java
@@ -35,7 +35,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Queue;
-import java.util.concurrent.Callable;
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 
@@ -44,7 +43,7 @@
 /**
  * {@link EventLoop} which uses epoll under the covers. Only works on Linux!
  */
-final class EpollEventLoop extends SingleThreadEventLoop {
+class EpollEventLoop extends SingleThreadEventLoop {
     private static final InternalLogger logger = InternalLoggerFactory.getInstance(EpollEventLoop.class);
     private static final AtomicIntegerFieldUpdater<EpollEventLoop> WAKEN_UP_UPDATER =
             AtomicIntegerFieldUpdater.newUpdater(EpollEventLoop.class, "wakenUp");
@@ -75,6 +74,7 @@ public int get() throws Exception {
             return epollWaitNow();
         }
     };
+    @SuppressWarnings("unused") // AtomicIntegerFieldUpdater
     private volatile int wakenUp;
     private volatile int ioRatio = 50;
 
@@ -248,7 +248,7 @@ private int epollWait(boolean oldWakeup) throws IOException {
             long totalDelay = delayNanos(System.nanoTime());
             prevDeadlineNanos = curDeadlineNanos;
             delaySeconds = (int) min(totalDelay / 1000000000L, Integer.MAX_VALUE);
-            delayNanos = (int) min(totalDelay - delaySeconds * 1000000000L, Integer.MAX_VALUE);
+            delayNanos = (int) min(totalDelay - delaySeconds * 1000000000L, MAX_SCHEDULED_TIMERFD_NS);
         }
         return Native.epollWait(epollFd, events, timerFd, delaySeconds, delayNanos);
     }
@@ -356,7 +356,10 @@ protected void run() {
         }
     }
 
-    private static void handleLoopException(Throwable t) {
+    /**
+     * Visible only for testing!
+     */
+    void handleLoopException(Throwable t) {
         logger.warn("Unexpected exception in the selector loop.", t);
 
         // Prevent possible consecutive immediate failures that lead to


Test patch:
diff --git a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollEventLoopTest.java b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollEventLoopTest.java
index ebf529f7328..4e51114422b 100644
--- a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollEventLoopTest.java
+++ b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollEventLoopTest.java
@@ -15,32 +15,52 @@
  */
 package io.netty.channel.epoll;
 
+import io.netty.channel.DefaultSelectStrategyFactory;
 import io.netty.channel.EventLoop;
 import io.netty.channel.EventLoopGroup;
+import io.netty.util.concurrent.DefaultThreadFactory;
 import io.netty.util.concurrent.Future;
+import io.netty.util.concurrent.RejectedExecutionHandlers;
+import io.netty.util.concurrent.ThreadPerTaskExecutor;
 import org.junit.Test;
 
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
 
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 public class EpollEventLoopTest {
 
     @Test
     public void testScheduleBigDelayNotOverflow() {
-        EventLoopGroup group = new EpollEventLoopGroup(1);
+        final AtomicReference<Throwable> capture = new AtomicReference<Throwable>();
 
-        final EventLoop el = group.next();
-        Future<?> future = el.schedule(new Runnable() {
+        final EventLoopGroup group = new EpollEventLoop(null,
+                new ThreadPerTaskExecutor(new DefaultThreadFactory(getClass())), 0,
+                DefaultSelectStrategyFactory.INSTANCE.newSelectStrategy(), RejectedExecutionHandlers.reject()) {
             @Override
-            public void run() {
-                // NOOP
+            void handleLoopException(Throwable t) {
+                capture.set(t);
+                super.handleLoopException(t);
             }
-        }, Long.MAX_VALUE, TimeUnit.MILLISECONDS);
+        };
 
-        assertFalse(future.awaitUninterruptibly(1000));
-        assertTrue(future.cancel(true));
-        group.shutdownGracefully();
+        try {
+            final EventLoop eventLoop = group.next();
+            Future<?> future = eventLoop.schedule(new Runnable() {
+                @Override
+                public void run() {
+                    // NOOP
+                }
+            }, Long.MAX_VALUE, TimeUnit.MILLISECONDS);
+
+            assertFalse(future.awaitUninterruptibly(1000));
+            assertTrue(future.cancel(true));
+            assertNull(capture.get());
+        } finally {
+            group.shutdownGracefully();
+        }
     }
 }