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:52:49 GMT
Repository: flink
Updated Branches:
  refs/heads/release-1.4 155149855 -> 612f07bbd


[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/612f07bb
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/612f07bb
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/612f07bb

Branch: refs/heads/release-1.4
Commit: 612f07bbd2dc9aa1abf01ebf817c8341c1ad7a10
Parents: 1551498
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:51:12 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/612f07bb/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/612f07bb/flink-dist/pom.xml
----------------------------------------------------------------------
diff --git a/flink-dist/pom.xml b/flink-dist/pom.xml
index 95b244c..124481f 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>
@@ -498,10 +492,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