Skip to content

Commit 3fd97cc

Browse files
committed
Using UTF-8 in Bitbucket client JENKINS-48648
1 parent 2e9c339 commit 3fd97cc

File tree

5 files changed

+74
-15
lines changed

5 files changed

+74
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ target
77
bin
88
temp
99
.gradle
10+
.okhttpcache

CHANGELOG.md

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,58 @@
11

2-
# Changelog
2+
# Violation comments to bitbucket server lib changelog
3+
4+
Changelog of Violation comments to bitbucket server lib.
5+
6+
## Unreleased
7+
### Jira JENKINS-48648
8+
9+
**Using UTF-8 in Bitbucket client**
10+
11+
12+
[34c3dfeaa82a055](https://github.com/tomasbjerre/violation-comments-to-bitbucket-server-lib/commit/34c3dfeaa82a055) Tomas Bjerre *2017-12-20 20:16:59*
13+
14+
15+
## 1.34
16+
### No issue
17+
18+
**Refactoring build scripts**
19+
20+
21+
[5bf64160d6ca74c](https://github.com/tomasbjerre/violation-comments-to-bitbucket-server-lib/commit/5bf64160d6ca74c) Tomas Bjerre *2017-12-07 16:01:06*
22+
23+
24+
## 1.33
25+
### No issue
26+
27+
**Resharper WikiUrl**
28+
29+
30+
[c08ea355348f350](https://github.com/tomasbjerre/violation-comments-to-bitbucket-server-lib/commit/c08ea355348f350) Tomas Bjerre *2017-10-13 09:40:16*
31+
32+
33+
## 1.32
34+
### No issue
35+
36+
**Added handling for empty IssueType Description attributes for Resharper**
37+
38+
39+
[1e2311c342cf1e0](https://github.com/tomasbjerre/violation-comments-to-bitbucket-server-lib/commit/1e2311c342cf1e0) Tomas Bjerre *2017-10-09 16:37:54*
40+
41+
**Doc**
42+
43+
44+
[37eeea9ff213c8a](https://github.com/tomasbjerre/violation-comments-to-bitbucket-server-lib/commit/37eeea9ff213c8a) Tomas Bjerre *2017-09-02 20:08:21*
45+
46+
47+
## 1.31
48+
### No issue
49+
50+
**Google Java Format**
51+
52+
53+
[ff4e27423a411f7](https://github.com/tomasbjerre/violation-comments-to-bitbucket-server-lib/commit/ff4e27423a411f7) Tomas Bjerre *2017-09-02 11:50:15*
54+
55+
356
## 1.30
457
### No issue
558

@@ -22,9 +75,9 @@
2275

2376

2477
## 1.28
25-
### No issue
78+
### GitHub [#2](https://github.com/tomasbjerre/violation-comments-to-bitbucket-server-lib/issues/2) Paths with spaces fail
2679

27-
**URL encoding paths #2**
80+
**URL encoding paths**
2881

2982

3083
[7122da4322e2f6e](https://github.com/tomasbjerre/violation-comments-to-bitbucket-server-lib/commit/7122da4322e2f6e) Tomas Bjerre *2017-08-02 15:29:50*
@@ -126,14 +179,17 @@
126179

127180

128181
## 1.17
129-
### No issue
182+
### GitHub [#1](https://github.com/tomasbjerre/violation-comments-to-bitbucket-server-lib/issues/1) NullPointerException when running the Jenkins plugin
130183

131-
**Handling deleted files in PR:s #1**
184+
**Handling deleted files in PR:s**
132185

133186
* And using violations lib 1.22
134187

135188
[40c69f6a7b64eea](https://github.com/tomasbjerre/violation-comments-to-bitbucket-server-lib/commit/40c69f6a7b64eea) Tomas Bjerre *2016-12-21 17:16:48*
136189

190+
191+
### No issue
192+
137193
**violations lib 1.22**
138194

139195

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ dependencies {
2727
testCompile 'junit:junit:4.12'
2828
testCompile 'org.assertj:assertj-core:2.3.0'
2929
testCompile ('org.assertj:assertj-core:2.5.0')
30-
}
30+
}

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
./gradlew clean gitChangelogTask eclipse build install -i
2+
./gradlew --refresh-dependencies clean gitChangelogTask eclipse build install -i

src/main/java/se/bjurr/violations/comments/bitbucketserver/lib/client/BitbucketServerInvoker.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package se.bjurr.violations.comments.bitbucketserver.lib.client;
22

3+
import static com.google.common.base.Charsets.UTF_8;
34
import static com.google.common.base.Strings.isNullOrEmpty;
45

56
import com.google.common.base.Throwables;
@@ -34,11 +35,12 @@ public String invokeUrl(
3435
try {
3536
CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
3637
conn = (HttpURLConnection) new URL(url).openConnection();
37-
String userAndPass = bitbucketServerUser + ":" + bitbucketServerPassword;
38-
String authString = new String(DatatypeConverter.printBase64Binary(userAndPass.getBytes()));
38+
final String userAndPass = bitbucketServerUser + ":" + bitbucketServerPassword;
39+
final String authString =
40+
new String(DatatypeConverter.printBase64Binary(userAndPass.getBytes()));
3941
conn.setRequestProperty("Authorization", "Basic " + authString);
4042
conn.setRequestMethod(method.name());
41-
String charset = "UTF-8";
43+
final String charset = "UTF-8";
4244
conn.setDoOutput(true);
4345
conn.setRequestProperty("X-Atlassian-Token", "no-check");
4446
conn.setRequestProperty("Content-Type", "application/json");
@@ -48,15 +50,15 @@ public String invokeUrl(
4850
output = conn.getOutputStream();
4951
output.write(postContent.getBytes(charset));
5052
}
51-
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
52-
StringBuilder stringBuilder = new StringBuilder();
53+
reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), UTF_8));
54+
final StringBuilder stringBuilder = new StringBuilder();
5355
String line = null;
5456
while ((line = reader.readLine()) != null) {
5557
stringBuilder.append(line + "\n");
5658
}
57-
String json = stringBuilder.toString();
59+
final String json = stringBuilder.toString();
5860
return json;
59-
} catch (Exception e) {
61+
} catch (final Exception e) {
6062
throw new RuntimeException("Error calling:\n" + url + "\n" + method + "\n" + postContent, e);
6163
} finally {
6264
try {
@@ -69,7 +71,7 @@ public String invokeUrl(
6971
if (output != null) {
7072
output.close();
7173
}
72-
} catch (IOException e) {
74+
} catch (final IOException e) {
7375
throw Throwables.propagate(e);
7476
}
7577
}

0 commit comments

Comments
 (0)