flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aljos...@apache.org
Subject flink git commit: [FLINK-8186] Exclude flink-avro from flink-dist; fix AvroUtils loading
Date Tue, 05 Dec 2017 15:53:33 GMT
Repository: flink
Updated Branches:
  refs/heads/master dd48a40ab -> f6e24ab60


[FLINK-8186] Exclude flink-avro from flink-dist; fix AvroUtils loading

Before, AvroUtils were loaded when the class was loaded which didn't
take into account the user-code ClassLoader. Now, we try loading avro
utils with the Thread context ClassLoader.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/f6e24ab6
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/f6e24ab6
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/f6e24ab6

Branch: refs/heads/master
Commit: f6e24ab60c3d434186d9cd9906c6562433617ff7
Parents: dd48a40
Author: Aljoscha Krettek <aljoscha.krettek@gmail.com>
Authored: Mon Dec 4 16:14:56 2017 +0100
Committer: Aljoscha Krettek <aljoscha.krettek@gmail.com>
Committed: Tue Dec 5 16:53:02 2017 +0100

----------------------------------------------------------------------
 .../flink/api/java/typeutils/AvroUtils.java       | 18 ++++++------------
 flink-dist/pom.xml                                | 10 ----------
 2 files changed, 6 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/f6e24ab6/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroUtils.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroUtils.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroUtils.java
index 2983be0..0677338 100644
--- a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroUtils.java
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroUtils.java
@@ -37,12 +37,14 @@ public abstract class AvroUtils {
 
 	private static final String AVRO_KRYO_UTILS = "org.apache.flink.formats.avro.utils.AvroKryoSerializerUtils";
 
-	private static final AvroUtils INSTANCE = loadAvroKryoUtils();
-
-	private static AvroUtils loadAvroKryoUtils() {
+	/**
+	 * Returns either the default {@link AvroUtils} which throw an exception in cases where
Avro
+	 * would be needed or loads the specific utils for Avro from flink-avro.
+	 */
+	public static AvroUtils getAvroUtils() {
 		// try and load the special AvroUtils from the flink-avro package
 		try {
-			Class<?> clazz = Class.forName(AVRO_KRYO_UTILS, false, AvroUtils.class.getClassLoader());
+			Class<?> clazz = Class.forName(AVRO_KRYO_UTILS, false, Thread.currentThread().getContextClassLoader());
 			return clazz.asSubclass(AvroUtils.class).getConstructor().newInstance();
 		} catch (ClassNotFoundException e) {
 			// cannot find the utils, return the default implementation
@@ -52,14 +54,6 @@ public abstract class AvroUtils {
 		}
 	}
 
-	/**
-	 * Returns either the default {@link AvroUtils} which throw an exception in cases where
Avro
-	 * would be needed or loads the specific utils for Avro from flink-avro.
-	 */
-	public static AvroUtils getAvroUtils() {
-		return INSTANCE;
-	}
-
 	// ------------------------------------------------------------------------
 
 	/**

http://git-wip-us.apache.org/repos/asf/flink/blob/f6e24ab6/flink-dist/pom.xml
----------------------------------------------------------------------
diff --git a/flink-dist/pom.xml b/flink-dist/pom.xml
index ed8314d..5d63b42 100644
--- a/flink-dist/pom.xml
+++ b/flink-dist/pom.xml
@@ -81,12 +81,6 @@ under the License.
 
 		<dependency>
 			<groupId>org.apache.flink</groupId>
-			<artifactId>flink-avro</artifactId>
-			<version>${project.version}</version>
-		</dependency>
-
-		<dependency>
-			<groupId>org.apache.flink</groupId>
 			<artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
 			<version>${project.version}</version>
 		</dependency>
@@ -493,10 +487,6 @@ under the License.
 							</artifactSet>
 							<relocations>
 								<relocation>
-									<pattern>org.codehaus.jackson</pattern>
-									<shadedPattern>org.apache.flink.formats.avro.shaded.org.codehaus.jackson</shadedPattern>
-								</relocation>
-								<relocation>
 									<!-- relocate jackson services, which isn't done by flink-shaded-jackson -->
 									<pattern>com.fasterxml.jackson</pattern>
 									<shadedPattern>org.apache.flink.shaded.jackson2.com.fasterxml.jackson</shadedPattern>


Mime
View raw message