gabrie-allaigre / sonar-gitlab-plugin

Add to each commit GitLab in a global commentary on the new anomalies added by this commit and add comment lines of modified files
GNU Lesser General Public License v3.0
713 stars 208 forks source link

Wrong URL concatenation leads in a FileNotFoundException #282

Closed erard22 closed 4 years ago

erard22 commented 4 years ago

From time to time my builds are failing with the following error:

Caused by: java.io.FileNotFoundException: https://host/api/v4/jects/33932/repository/commits/77961905e8cb59255bb6a9e293014119c7ad233d/diff?id=33932&page=2&per_page=20&sha=77961905e8cb59255bb6a9e293014119c7ad233d

looking at the URL there we see that it really a wrong url https://host/api/v4/jects/33932 instead of https://host/api/v4/projects/33932

Currently I don't see where this is comming from.

erard22 commented 4 years ago

Ah... I could debug the issue and found it here:

    public String removeAPIUrl(String url) {
        String withoutHost = url.substring(hostUrl.length());
        return withoutHost.substring(withoutHost.indexOf(API_NAMESPACE) + API_NAMESPACE.length());
    }

Because our server has two dns names and returns not the same in his response as we initially configured it in sonar the calculation of the lenght is wrong.

I think it's related to our setup and can be closed.