mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-10 08:21:21 +00:00
Issue #261: handle 204 no content correctly
This commit is contained in:
@@ -512,6 +512,10 @@ class Requester {
|
||||
if (responseCode == 304) {
|
||||
return null; // special case handling for 304 unmodified, as the content will be ""
|
||||
}
|
||||
if (responseCode == 204 && type.isArray()) {
|
||||
// no content
|
||||
return type.cast(Array.newInstance(type.getComponentType(),0));
|
||||
}
|
||||
|
||||
r = new InputStreamReader(wrapStream(uc.getInputStream()), "UTF-8");
|
||||
String data = IOUtils.toString(r);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import org.kohsuke.github.GHRepository;
|
||||
import org.kohsuke.github.GHRepository.Contributor;
|
||||
import org.kohsuke.github.GHUser;
|
||||
import org.kohsuke.github.GitHub;
|
||||
|
||||
@@ -9,11 +10,10 @@ import java.util.Collection;
|
||||
*/
|
||||
public class Foo {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Collection<GHRepository> lst = GitHub.connect().getUser("kohsuke").getRepositories().values();
|
||||
for (GHRepository r : lst) {
|
||||
System.out.println(r.getName());
|
||||
GitHub gh = GitHub.connect();
|
||||
for (Contributor c : gh.getRepository("kohsuke/yo").listContributors()) {
|
||||
System.out.println(c);
|
||||
}
|
||||
System.out.println(lst.size());
|
||||
}
|
||||
|
||||
private static void testRateLimit() throws Exception {
|
||||
|
||||
@@ -50,4 +50,12 @@ public class RepositoryTest extends AbstractGitHubApiTestBase {
|
||||
String mainLanguage = r.getLanguage();
|
||||
assertTrue(r.listLanguages().containsKey(mainLanguage));
|
||||
}
|
||||
|
||||
@Test // Issue #261
|
||||
public void listEmptyContributors() throws IOException {
|
||||
GitHub gh = GitHub.connect();
|
||||
for (Contributor c : gh.getRepository("github-api-test-org/empty").listContributors()) {
|
||||
System.out.println(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user