Skip to content

Conversation

@olavloite
Copy link

@olavloite olavloite commented Jul 19, 2019

There's no automatic test for this, but I did the following manual testing:

  1. Before the change: Include the shaded nio library as a dependency along with the google-cloud-spanner library. It is then possible to use the nio library, but any call to Spanner fails with a NoSuchMethodError.
  2. After the change: Include the shaded nio library as a dependency along with the google-cloud-spanner library. It is now possible to use both nio as Spanner without any conflicts.

Fixes #5127

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 19, 2019
@codecov
Copy link

codecov bot commented Jul 19, 2019

Codecov Report

Merging #5789 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #5789      +/-   ##
============================================
+ Coverage     47.17%   47.17%   +<.01%     
+ Complexity    25130    25115      -15     
============================================
  Files          2389     2389              
  Lines        259836   259836              
  Branches      29417    29422       +5     
============================================
+ Hits         122585   122586       +1     
+ Misses       128321   128320       -1     
  Partials       8930     8930
Impacted Files Coverage Δ Complexity Δ
...ain/java/com/google/cloud/pubsub/v1/Publisher.java 89.89% <0%> (+0.34%) 40% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4a95f17...b959f53. Read the comment docs.

@chingor13
Copy link
Contributor

cc @jean-philippe-martin

@jean-philippe-martin
Copy link

I need to look at this in more detail, but to recap just to make sure I got it right:

  • The original bug is that NIO code passes an com.google.cloud.http.HttpTransportOptions around (in ways unspecified), and this object has public getter that returns a shaded shaded.cloud_nio.com.google.auth.http.HttpTransportFactory. Other code that looks at the HttpTransportOptions don't expect that type and crash
  • The original bug description suggests that shading more may be a solution
  • This fix does shade more (by narrowing the exception list), so the HttpTransportOptions would be shaded too.

This fix also points out a new failure mode, where including both Spanner and NIO causes Spanner to break.

@olavloite
Copy link
Author

@jean-philippe-martin
This problem is triggered when you use the shaded version of google-cloud-storage-nio in combination with other Google Cloud libraries. The original bug originates from a user that uses google-cloud-storage-nio in combination with Big Query (see the included stack trace). I tested it with Spanner, but it will probably break with most (all?) Google Cloud libraries, as the shaded nio library does not shade its core com.google.cloud.* dependencies, but does include them in the shaded .jar. So the result is that you end up with the core Google Cloud libraries twice on the classpath.

@jean-philippe-martin
Copy link

This looks good to me. With this change in, I was able to load BigQuery and Spanner along with the NIO library and initialize them successfully.

👍

@olavloite
Copy link
Author

@JesseLovelace Friendly ping. Do you have time to have a look at this?

@JesseLovelace JesseLovelace merged commit c3173ea into googleapis:master Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incomplete shading in google-cloud-nio leads to downstream breakage

5 participants