Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got an exception when trying to get contents #903

Open
lthuangiang opened this issue Aug 21, 2014 · 22 comments
Open

Got an exception when trying to get contents #903

lthuangiang opened this issue Aug 21, 2014 · 22 comments

Comments

@lthuangiang
Copy link
Contributor

Following Contents.get() method, we got an exception

final Repos repos = github().repos();
final Repo repo =  repos.get(new Coordinates.Simple("jcabi/jcabi-github"));
System.out.println(new Content.Smart(repo.contents().get("src/main/java/com/jcabi/github/Users.java")).url());
// #output https://api.github.com/repos/jcabi/jcabi-github/contents/src/main/java/com/jcabi/github/Users.java?ref=master
System.out.println(new Content.Smart(repo.contents().get("src/main/java/com/jcabi/github/mock")).url());

ERROR LOG

https://api.github.com/repos/jcabi/jcabi-github/contents/src/main/java/com/jcabi/github/Users.java?ref=master
[�[0;37mINFO�[m] main com.jcabi.http.request.BaseRequest: #fetch(GET api.github.com /repos/jcabi/jcabi-github/contents/src/main/java/com/jcabi/github/mock): [200 OK] in 2s

javax.json.JsonException: Cannot read JSON object, found JSON array
    at org.glassfish.json.JsonReaderImpl.readObject(JsonReaderImpl.java:105)
    at com.jcabi.http.response.JsonResponse$VerboseReader.readObject(JsonResponse.java:159)
    at com.jcabi.github.RtContents.content(RtContents.java:266)
@dmarkov
Copy link

dmarkov commented Aug 24, 2014

I'll ask someone to take care of this task soon

@dmarkov
Copy link

dmarkov commented Aug 27, 2014

this task will get someone's attention soon

@dmarkov
Copy link

dmarkov commented Aug 31, 2014

@hariso it's yours now, please proceed keeping in mind our principles. Feel free to ask any technical questions right here in the ticket

@dmarkov
Copy link

dmarkov commented Aug 31, 2014

@hariso The cost of this task is 30 mins (this is exactly how much will be paid, not less not more), when the task is done

@dmarkov
Copy link

dmarkov commented Aug 31, 2014

many thanks for the report, I topped your account for 15 mins, transaction 43893062

@dmarkov
Copy link

dmarkov commented Sep 7, 2014

@hariso the task is your hands for the last 10 days.. keep in mind that if it's not closed in the next 48 hours, it will be re-assigned to someone else, see No Obligations principle

@dmarkov
Copy link

dmarkov commented Sep 18, 2014

@hariso this task is taking too long, I have to change the performer, sorry. Please stop working with it right now. See our no obligations principle

@dmarkov dmarkov removed the @hariso label Sep 18, 2014
@dmarkov
Copy link

dmarkov commented Dec 10, 2014

@longtimeago it's in your hands now, please proceed

@longtimeago
Copy link
Contributor

@yegor256 Please, assign someone else. Unfortunately, I've lack of time.

@dmarkov
Copy link

dmarkov commented Dec 22, 2014

@longtimeago you're holding this task for 11 days already

@yegor256
Copy link
Member

@dmarkov give it to someone else pls

@dmarkov
Copy link

dmarkov commented Dec 25, 2014

@dmarkov give it to someone else pls

@yegor256 all right, we'll find someone else for this task

@dmarkov
Copy link

dmarkov commented Dec 26, 2014

@darkled this ticket is yours now, please proceed, and keep in mind this. Any technical questions you should ask right here

Budget here is 30 mins (keep this principle in mind)

@asaen
Copy link

asaen commented Jan 6, 2015

@dmarkov unfortunately, for the moment jcabi-github absolutely doesn't support processing of JsonArray's.

The possible fix of this problem could be this snippet in RtContents (I can push it if it could make sense):

    private Content content(final String path, final String ref)
        throws IOException {
        final String name = "ref";
        final JsonStructure jsonStructure =
            this.request.method(Request.GET).uri().path(path)
                .queryParam(name, ref).back().fetch().as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK).as(JsonResponse.class)
                .json().read();
        String contentPath = null;
        if (ValueType.ARRAY == jsonStructure.getValueType()) {
            contentPath = path;
        } else if (ValueType.OBJECT == jsonStructure.getValueType()) {
            contentPath = ((JsonObject) jsonStructure).getString("path");
        }
        return new RtContent(this.entry.uri().queryParam(name, ref).back(),
            this.owner, contentPath);
    }

But actually it leads for further problems because somewhere inside this method com.jcabi.github.RtContent.json() is invoked which has 170 usages in sources and will throw the same exception javax.json.JsonException: Cannot read JSON object, found JSON array.

So, it looks not possible to fix without the great refactoring of all those classes and I have no idea what to do with it within this issue.

UPD: created a new issue #968 for this problem

@asaen
Copy link

asaen commented Jan 9, 2015

@dmarkov please, assign this task to someone else.

@dmarkov
Copy link

dmarkov commented Jan 12, 2015

@dmarkov please, assign this task to someone else.

@darkled I will assign somebody else to this issue

@dmarkov
Copy link

dmarkov commented Jan 14, 2015

@palyuga This task is yours, please go ahead keeping in mind this. If any questions, don't hesitate to ask right here... Task's budget is 30 mins (see this for explanation)

@palyuga
Copy link

palyuga commented Jan 16, 2015

@dmarkov Waiting for #968 here

@dmarkov
Copy link

dmarkov commented Jan 19, 2015

@dmarkov Waiting for #968 here

@palyuga OK, let's wait for #968

@dmarkov
Copy link

dmarkov commented Oct 16, 2015

@lthuangiang #968 is closed, it was an impediment

@dmarkov
Copy link

dmarkov commented Nov 2, 2015

@palyuga check this "no obligations principle".. This task is on your name for at least 17 days. If you can't close it within the next 48 hours I will have to assign someone else to it. This article should help if you're stuck... -30 added to your rating, current score is: -30

@dmarkov
Copy link

dmarkov commented Nov 5, 2015

@palyuga you've been working with this task for too long. I'm sorry, but I'll assign someone else. Please stop working with it. See our no obligations principle. -60 to your rating, your total score is -90

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

No branches or pull requests

6 participants