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

Issue with pull-requests formatting #98

Closed
mkj28 opened this Issue Feb 10, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@mkj28

mkj28 commented Feb 10, 2017

Seeing this on stash side:
ERROR "GET /rest/api/1.0/projects/proj/repos/repo/pull-requests/10,997/diff HTTP/1.1" c.a.s.i.r.e.DefaultUnhandledExceptionMapperHelper Unhandled exception while processing REST request: "GET /rest/api/1.0/projects/proj/repos/repo/pull-requests/10,997/diff HTTP/1.1"
java.lang.NumberFormatException: For input string: "10,997"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_60]
at java.lang.Long.parseLong(Long.java:589) ~[na:1.8.0_60]
at java.lang.Long.parseLong(Long.java:631) ~[na:1.8.0_60]

@mkj28

This comment has been minimized.

Show comment
Hide comment
@mkj28

mkj28 Feb 10, 2017

Something like this:

diff --git a/src/main/java/org/sonar/plugins/stash/client/StashClient.java b/src/main/java/org/sonar/plugins/stash/client/StashClient.java
index e54292c..85e1c46 100755
--- a/src/main/java/org/sonar/plugins/stash/client/StashClient.java
+++ b/src/main/java/org/sonar/plugins/stash/client/StashClient.java
@@ -51,7 +54,7 @@ public class StashClient implements AutoCloseable {
   private static final String TASKS_API = REST_API + "tasks";
 
   private static final String API_ALL_PR = REPO_API + "pull-requests/";
-  private static final String API_ONE_PR = API_ALL_PR + "{3}";
+  private static final String API_ONE_PR = API_ALL_PR + "{3,number,#}";
 
   private static final String API_ONE_PR_ALL_COMMENTS = API_ONE_PR + "/comments";
   private static final String API_ONE_PR_DIFF = API_ONE_PR + "/diff?withComments=true";

mkj28 commented Feb 10, 2017

Something like this:

diff --git a/src/main/java/org/sonar/plugins/stash/client/StashClient.java b/src/main/java/org/sonar/plugins/stash/client/StashClient.java
index e54292c..85e1c46 100755
--- a/src/main/java/org/sonar/plugins/stash/client/StashClient.java
+++ b/src/main/java/org/sonar/plugins/stash/client/StashClient.java
@@ -51,7 +54,7 @@ public class StashClient implements AutoCloseable {
   private static final String TASKS_API = REST_API + "tasks";
 
   private static final String API_ALL_PR = REPO_API + "pull-requests/";
-  private static final String API_ONE_PR = API_ALL_PR + "{3}";
+  private static final String API_ONE_PR = API_ALL_PR + "{3,number,#}";
 
   private static final String API_ONE_PR_ALL_COMMENTS = API_ONE_PR + "/comments";
   private static final String API_ONE_PR_DIFF = API_ONE_PR + "/diff?withComments=true";
@t-8ch

This comment has been minimized.

Show comment
Hide comment
@t-8ch

t-8ch Feb 10, 2017

Member

@mkj28 Which version of the plugin are you using?
I would like to find out how the pull request number became a floating point number.

Member

t-8ch commented Feb 10, 2017

@mkj28 Which version of the plugin are you using?
I would like to find out how the pull request number became a floating point number.

@t-8ch

This comment has been minimized.

Show comment
Hide comment
@t-8ch

t-8ch Feb 10, 2017

Member

The new version will use ints interally for the pull request id.
Can you show me the command line you are using to call the plugin?
The pull request id should be passed down directly from the configuration, without any modification

Member

t-8ch commented Feb 10, 2017

The new version will use ints interally for the pull request id.
Can you show me the command line you are using to call the plugin?
The pull request id should be passed down directly from the configuration, without any modification

@mkj28

This comment has been minimized.

Show comment
Hide comment
@mkj28

mkj28 Feb 11, 2017

@t-8ch I'm using 1.3.0.

I think it becomes formatted in StashClient.java:
String request = MessageFormat.format(API_ONE_PR_DIFF, baseUrl, pr.project(), pr.repository(), pr.pullRequestId());

http://stackoverflow.com/questions/1942118/how-do-i-format-a-long-integer-as-a-string-without-separator-in-java

mkj28 commented Feb 11, 2017

@t-8ch I'm using 1.3.0.

I think it becomes formatted in StashClient.java:
String request = MessageFormat.format(API_ONE_PR_DIFF, baseUrl, pr.project(), pr.repository(), pr.pullRequestId());

http://stackoverflow.com/questions/1942118/how-do-i-format-a-long-integer-as-a-string-without-separator-in-java

@t-8ch

This comment has been minimized.

Show comment
Hide comment
@t-8ch

t-8ch Feb 13, 2017

Member

@mkj28 , ah misunderstood the issue. You are of course right and the fix is is correct.
I regarded the comma as a decimal separator (I am from Europe) and was wondering where you got a PR of 10.997 from.

Member

t-8ch commented Feb 13, 2017

@mkj28 , ah misunderstood the issue. You are of course right and the fix is is correct.
I regarded the comma as a decimal separator (I am from Europe) and was wondering where you got a PR of 10.997 from.

@t-8ch t-8ch closed this in e157c6e Feb 13, 2017

t-8ch added a commit that referenced this issue Mar 22, 2017

fix url building with pull requests >= 1000
By default java formats numbers with thousand separators.
This breaks our URLs. Disable it.

Fixes #98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment