Skip to content

Commit e0a13c8

Browse files
added findbugs + maven task to check at compile time
1 parent 69eee25 commit e0a13c8

7 files changed

Lines changed: 32 additions & 11 deletions

File tree

pom.xml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,20 @@
4949
<artifactId>commons-codec</artifactId>
5050
<version>1.4</version>
5151
</dependency>
52-
52+
5353
<dependency>
5454
<groupId>junit</groupId>
5555
<artifactId>junit</artifactId>
5656
<version>4.8.1</version>
5757
<scope>test</scope>
5858
</dependency>
59-
59+
6060
</dependencies>
6161
<build>
6262
<plugins>
6363
<plugin>
6464
<artifactId>maven-compiler-plugin</artifactId>
65+
<version>3.0</version>
6566
<configuration>
6667
<source>1.5</source>
6768
<target>1.5</target>
@@ -70,6 +71,7 @@
7071
<plugin>
7172
<groupId>org.apache.maven.plugins</groupId>
7273
<artifactId>maven-gpg-plugin</artifactId>
74+
<version>1.4</version>
7375
<executions>
7476
<execution>
7577
<id>sign-artifacts</id>
@@ -80,6 +82,23 @@
8082
</execution>
8183
</executions>
8284
</plugin>
85+
<plugin>
86+
<groupId>org.codehaus.mojo</groupId>
87+
<artifactId>findbugs-maven-plugin</artifactId>
88+
<version>2.5.2</version>
89+
<executions>
90+
<execution>
91+
<id>failing-on-high</id>
92+
<phase>compile</phase>
93+
<goals>
94+
<goal>check</goal>
95+
</goals>
96+
<configuration>
97+
<threshold>Low</threshold>
98+
</configuration>
99+
</execution>
100+
</executions>
101+
</plugin>
83102
</plugins>
84103
</build>
85104
</project>

src/main/java/org/scribe/builder/api/PlurkApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public String getAccessTokenEndpoint()
2626
return ACCESS_TOKEN_URL;
2727
}
2828

29-
public class Mobile extends PlurkApi
29+
public static class Mobile extends PlurkApi
3030
{
3131
private static final String AUTHORIZATION_URL = "http://www.plurk.com/m/authorize?oauth_token=%s";
3232

src/main/java/org/scribe/extractors/HeaderExtractorImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public String extract(OAuthRequest request)
2626
Map<String, String> parameters = request.getOauthParameters();
2727
StringBuffer header = new StringBuffer(parameters.size() * 20);
2828
header.append(PREAMBLE);
29-
for (String key : parameters.keySet())
29+
for (Map.Entry<String, String> entry : parameters.entrySet())
3030
{
3131
if(header.length() > PREAMBLE.length())
3232
{
3333
header.append(PARAM_SEPARATOR);
3434
}
35-
header.append(String.format("%s=\"%s\"", key, OAuthEncoder.encode(parameters.get(key))));
35+
header.append(String.format("%s=\"%s\"", entry.getKey(), OAuthEncoder.encode(entry.getValue())));
3636
}
3737
return header.toString();
3838
}

src/main/java/org/scribe/model/Request.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import java.net.*;
55
import java.nio.charset.*;
66
import java.util.*;
7-
import java.util.concurrent.TimeUnit;
7+
import java.util.concurrent.*;
88

99
import org.scribe.exceptions.*;
1010

@@ -189,7 +189,7 @@ public void addPayload(String payload)
189189
*/
190190
public void addPayload(byte[] payload)
191191
{
192-
this.bytePayload = payload;
192+
this.bytePayload = payload.clone();
193193
}
194194

195195
/**

src/main/java/org/scribe/services/HMACSha1SignatureService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private String doSign(String toSign, String keyString) throws Exception
4444
Mac mac = Mac.getInstance(HMAC_SHA1);
4545
mac.init(key);
4646
byte[] bytes = mac.doFinal(toSign.getBytes(UTF8));
47-
return new String(Base64.encodeBase64(bytes)).replace(CARRIAGE_RETURN, EMPTY_STRING);
47+
return new String(Base64.encodeBase64(bytes), UTF8).replace(CARRIAGE_RETURN, EMPTY_STRING);
4848
}
4949

5050
/**

src/main/java/org/scribe/services/RSASha1SignatureService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class RSASha1SignatureService implements SignatureService
1111
{
1212
private static final String METHOD = "RSA-SHA1";
1313
private static final String RSA_SHA1 = "SHA1withRSA";
14+
private static final String UTF8 = "UTF-8";
1415

1516
private PrivateKey privateKey;
1617

@@ -28,8 +29,8 @@ public String getSignature(String baseString, String apiSecret, String tokenSecr
2829
{
2930
Signature signature = Signature.getInstance(RSA_SHA1);
3031
signature.initSign(privateKey);
31-
signature.update(baseString.getBytes());
32-
return new String(Base64.encodeBase64(signature.sign(), false));
32+
signature.update(baseString.getBytes(UTF8));
33+
return new String(Base64.encodeBase64(signature.sign(), false), UTF8);
3334
}
3435
catch (Exception e)
3536
{

src/main/java/org/scribe/services/TimestampServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ void setTimer(Timer timer)
5353
*/
5454
static class Timer
5555
{
56+
private final Random rand = new Random();
5657
Long getMilis()
5758
{
5859
return System.currentTimeMillis();
5960
}
6061

6162
Integer getRandomInteger()
6263
{
63-
return new Random().nextInt();
64+
return rand.nextInt();
6465
}
6566
}
6667

0 commit comments

Comments
 (0)