[
https://issues.apache.org/jira/browse/AVRO-2192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16709677#comment-16709677
]
ASF GitHub Bot commented on AVRO-2192:
--------------------------------------
Fokko closed pull request #400: AVRO-2192: Remove paranamer dependency from Avro
URL: https://github.com/apache/avro/pull/400
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/lang/java/avro/pom.xml b/lang/java/avro/pom.xml
index 0eb36857a..d04c05513 100644
--- a/lang/java/avro/pom.xml
+++ b/lang/java/avro/pom.xml
@@ -38,7 +38,6 @@
<osgi.import>
!org.apache.avro*,
com.fasterxml.jackson*,
- com.thoughtworks.paranamer;resolution:=optional,
org.xerial.snappy;resolution:=optional,
sun.misc;resolution:=optional,
*
@@ -56,24 +55,6 @@
</resource>
</resources>
<plugins>
- <plugin>
- <groupId>com.thoughtworks.paranamer</groupId>
- <artifactId>paranamer-maven-plugin</artifactId>
- <version>${paranamer.version}</version>
- <executions>
- <execution>
- <id>paranamer-test</id>
- <configuration>
-
<sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
-
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
- </configuration>
- <phase>process-test-classes</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
@@ -146,11 +127,6 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
- <dependency>
- <groupId>com.thoughtworks.paranamer</groupId>
- <artifactId>paranamer</artifactId>
- <optional>true</optional>
- </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
diff --git
a/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
b/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
index 3e9e0796f..6e9b7792e 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
@@ -24,6 +24,7 @@
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Parameter;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.nio.ByteBuffer;
@@ -38,7 +39,6 @@
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Function;
import org.apache.avro.AvroRemoteException;
import org.apache.avro.AvroRuntimeException;
@@ -763,11 +763,11 @@ protected Schema createFieldSchema(Field field,
Map<String, Schema> names) {
return schema;
}
- /** Return the protocol for a Java interface.
- * <p>Note that this requires that <a
- * href="http://paranamer.codehaus.org/">Paranamer</a> is run over compiled
- * interface declarations, since Java 6 reflection does not provide access to
- * method parameter names. See Avro's build.xml for an example. */
+ /**
+ * Return the protocol for a Java interface.
+ * <p>The correct name of the method parameters needs the
<code>-parameters</code>
+ * java compiler argument. More info at https://openjdk.java.net/jeps/118
+ */
@Override
public Protocol getProtocol(Class iface) {
Protocol protocol =
@@ -792,32 +792,15 @@ public Protocol getProtocol(Class iface) {
return protocol;
}
- private Function<Method, String[]> paranamer;
- private synchronized Function<Method, String[]> getParanamer() {
- if (paranamer == null) {
- try {
- final com.thoughtworks.paranamer.CachingParanamer p = new
com.thoughtworks.paranamer.CachingParanamer();
- paranamer = new Function<Method, String[]>() {
- public String[] apply(Method t) {
- return p.lookupParameterNames(t);
- }
- };
- } catch (Throwable t) {
- paranamer = new Function<Method, String[]>() {
- public String[] apply(Method t) {
- return new String[0];
- }
- };
- }
- }
- return paranamer;
- }
-
private String[] getParameterNames(Method m) {
- return getParanamer().apply(m);
+ Parameter[] parameters = m.getParameters();
+ String[] paramNames = new String[parameters.length];
+ for (int i = 0; i < parameters.length; i++) {
+ paramNames[i] = parameters[i].getName();
+ }
+ return paramNames;
}
-
private Message getMessage(Method method, Protocol protocol,
Map<String,Schema> names) {
List<Schema.Field> fields = new ArrayList<>();
diff --git a/lang/java/pom.xml b/lang/java/pom.xml
index 773d71c5e..9d64b6efb 100644
--- a/lang/java/pom.xml
+++ b/lang/java/pom.xml
@@ -44,7 +44,6 @@
<jopt-simple.version>5.0.4</jopt-simple.version>
<junit.version>4.12</junit.version>
<netty.version>3.10.6.Final</netty.version>
- <paranamer.version>2.8</paranamer.version>
<protobuf.version>2.6.1</protobuf.version>
<thrift.version>0.9.3</thrift.version>
<slf4j.version>1.7.25</slf4j.version>
@@ -110,6 +109,9 @@
<configuration>
<source>1.8</source>
<target>1.8</target>
+ <compilerArgs>
+ <arg>-parameters</arg>
+ </compilerArgs>
</configuration>
</plugin>
<plugin>
@@ -351,19 +353,6 @@
<ignore />
</action>
</pluginExecution>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>com.thoughtworks.paranamer</groupId>
- <artifactId>paranamer-maven-plugin</artifactId>
- <versionRange>[${paranamer.version},)</versionRange>
- <goals>
- <goal>generate</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore />
- </action>
- </pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.avro</groupId>
@@ -454,11 +443,6 @@
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
- <dependency>
- <groupId>com.thoughtworks.paranamer</groupId>
- <artifactId>paranamer</artifactId>
- <version>${paranamer.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
diff --git a/lang/java/tools/src/main/resources/META-INF/LICENSE
b/lang/java/tools/src/main/resources/META-INF/LICENSE
index 550260d22..eba2996cc 100644
--- a/lang/java/tools/src/main/resources/META-INF/LICENSE
+++ b/lang/java/tools/src/main/resources/META-INF/LICENSE
@@ -270,36 +270,6 @@ SLF4J license text (MIT):
| OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
| WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------
-License for paranamer, included in this binary artifact:
-
-Copyright (c) 2006 Paul Hammant & ThoughtWorks Inc
-All rights reserved.
-
-| Redistribution and use in source and binary forms, with or without
-| modification, are permitted provided that the following conditions
-| are met:
-| 1. Redistributions of source code must retain the above copyright
-| notice, this list of conditions and the following disclaimer.
-| 2. Redistributions in binary form must reproduce the above copyright
-| notice, this list of conditions and the following disclaimer in the
-| documentation and/or other materials provided with the distribution.
-| 3. Neither the name of the copyright holders nor the names of its
-| contributors may be used to endorse or promote products derived from
-| this software without specific prior written permission.
-|
-| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-| ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-| THE POSSIBILITY OF SUCH DAMAGE.
-
----------------------------------------------------------------------
License for snappy-java, included in this binary artifact:
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Remove paranamer dependency from Avro
> -------------------------------------
>
> Key: AVRO-2192
> URL: https://issues.apache.org/jira/browse/AVRO-2192
> Project: Apache Avro
> Issue Type: Improvement
> Components: java
> Affects Versions: 1.8.2
> Reporter: RAJKUMAR NATARAJAN
> Assignee: Ismaël Mejía
> Priority: Minor
> Fix For: 1.9.0
>
>
> Hi,
>
> Avro seems to be depend upon the com.thoughtworks.paranamer. Avro 1.7.7
> depends upon 2.7 and 1.8. depends on 2.8 paranamer versions.
>
> Please remove this dependency in the future versions.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)