Skip to content

Commit

Permalink
Minor spotbugs and sonar fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelmay committed Mar 24, 2019
1 parent f97c1a0 commit e950955
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class GreenMailUtil {
private static int generateCount = 0;
private static final String GENERATE_SET = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPRSTUVWXYZ23456789";
private static final int GENERATE_SET_SIZE = GENERATE_SET.length();
private static final Random RANDOM = new Random();

private static GreenMailUtil instance = new GreenMailUtil();

Expand Down Expand Up @@ -179,16 +180,14 @@ public static String toString(Part msg) {
* @return the random string.
*/
public static String random() {
Random r = new Random();
int nbrOfLetters = r.nextInt(3) + 5;
int nbrOfLetters = RANDOM.nextInt(3) + 5;
return random(nbrOfLetters);
}

public static String random(int nbrOfLetters) {
Random r = new Random();
StringBuilder ret = new StringBuilder();
for (/* empty */; nbrOfLetters > 0; nbrOfLetters--) {
int pos = (r.nextInt(GENERATE_SET_SIZE) + (++generateCount)) % GENERATE_SET_SIZE;
int pos = (RANDOM.nextInt(GENERATE_SET_SIZE) + (++generateCount)) % GENERATE_SET_SIZE;
ret.append(GENERATE_SET.charAt(pos));
}
return ret.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static void configure(final Configuration pConf,
if ("host".equals(hostOrPort)) {
serviceConf.hostname = pValue;
} else if ("port".equals(hostOrPort)) {
serviceConf.port = Integer.valueOf(pValue);
serviceConf.port = Integer.parseInt(pValue);
}
}
}
Expand Down

0 comments on commit e950955

Please sign in to comment.