taskadapter / redmine-java-api

Redmine Java API
Apache License 2.0
270 stars 163 forks source link

Redmine Manager class with NULL URI param creates an unusable URI #324

Open peterhorvath2014 opened 5 years ago

peterhorvath2014 commented 5 years ago

Hi,

From redmine-java-api:3.0.0 if I use this code:

final RedmineManager manager = RedmineManagerFactory.createWithApiKey(uri, apiAccessKey);
new Issue(manager.getTransport(), projectId).setSubject(subject).create();

It generates to the url: https://redmine/**null**/issues.json?.....

There is a null in the url, so it gives 404. As per the redmine Rest API, there should be nothing there in this case.

Am I missing a configuration, or maybe my spring boot config creates a bean which is used in this package?

2.6.0 version is okay, but that is not compatible with our redmine server.

Thanks for the help, Peter

ElielBarone commented 5 years ago

builder.setPath(builder.getPath() + "/" + query);

//builder.getPath() returns null. To get away from this, you can use the url like that: http://redmine.local/**redmine**

URIConfigurator [86]

alexeyOnGitHub commented 4 years ago

can you please describe your use-case where you need URI to be null?

stklcode commented 4 years ago

Also just came across this issue.

Using URI without trailing slash, i.e. without a path results in null path. Initialization with RedmineManagerFactory.createWithApiKey("https://redmine.example.com", "secret"); results in https://redmine.example.com/null/issues/... being queried which just gives a 404 or similar error. Completely obvious, the given URI does not contain any path.

Fix is to append the root path, i.e. trailing slash: "https://redmine.example.com/"

Used to work fine with 2.x, failed after upgrading a project to latest stable 3.1.2.

For convenience the factory should fall back to an empty string instead of stringifying null, which is probably never correct and if it was, one could simply write it down explicitly ("https://redmine.example.com/null/")

Edit: Apparently this has already been fixed in #321

alexeyOnGitHub commented 4 years ago

@peterhorvath2014 please try the latest released version, which is currently https://search.maven.org/artifact/com.taskadapter/redmine-java-api/4.0.0.preview.3/jar