-
Notifications
You must be signed in to change notification settings - Fork 234
helios-testing shaded artifact is broken #1142
Comments
Confirmed that this is fixed in #1141 (if merged):
|
We can return the built in Collection types, but AutoValue docs recommend returning the |
I think they mean that as a general principle and not something directly related to using auto-value. I started on a branch to reduce our usage of Guava in the public API of docker-client, but it might break a lot of methods on classes in the 'messages' package that use the immutable Builders or offer varargs setters. |
Can I close this issue since the original problem is now fixed?
Are you sure? The example they give here has @AutoValue
public abstract class ListExample {
public static ListExample create(String[] mutableNames) {
return new AutoValue_ListExample(ImmutableList.copyOf(mutableNames));
}
public abstract ImmutableList<String> names();
} |
@davidxia my point was more that it is a recommendation and not a requirement when using auto-value, and we don't have to follow it if it leads to a problematic design like in this case. I'm not sure if this is still a problem or not, I haven't tried building a new project that uses helios-testing:shaded since #1141 was done - there might be other problems. |
To elaborate a little bit: Returning Guava types ( Trying to alleviate this by shading and relocating the Guava classes in helios-testing or docker-client would seem like an obvious solution, but if the public API is returning Guava types, then these uses get relocated too. This means that someone using the normal helios-testing passes in a For a value class like Should note that if you decide to not expose fields as Immutable/Guava types, you can still use them internally in the auto-value static factory - accept a Also for a class like |
Makes sense. Should we change the return types to regular collections? Did
you have a branch somewhere?
|
No, I hadn't started on that. That type of change might be considered breaking, since code like the following would fail to compile: ImmutableList<?> ports = networkSettings.ports() // if ports() now returns java.util.List |
Yea we can bump the major version. Seems like solving the relocation
problem might be worth it to some users.
I would’ve never followed the autovalue examples of returning immutable
types if I knew it was going to be such a headache later on.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
#1137 added a "shaded" artifact for helios-testing to attempt to relocate Guava classes to a new package, so that users of helios-testing are not impacted whenever helios updates the Guava version it uses (which tends to cause a chain of headaches because of version incompatibilities).
The shaded helios-testing jar appears to be broken and unusable, at least for users of HeliosSoloDeployment: a NoSuchMethodError is thrown in a simple test case like
This looks to be due to the fact that the maven-shade-plugin is rewriting the bytecode for the
getHostPort
method incom.spotify.helios.testing.HeliosSoloDeployment
to look like the following (this is from the 0.9.146 JAR):This last 3 lines are the problem - it is trying to invoke a method named
com/spotify/docker/client/messages/NetworkSettings.ports
with no arguments (()
) which is expected to returncom/spotify/helios/testing/shaded/com/google/common/collect/ImmutableMap
.It seems as if the plugin does not realize that in code like this
the
invokevirtual
operations that invoke thecom.google.common.collect.ImmutableMap NetworkSettings.ports()
method should not be rewritten to returncom.spotify.helios.testing.shaded.com.google.common.collect.ImmutableMap
since this class is supplied from another library and will never actually return this rewritten type.In looking at this, I noticed that we are using version 2.4.3 of maven-shade-plugin and that 3.0.0 exists, I'm not sure yet if upgrading there would fix this.
On the other hand, upgrading docker-client so that the
NetworkSettings.ports()
method does not return a type from thecom.google.common.collect
package (#1138 or #1141) should also fix this.But in general simply relocating Guava classes is not as simple as thought and might have to be scrapped as unworkable.
The text was updated successfully, but these errors were encountered: