Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Incorrect META-INF/services records in ffwd-http-client #75

Open
mishako opened this issue Jul 31, 2018 · 3 comments
Open

Incorrect META-INF/services records in ffwd-http-client #75

mishako opened this issue Jul 31, 2018 · 3 comments

Comments

@mishako
Copy link

mishako commented Jul 31, 2018

Jar-file of ffwd-http-client contains incorrect records in META-INF/services.

$ jar -xf ffwd-http-client-0.4.1.jar
$ cat META-INF/services/com.fasterxml.jackson.databind.Module
com.spotify.ffwd.http.fasterxml.jackson.datatype.jdk8.Jdk8Module

Note the mismatch between com.fasterxml in the name of the file and com.spotify.ffwd.http.fasterxml inside it.

This breaks java service discovery. For example, having ffwd-http-client on classpath and doing new ObjectMapper().findAndRegisterModules() results in this error:

java.util.ServiceConfigurationError: com.fasterxml.jackson.databind.Module:
Provider com.spotify.ffwd.http.fasterxml.jackson.datatype.jdk8.Jdk8Module not a subtype
@dmichel1
Copy link
Contributor

dmichel1 commented Aug 7, 2018

@mishako thanks for reporting.

Can you provide me a code snippet on how I can reproduce this error you are seeing?

I believe this is error is happening because of the way the client is shading dependencies.

@mishako
Copy link
Author

mishako commented Aug 9, 2018

@dmichel1
Here is a way to reproduce the error:

curl -s http://repo1.maven.org/maven2/com/spotify/ffwd/ffwd-http-client/0.4.1/ffwd-http-client-0.4.1.jar > ffwd-http-client-0.4.1.jar
curl -s http://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.9.6/jackson-databind-2.9.6-javadoc.jar > jackson-databind-2.9.6-javadoc.jar
curl -s http://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.9.6/jackson-databind-2.9.6.jar > jackson-databind-2.9.6.jar
curl -s http://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.9.6/jackson-core-2.9.6.jar > jackson-core-2.9.6.jar
curl -s http://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.9.6/jackson-annotations-2.9.6.jar > jackson-annotations-2.9.6.jar
echo 'import com.fasterxml.jackson.databind.ObjectMapper; class Main { public static void main(String[] args) { new ObjectMapper().findAndRegisterModules();  } }' > Main.java
javac -cp ffwd-http-client-0.4.1.jar:jackson-databind-2.9.6.jar:jackson-core-2.9.6.jar:jackson-annotations-2.9.6.jar Main.java
java -cp ffwd-http-client-0.4.1.jar:jackson-databind-2.9.6.jar:jackson-core-2.9.6.jar:jackson-annotations-2.9.6.jar:. Main

Output:

Exception in thread "main" java.util.ServiceConfigurationError: com.fasterxml.jackson.databind.Module: Provider com.spotify.ffwd.http.fasterxml.jackson.datatype.jdk8.Jdk8Module not a subtype
        at java.util.ServiceLoader.fail(ServiceLoader.java:239)
        at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
        at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
        at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
        at java.util.ServiceLoader$1.next(ServiceLoader.java:480)                                                                                                                           
        at com.fasterxml.jackson.databind.ObjectMapper.findModules(ObjectMapper.java:994)                                                                                                   
        at com.fasterxml.jackson.databind.ObjectMapper.findModules(ObjectMapper.java:978)                                                                                                   
        at com.fasterxml.jackson.databind.ObjectMapper.findAndRegisterModules(ObjectMapper.java:1028)                                                                                       
        at Main.main(Main.java:1)

@dmichel1
Copy link
Contributor

dmichel1 commented Aug 9, 2018

@mishako thank you!

I'm thinking the best path forward is to move the ffwd-http-client into it's own repo since it doesn't have any dependencies on the rest of ffwd and remove the shading the client is doing and instead let the user resolve the dependencies.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants