Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing dependency on apache-commons lang 3, adding necessary classes as needed #444

Merged
merged 1 commit into from
Sep 6, 2018

Conversation

n3nash
Copy link
Contributor

@n3nash n3nash commented Sep 4, 2018

Added 4 new types of classes to help remove this dependency :

  1. Pair and ImmutablePair
  2. Triple and ImmutableTriple
  3. SerializationUtils
  4. StringUtils

In the past, we have faced many issues such as ClassNotFoundException or NoSuchMethod exception due to conflicting classes from lang3 versions, also the SerializationUtils from lang3 is buggy; it has some issues with instantiating the correct class loaders. Hence, we are removing lang3 dependency to alleviate such issues in the future.

@n3nash
Copy link
Contributor Author

n3nash commented Sep 4, 2018

@vinothchandar @bvaradar Please take a pass at this

* (NOTE: Adapted from Apache commons-lang3)
* This class defines API's to serde an object.
*/
public class SerializationUtils {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should nt be in collections.. just common.util.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, done

/**
* Simple utility for operations on strings
*/
public class StringUtils {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.. should nt be in collection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, done

@@ -103,7 +103,7 @@ public HoodieRecord getData(byte[] bytes) {
hoodieRecord.setNewLocation(newLocation);
return hoodieRecord;
} catch (IOException io) {
throw new HoodieNotSerializableException("Cannot de-serialize value from bytes", io);
throw new HoodieSerializableException("Cannot de-serialize value from bytes", io);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename: HoodieSerializationException ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* limitations under the License.
*/

package com.uber.hoodie.common.util.collection.tuple;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just keep package as common.util.collection. having pair under tuple package seems kind of odd to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just borrowed it from lang3, we can keep it under collection, done

* limitations under the License.
*/

package com.uber.hoodie.common.util.collection.tuple;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.. just common.util.collection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just borrowed it from lang3, we can keep it under collection, done

* limitations under the License.
*/

package com.uber.hoodie.common.util.collection.tuple;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.. just common.util.collection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just borrowed it from lang3, we can keep it under collection, done

* limitations under the License.
*/

package com.uber.hoodie.common.util.collection.tuple;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.. just common.util.collection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just borrowed it from lang3, we can keep it under collection, done

@n3nash n3nash force-pushed the fix_apache_commons_usage branch from 687bff5 to 7a56d29 Compare September 5, 2018 18:49
@n3nash
Copy link
Contributor Author

n3nash commented Sep 5, 2018

@vinothchandar updated the diff

@@ -110,10 +110,6 @@
<artifactId>hadoop-common</artifactId>
<classifier>tests</classifier>
</dependency>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this dependency can sometimes still result in NoSuchMethod or other runtime errors elsewhere because of different versions of commons-lang3 getting pulled due to multiple "transitive" dependencies.

To avoid potential landmines, Can you check using mvn dependency:tree with this code-change to see if different versions of commons-lang3 is appearing in multiple different paths. You would need to use both mvn dependency:tree and parent dependency's pom files to figure out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, here is the breakdown of where this library is brought in :

hoodie-cli

[INFO] +- org.springframework.shell:spring-shell:jar:1.2.0.RELEASE:compile
[INFO] | +- com.google.guava:guava:jar:15.0:compile
[INFO] | +- jline:jline:jar:2.12:compile
[INFO] | +- org.springframework:spring-context-support:jar:4.2.4.RELEASE:compile
[INFO] | | +- org.springframework:spring-beans:jar:4.2.4.RELEASE:compile
[INFO] | | - org.springframework:spring-context:jar:4.2.4.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:4.2.4.RELEASE:compile
[INFO] | | | - aopalliance:aopalliance:jar:1.0:compile
[INFO] | | - org.springframework:spring-expression:jar:4.2.4.RELEASE:compile
[INFO] | +- commons-io:commons-io:jar:2.4:compile
[INFO] | - org.springframework:spring-core:jar:4.2.4.RELEASE:compile
[INFO] | - commons-logging:commons-logging:jar:1.2:compile
[INFO] +- de.vandermeer:asciitable:jar:0.2.5:compile
[INFO] | +- de.vandermeer:asciilist:jar:0.0.3:compile
[INFO] | - org.apache.commons:commons-lang3:jar:3.4:compile

hoodie-client

[INFO] +- org.apache.spark:spark-core_2.11:jar:2.1.0:provided
[INFO] | +- org.apache.avro:avro-mapred:jar:hadoop2:1.7.7:provided
[INFO] | +- com.twitter:chill_2.11:jar:0.8.0:provided
[INFO] | | - com.esotericsoftware:kryo-shaded:jar:3.0.3:provided
[INFO] | | +- com.esotericsoftware:minlog:jar:1.3.0:provided
[INFO] | | - org.objenesis:objenesis:jar:2.1:provided
[INFO] | +- com.twitter:chill-java:jar:0.8.0:provided
[INFO] | +- org.apache.xbean:xbean-asm5-shaded:jar:4.4:provided
[INFO] | +- org.apache.spark:spark-launcher_2.11:jar:2.1.0:provided
[INFO] | +- org.apache.spark:spark-network-common_2.11:jar:2.1.0:provided
[INFO] | +- org.apache.spark:spark-network-shuffle_2.11:jar:2.1.0:provided
[INFO] | +- org.apache.spark:spark-unsafe_2.11:jar:2.1.0:provided
[INFO] | +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] | +- org.apache.commons:commons-lang3:jar:3.5:provided

hoodie-spark

[INFO] +- org.apache.spark:spark-core_2.11:jar:2.1.0:provided
[INFO] | +- org.apache.avro:avro-mapred:jar:hadoop2:1.7.7:provided
[INFO] | | +- org.apache.avro:avro-ipc:jar:1.7.7:compile
[INFO] | | - org.apache.avro:avro-ipc:jar:tests:1.7.7:compile
[INFO] | +- com.twitter:chill_2.11:jar:0.8.0:provided
[INFO] | | - com.esotericsoftware:kryo-shaded:jar:3.0.3:provided
[INFO] | | +- com.esotericsoftware:minlog:jar:1.3.0:provided
[INFO] | | - org.objenesis:objenesis:jar:2.1:provided
[INFO] | +- com.twitter:chill-java:jar:0.8.0:provided
[INFO] | +- org.apache.xbean:xbean-asm5-shaded:jar:4.4:provided
[INFO] | +- org.apache.spark:spark-launcher_2.11:jar:2.1.0:provided
[INFO] | +- org.apache.spark:spark-network-common_2.11:jar:2.1.0:provided
[INFO] | | - org.fusesource.leveldbjni:leveldbjni-all:jar:1.8:compile
[INFO] | +- org.apache.spark:spark-network-shuffle_2.11:jar:2.1.0:provided
[INFO] | +- org.apache.spark:spark-unsafe_2.11:jar:2.1.0:provided
[INFO] | +- net.java.dev.jets3t:jets3t:jar:0.7.1:compile
[INFO] | +- org.apache.curator:curator-recipes:jar:2.4.0:compile
[INFO] | | - org.apache.curator:curator-framework:jar:2.4.0:compile
[INFO] | +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] | +- org.apache.commons:commons-lang3:jar:3.5:compile

hoodie-utilities

[INFO] +- org.apache.spark:spark-core_2.11:jar:2.1.0:provided
[INFO] | +- org.apache.avro:avro-mapred:jar:hadoop2:1.7.7:provided
[INFO] | +- com.twitter:chill_2.11:jar:0.8.0:provided
[INFO] | | - com.esotericsoftware:kryo-shaded:jar:3.0.3:provided
[INFO] | | +- com.esotericsoftware:minlog:jar:1.3.0:provided
[INFO] | | - org.objenesis:objenesis:jar:2.1:provided
[INFO] | +- com.twitter:chill-java:jar:0.8.0:provided
[INFO] | +- org.apache.xbean:xbean-asm5-shaded:jar:4.4:provided
[INFO] | +- org.apache.spark:spark-launcher_2.11:jar:2.1.0:provided
[INFO] | +- org.apache.spark:spark-network-common_2.11:jar:2.1.0:provided
[INFO] | +- org.apache.spark:spark-network-shuffle_2.11:jar:2.1.0:provided
[INFO] | +- org.apache.spark:spark-unsafe_2.11:jar:2.1.0:provided
[INFO] | +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] | +- org.apache.commons:commons-lang3:jar:3.5:compile

Seems like spark-core brings it, but it's provided.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think lang3 dependency in hoodie-cli is coming from hoodie-utilities which will be shaded (with Vinoth's deltastreamer changes). Rest of the dependencies are only through spark-core which is provided as you mentioned. So, we should be good here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deltastreamer changes are nt checked in.. I plan to redo the patch based on these classes anyway.

@vinothchandar vinothchandar merged commit 324de29 into apache:master Sep 6, 2018
vinishjail97 pushed a commit to vinishjail97/hudi that referenced this pull request Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants