Skip to content

Commit b5fe194

Browse files
author
Guido Medina
committed
System time synchronization changed to volatile.
Static final pattern variable names fixes. Slf4j updated to 1.7.18
1 parent 6bb3cab commit b5fe194

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
7070
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
7171
<jdkLevel>1.7</jdkLevel>
72-
<slf4j.version>1.7.16</slf4j.version>
72+
<slf4j.version>1.7.18</slf4j.version>
7373
<mainClass/>
7474

7575
<maven-resources-plugin-version>2.7</maven-resources-plugin-version>

quickfixj-core/src/main/java/quickfix/SessionID.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* but using different FIX versions (and/or session qualifiers).
3939
*/
4040
public class SessionID implements Serializable {
41-
private static final Pattern pattern = Pattern.compile("(.*?):(.*?)(?:/(.*?)|)(?:/(.*?)|)->(.*?)(?:/(.*?)|)(?:/(.*?)|)(?::(.*)|)");
41+
private static final Pattern PATTERN = Pattern.compile("(.*?):(.*?)(?:/(.*?)|)(?:/(.*?)|)->(.*?)(?:/(.*?)|)(?:/(.*?)|)(?::(.*)|)");
4242
public static final String NOT_SET = "";
4343

4444
private final String id;
@@ -106,7 +106,7 @@ public SessionID() {
106106
}
107107

108108
public SessionID(String id) {
109-
Matcher matcher = pattern.matcher(id);
109+
Matcher matcher = PATTERN.matcher(id);
110110
if (!matcher.matches()) {
111111
throw new IllegalArgumentException("Invalid session ID string: " + id);
112112
}

quickfixj-core/src/main/java/quickfix/SessionSettings.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,14 @@ private void skipWhitespace(Reader reader) throws IOException {
529529
}
530530
}
531531

532-
private final Pattern variablePattern = Pattern.compile("\\$\\{(.+?)}");
532+
private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\$\\{(.+?)}");
533533

534534
private String interpolate(String value) {
535535
if (value == null || value.indexOf('$') == -1) {
536536
return value;
537537
}
538538
final StringBuffer buffer = new StringBuffer();
539-
final Matcher m = variablePattern.matcher(value);
539+
final Matcher m = VARIABLE_PATTERN.matcher(value);
540540
while (m.find()) {
541541
if (m.start() > 0 && value.charAt(m.start() - 1) == '\\') {
542542
continue;

quickfixj-core/src/main/java/quickfix/SystemTime.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ public long getTime() {
3535
}
3636
};
3737

38-
private static SystemTimeSource systemTimeSource = DEFAULT_TIME_SOURCE;
38+
private static volatile SystemTimeSource systemTimeSource = DEFAULT_TIME_SOURCE;
3939

40-
public static synchronized long currentTimeMillis() {
40+
public static long currentTimeMillis() {
4141
return systemTimeSource.getTime();
4242
}
4343

4444
public static Date getDate() {
4545
return new Date(currentTimeMillis());
4646
}
4747

48-
public static synchronized void setTimeSource(SystemTimeSource systemTimeSource) {
48+
public static void setTimeSource(SystemTimeSource systemTimeSource) {
4949
SystemTime.systemTimeSource = systemTimeSource != null ? systemTimeSource
5050
: DEFAULT_TIME_SOURCE;
5151
}

quickfixj-core/src/main/java/quickfix/field/converter/DoubleConverter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
* Converts between a double and a String.
3333
*/
3434
public class DoubleConverter {
35-
private static final Pattern decimalPattern = Pattern.compile("-?\\d*(\\.\\d*)?");
36-
private static final ThreadLocal<DecimalFormat[]> threadDecimalFormats = new ThreadLocal<DecimalFormat[]>();
35+
private static final Pattern DECIMAL_PATTERN = Pattern.compile("-?\\d*(\\.\\d*)?");
36+
private static final ThreadLocal<DecimalFormat[]> THREAD_DECIMAL_FORMATS = new ThreadLocal<DecimalFormat[]>();
3737

3838
/**
3939
* Converts a double to a string with no padding.
@@ -51,10 +51,10 @@ static DecimalFormat getDecimalFormat(int padding) {
5151
// FieldConvertError not supported in setDouble methods on Message
5252
throw new RuntimeError("maximum padding of 14 zeroes is supported: " + padding);
5353
}
54-
DecimalFormat[] decimalFormats = threadDecimalFormats.get();
54+
DecimalFormat[] decimalFormats = THREAD_DECIMAL_FORMATS.get();
5555
if (decimalFormats == null) {
5656
decimalFormats = new DecimalFormat[14];
57-
threadDecimalFormats.set(decimalFormats);
57+
THREAD_DECIMAL_FORMATS.set(decimalFormats);
5858
}
5959
DecimalFormat f = decimalFormats[padding];
6060
if (f == null) {
@@ -92,7 +92,7 @@ public static String convert(double d, int padding) {
9292
*/
9393
public static double convert(String value) throws FieldConvertError {
9494
try {
95-
Matcher matcher = decimalPattern.matcher(value);
95+
Matcher matcher = DECIMAL_PATTERN.matcher(value);
9696
if (!matcher.matches()) {
9797
throw new NumberFormatException();
9898
}

quickfixj-core/src/test/java/quickfix/test/acceptance/ExpectMessageStep.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public class ExpectMessageStep implements TestStep {
4444
private final Logger log = LoggerFactory.getLogger(getClass());
4545
private final String data;
4646
private final Map<String, String> expectedFields;
47-
private static final Pattern headerPattern = Pattern.compile("^E(\\d+),.*");
48-
private static final Pattern fieldPattern = Pattern.compile("(\\d+)=([^\\001]+)\\001");
47+
private static final Pattern HEADER_PATTERN = Pattern.compile("^E(\\d+),.*");
48+
private static final Pattern FIELD_PATTERN = Pattern.compile("(\\d+)=([^\\001]+)\\001");
4949
private int clientId = 0;
5050
private static final int heartBeatOverride;
5151

@@ -56,7 +56,7 @@ public class ExpectMessageStep implements TestStep {
5656

5757
public ExpectMessageStep(String data) {
5858
this.data = data;
59-
Matcher headerMatcher = headerPattern.matcher(data);
59+
Matcher headerMatcher = HEADER_PATTERN.matcher(data);
6060
if (headerMatcher.matches()) {
6161
clientId = Integer.parseInt(headerMatcher.group(1));
6262
} else {
@@ -67,7 +67,7 @@ public ExpectMessageStep(String data) {
6767

6868
private Map<String, String> simpleParse(String data) {
6969
HashMap<String, String> fields = new HashMap<String, String>();
70-
Matcher fieldMatcher = fieldPattern.matcher(data);
70+
Matcher fieldMatcher = FIELD_PATTERN.matcher(data);
7171
while (fieldMatcher.find()) {
7272
fields.put(fieldMatcher.group(1), fieldMatcher.group(2));
7373
}

0 commit comments

Comments
 (0)