Last active
July 30, 2018 18:04
-
-
Save fiunchinho/c250427a2bb0186786c9 to your computer and use it in GitHub Desktop.
Feign Observable serialization doesn't work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
sourceCompatibility = 1.8 | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'com.netflix.feign:feign-core:8.14.4' | |
compile 'com.netflix.feign:feign-jackson:8.14.4' | |
compile 'com.netflix.feign:feign-hystrix:8.14.4' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.armesto.feign; | |
import feign.Feign; | |
import feign.Param; | |
import feign.RequestLine; | |
import feign.jackson.JacksonDecoder; | |
import feign.jackson.JacksonEncoder; | |
import rx.Observable; | |
import java.util.List; | |
public class ListExample { | |
public static void main(String[] args) { | |
GitHub github = Feign.builder() | |
.encoder(new JacksonEncoder()) | |
.decoder(new JacksonDecoder()) | |
.target(GitHub.class, "https://api.github.com"); | |
github.contributors("netflix", "feign") | |
.forEach( | |
contributor -> System.out.println(contributor.login + " (" + contributor.contributions + ")") | |
); | |
} | |
} | |
class Contributor { | |
String login; | |
int contributions; | |
public void setLogin(String login) { | |
this.login = login; | |
} | |
public void setContributions(int contributions) { | |
this.contributions = contributions; | |
} | |
} | |
interface GitHub { | |
@RequestLine("GET /repos/{owner}/{repo}/contributors") | |
List<Contributor> contributors(@Param("owner") String owner, @Param("repo") String repo); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.armesto.feign; | |
import feign.Feign; | |
import feign.Param; | |
import feign.RequestLine; | |
import feign.jackson.JacksonDecoder; | |
import feign.jackson.JacksonEncoder; | |
import rx.Observable; | |
public class ObservableExample { | |
public static void main(String[] args) { | |
GitHub github = HystrixFeign.builder() | |
.encoder(new JacksonEncoder()) | |
.decoder(new JacksonDecoder()) | |
.target(GitHub.class, "https://api.github.com"); | |
github.contributors("netflix", "feign") | |
.subscribe( | |
contributor -> System.out.println(contributor.login + " (" + contributor.contributions + ")") | |
); | |
} | |
} | |
class Contributor { | |
String login; | |
int contributions; | |
public void setLogin(String login) { | |
this.login = login; | |
} | |
public void setContributions(int contributions) { | |
this.contributions = contributions; | |
} | |
} | |
interface GitHub { | |
@RequestLine("GET /repos/{owner}/{repo}/contributors") | |
Observable<Contributor> contributors(@Param("owner") String owner, @Param("repo") String repo); | |
} |
Any solution to this?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ListExample works flawlessly.
ObservableExample fails with