Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
[SPARK-13848][SPARK-5185] Update to Py4J 0.9.2 in order to fix classl…
Browse files Browse the repository at this point in the history
…oading issue

This patch upgrades Py4J from 0.9.1 to 0.9.2 in order to include a patch which modifies Py4J to use the current thread's ContextClassLoader when performing reflection / class loading. This is necessary in order to fix [SPARK-5185](https://issues.apache.org/jira/browse/SPARK-5185), a longstanding issue affecting the use of `--jars` and `--packages` in PySpark.

In order to demonstrate that the fix works, I removed the workarounds which were added as part of [SPARK-6027](https://issues.apache.org/jira/browse/SPARK-6027) / #4779 and other patches.

Py4J diff: py4j/py4j@0.9.1...0.9.2

/cc zsxwing tdas davies brkyvz

Author: Josh Rosen <joshrosen@databricks.com>

Closes #11687 from JoshRosen/py4j-0.9.2.
  • Loading branch information
JoshRosen committed Mar 14, 2016
1 parent a8dc23a commit 54040f3
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions streaming-mqtt/python/mqtt.py
Expand Up @@ -38,18 +38,15 @@ def createStream(ssc, brokerUrl, topic,
:param storageLevel: RDD storage level.
:return: A DStream object
"""
jlevel = ssc._sc._getJavaStorageLevel(storageLevel)

try:
helperClass = ssc._jvm.java.lang.Thread.currentThread().getContextClassLoader() \
.loadClass("org.apache.spark.streaming.mqtt.MQTTUtilsPythonHelper")
helper = helperClass.newInstance()
jstream = helper.createStream(ssc._jssc, brokerUrl, topic, jlevel)
except Py4JJavaError as e:
if 'ClassNotFoundException' in str(e.java_exception):
helper = ssc._jvm.org.apache.spark.streaming.mqtt.MQTTUtilsPythonHelper()
except TypeError as e:
if str(e) == "'JavaPackage' object is not callable":
MQTTUtils._printErrorMsg(ssc.sparkContext)
raise

jlevel = ssc._sc._getJavaStorageLevel(storageLevel)
jstream = helper.createStream(ssc._jssc, brokerUrl, topic, jlevel)
return DStream(jstream, ssc, UTF8Deserializer())

@staticmethod
Expand Down

0 comments on commit 54040f3

Please sign in to comment.