ffwd icon indicating copy to clipboard operation
ffwd copied to clipboard

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

Open mishako opened this issue 6 years ago • 3 comments

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

mishako avatar Jul 31 '18 07:07 mishako

@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.

dmichel1 avatar Aug 07 '18 14:08 dmichel1

@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)

mishako avatar Aug 09 '18 10:08 mishako

@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.

dmichel1 avatar Aug 09 '18 19:08 dmichel1