Skip to content

Commit

Permalink
Revert "Ensure we only register native methods once (netty#10876)" (n…
Browse files Browse the repository at this point in the history
…etty#10928)

Motivation:

This reverts commit 7fb62a9 as it broke native loading in some cases due maven dependencies.

Modification:

Revert the commit.

Result:

Native loading works again
  • Loading branch information
normanmaurer authored and zxingy committed Jan 29, 2021
1 parent 5ab67e3 commit 1e5ddab
Show file tree
Hide file tree
Showing 25 changed files with 341 additions and 698 deletions.
76 changes: 1 addition & 75 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,6 @@
<dependencies>
<!-- Depend on all our native jars -->
<!-- As this is executed on either macOS or Linux we directly need to specify the classifier -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<classifier>linux-x86_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<classifier>linux-aarch_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<classifier>osx-x86_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
Expand Down Expand Up @@ -118,27 +97,6 @@
<dependencies>
<!-- Depend on all our native jars -->
<!-- As this is executed on either macOS or Linux we directly need to specify the classifier -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<classifier>linux-x86_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<classifier>linux-aarch_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<classifier>osx-x86_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
Expand Down Expand Up @@ -170,7 +128,7 @@
</dependencies>
</profile>

<!-- The linux profile will only include the native jar for epoll to the all jar.
<!-- The linux profile will only include the native jar for epol to the all jar.
If you want to also include the native jar for kqueue use -Puber.
-->
<profile>
Expand All @@ -182,14 +140,6 @@
</activation>
<dependencies>
<!-- All release modules -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
Expand Down Expand Up @@ -225,14 +175,6 @@
</activation>
<dependencies>
<!-- All release modules -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
Expand Down Expand Up @@ -267,14 +209,6 @@
</activation>
<dependencies>
<!-- All release modules -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
Expand Down Expand Up @@ -302,14 +236,6 @@
</activation>
<dependencies>
<!-- All release modules -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
Expand Down
27 changes: 0 additions & 27 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1317,33 +1317,6 @@

<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<!-- enable flattening -->
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<!-- ensure proper cleanup -->
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
<configuration>
<flattenMode>oss</flattenMode>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</plugin>
<!-- keep surefire and failsafe in sync -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
33 changes: 10 additions & 23 deletions resolver-dns-native-macos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,23 +124,11 @@
<artifactId>netty-transport-native-unix-common</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
</dependency>
</dependencies>
</profile>
<profile>
<!--
For non-classifier native builds we should depend on netty-transport-native-unix-common without the
classifier. This profile will be disabled by the other profiles when the native bits will be build.
-->
<id>non-native</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>${project.version}</version>
<!--
The unix-common with classifier dependency is optional because it is not a runtime dependency, but a build time
dependency to get the static library which is built directly into the shared library generated by this project.
-->
<optional>true</optional>
</dependency>
</dependencies>
</profile>
Expand Down Expand Up @@ -168,16 +156,15 @@
<artifactId>netty-resolver-dns</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<!-- We need to use the flatten plugin so the classifier portion of the dependency is resolved-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package io.netty.resolver.dns.macos;

import io.netty.channel.unix.Unix;
import io.netty.resolver.dns.DnsServerAddressStream;
import io.netty.resolver.dns.DnsServerAddressStreamProvider;
import io.netty.resolver.dns.DnsServerAddressStreamProviders;
Expand Down Expand Up @@ -54,7 +53,6 @@ public final class MacOSDnsServerAddressStreamProvider implements DnsServerAddre
static {
Throwable cause = null;
try {
Unix.ensureAvailability();
loadNativeLibrary();
} catch (Throwable error) {
cause = error;
Expand Down
1 change: 0 additions & 1 deletion testsuite-osgi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@
<dependencySet>
<scope>test</scope>
</dependencySet>
<separator>${line.separator}</separator>
</configuration>
</execution>
</executions>
Expand Down
37 changes: 15 additions & 22 deletions transport-native-epoll/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@
<artifactId>netty-transport-native-unix-common</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
<!--
The unix-common with classifier dependency is optional because it is not a runtime dependency, but a build time
dependency to get the static library which is built directly into the shared library generated by this project.
-->
<optional>true</optional>
</dependency>
</dependencies>
</profile>
Expand Down Expand Up @@ -346,23 +351,11 @@
<artifactId>netty-transport-native-unix-common</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
</dependency>
</dependencies>
</profile>
<profile>
<!--
For non-classifier native builds we should depend on netty-transport-native-unix-common without the
classifier. This profile will be disabled by the other profiles when the native bits will be build.
-->
<id>non-native</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>${project.version}</version>
<!--
The unix-common with classifier dependency is optional because it is not a runtime dependency, but a build time
dependency to get the static library which is built directly into the shared library generated by this project.
-->
<optional>true</optional>
</dependency>
</dependencies>
</profile>
Expand All @@ -384,6 +377,11 @@
<artifactId>netty-transport</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-testsuite</artifactId>
Expand All @@ -407,11 +405,6 @@

<build>
<plugins>
<!-- We need to use the flatten plugin so the classifier portion of the dependency is resolved-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
<!-- Also include c files in source jar -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package io.netty.channel.epoll;

import io.netty.channel.unix.FileDescriptor;
import io.netty.channel.unix.Unix;
import io.netty.util.internal.SystemPropertyUtil;

/**
Expand All @@ -37,7 +36,6 @@ public final class Epoll {
FileDescriptor epollFd = null;
FileDescriptor eventFd = null;
try {
Unix.ensureAvailability();
epollFd = Native.newEpollCreate();
eventFd = Native.newEventFd();
} catch (Throwable t) {
Expand Down

0 comments on commit 1e5ddab

Please sign in to comment.