Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions quickfixj-core/src/main/java/quickfix/CachedFileStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ public class CachedFileStore implements MessageStore {
sessionFileName = prefix + "session";

final File directory = new File(msgFileName).getParentFile();
if (!directory.exists()) {
directory.mkdirs();
}
directory.mkdirs();

initialize(false);
}
Expand Down Expand Up @@ -176,7 +174,7 @@ private void initializeSequenceNumbers() throws IOException {
final String s = sequenceNumberFile.readUTF();
final int offset = s.indexOf(':');
if (offset < 0) {
throw new IOException("Invalid sequenceNumbderFile '" + seqNumFileName
throw new IOException("Invalid sequenceNumberFile '" + seqNumFileName
+ "' character ':' is missing");
}
cache.setNextSenderMsgSeqNum(Integer.parseInt(s.substring(0, offset)));
Expand Down Expand Up @@ -349,7 +347,7 @@ public boolean set(int sequence, String message) throws IOException {
final long offset = messageFileWriter.getFilePointer();
final byte[] messageBytes = message.getBytes(CharsetSupport.getCharset());
final int size = messageBytes.length;
messageIndex.put((long) sequence, new long[] { offset, size });
messageIndex.put((long) sequence, new long[]{offset, size});
headerDataOutputStream.writeInt(sequence);
headerDataOutputStream.writeLong(offset);
headerDataOutputStream.writeInt(size);
Expand Down Expand Up @@ -488,7 +486,7 @@ private long[] seekMessageIndex(final long index) {
final long offset = headerDataInputStream.readLong();
final int size = headerDataInputStream.readInt();
if (index == sequenceNumber) {
return new long[] { offset, size };
return new long[]{offset, size};
}
}
} catch (final IOException e) {
Expand Down Expand Up @@ -519,7 +517,7 @@ private List<long[]> seekMessageIndex(final long startSequence, final long endSe
final long offset = headerDataInputStream.readLong();
final int size = headerDataInputStream.readInt();
if (sequenceNumber >= startSequence && sequenceNumber <= endSequence) {
indexPerSequenceNumber.put(sequenceNumber, new long[] { offset, size });
indexPerSequenceNumber.put(sequenceNumber, new long[]{offset, size});
}
}
} catch (final IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/**
* Creates a message store that stores messages in a file. Compatibility note: The file formats are not compatible with
* QF C++/JNI. If you upgrading from the QuickFIX JNI, you must delete your old session state files.)
* QF C++/JNI. If you're upgrading from the QuickFIX JNI, you must delete your old session state files.)
*/
public class CachedFileStoreFactory extends FileStoreFactory {

Expand Down
38 changes: 19 additions & 19 deletions quickfixj-core/src/main/java/quickfix/DefaultSessionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class DefaultSessionFactory implements SessionFactory {
private final SessionScheduleFactory sessionScheduleFactory;

public DefaultSessionFactory(Application application, MessageStoreFactory messageStoreFactory,
LogFactory logFactory) {
LogFactory logFactory) {
this.application = application;
this.messageStoreFactory = messageStoreFactory;
this.messageQueueFactory = new InMemoryMessageQueueFactory();
Expand All @@ -66,7 +66,7 @@ public DefaultSessionFactory(Application application, MessageStoreFactory messag
}

public DefaultSessionFactory(Application application, MessageStoreFactory messageStoreFactory,
LogFactory logFactory, MessageFactory messageFactory) {
LogFactory logFactory, MessageFactory messageFactory) {
this.application = application;
this.messageStoreFactory = messageStoreFactory;
this.messageQueueFactory = new InMemoryMessageQueueFactory();
Expand Down Expand Up @@ -274,7 +274,7 @@ public Session create(SessionID sessionID, SessionSettings settings) throws Conf
}

private void processPreFixtDataDictionary(SessionID sessionID, SessionSettings settings,
DefaultDataDictionaryProvider dataDictionaryProvider) throws ConfigError,
DefaultDataDictionaryProvider dataDictionaryProvider) throws ConfigError,
FieldConvertError {
final DataDictionary dataDictionary = createDataDictionary(sessionID, settings,
Session.SETTING_DATA_DICTIONARY, sessionID.getBeginString());
Expand All @@ -284,7 +284,7 @@ private void processPreFixtDataDictionary(SessionID sessionID, SessionSettings s
}

private DataDictionary createDataDictionary(SessionID sessionID, SessionSettings settings,
String settingsKey, String beginString) throws ConfigError, FieldConvertError {
String settingsKey, String beginString) throws ConfigError, FieldConvertError {
final String path = getDictionaryPath(sessionID, settings, settingsKey, beginString);
return getDataDictionary(path);
}
Expand All @@ -293,22 +293,22 @@ private ValidationSettings createValidationSettings(SessionID sessionID, Session
ValidationSettings validationSettings = new ValidationSettings();

validationSettings.setCheckFieldsOutOfOrder(settings.getBoolOrDefault(sessionID,
Session.SETTING_VALIDATE_FIELDS_OUT_OF_ORDER, validationSettings.isCheckFieldsOutOfOrder()));
Session.SETTING_VALIDATE_FIELDS_OUT_OF_ORDER, validationSettings.isCheckFieldsOutOfOrder()));

validationSettings.setCheckFieldsHaveValues(settings.getBoolOrDefault(sessionID,
Session.SETTING_VALIDATE_FIELDS_HAVE_VALUES, validationSettings.isCheckFieldsHaveValues()));
Session.SETTING_VALIDATE_FIELDS_HAVE_VALUES, validationSettings.isCheckFieldsHaveValues()));

validationSettings.setCheckUnorderedGroupFields(settings.getBoolOrDefault(sessionID,
Session.SETTING_VALIDATE_UNORDERED_GROUP_FIELDS, validationSettings.isCheckUnorderedGroupFields()));
Session.SETTING_VALIDATE_UNORDERED_GROUP_FIELDS, validationSettings.isCheckUnorderedGroupFields()));

validationSettings.setCheckUserDefinedFields(settings.getBoolOrDefault(sessionID,
Session.SETTING_VALIDATE_USER_DEFINED_FIELDS, validationSettings.isCheckUserDefinedFields()));
Session.SETTING_VALIDATE_USER_DEFINED_FIELDS, validationSettings.isCheckUserDefinedFields()));

validationSettings.setAllowUnknownMessageFields(settings.getBoolOrDefault(sessionID,
Session.SETTING_ALLOW_UNKNOWN_MSG_FIELDS, validationSettings.isAllowUnknownMessageFields()));
Session.SETTING_ALLOW_UNKNOWN_MSG_FIELDS, validationSettings.isAllowUnknownMessageFields()));

validationSettings.setFirstFieldInGroupIsDelimiter(settings.getBoolOrDefault(sessionID,
Session.SETTING_FIRST_FIELD_IN_GROUP_IS_DELIMITER, validationSettings.isFirstFieldInGroupIsDelimiter()));
Session.SETTING_FIRST_FIELD_IN_GROUP_IS_DELIMITER, validationSettings.isFirstFieldInGroupIsDelimiter()));

validateValidationSettings(validationSettings);

Expand All @@ -323,7 +323,7 @@ private void validateValidationSettings(ValidationSettings validationSettings) {
}

private void processFixtDataDictionaries(SessionID sessionID, SessionSettings settings,
DefaultDataDictionaryProvider dataDictionaryProvider) throws ConfigError,
DefaultDataDictionaryProvider dataDictionaryProvider) throws ConfigError,
FieldConvertError {
dataDictionaryProvider.addTransportDictionary(
sessionID.getBeginString(),
Expand Down Expand Up @@ -373,7 +373,7 @@ private boolean isApplVerIdEnum(String value) {
}

private String getDictionaryPath(SessionID sessionID, SessionSettings settings,
String settingsKey, String beginString) throws ConfigError, FieldConvertError {
String settingsKey, String beginString) throws ConfigError, FieldConvertError {
String path;
if (settings.isSetting(sessionID, settingsKey)) {
path = settings.getString(sessionID, settingsKey);
Expand Down Expand Up @@ -410,7 +410,7 @@ private int[] getLogonIntervalsInSeconds(SessionSettings settings, SessionID ses
throw new ConfigError(e);
}
}
return new int[] { 5 }; // default value
return new int[]{5}; // default value
}

private Set<InetAddress> getInetAddresses(SessionSettings settings, SessionID sessionID)
Expand All @@ -428,26 +428,26 @@ private Set<InetAddress> getInetAddresses(SessionSettings settings, SessionID se
}

private boolean getSetting(SessionSettings settings, SessionID sessionID, String key,
boolean defaultValue) throws ConfigError, FieldConvertError {
boolean defaultValue) throws ConfigError, FieldConvertError {
return settings.isSetting(sessionID, key) ? settings.getBool(sessionID, key) : defaultValue;
}

private int getSetting(SessionSettings settings, SessionID sessionID, String key,
int defaultValue) throws ConfigError, FieldConvertError {
int defaultValue) throws ConfigError, FieldConvertError {
return settings.isSetting(sessionID, key)
? (int) settings.getLong(sessionID, key)
: defaultValue;
}

private double getSetting(SessionSettings settings, SessionID sessionID, String key,
double defaultValue) throws ConfigError, FieldConvertError {
double defaultValue) throws ConfigError, FieldConvertError {
return settings.isSetting(sessionID, key)
? Double.parseDouble(settings.getString(sessionID, key))
: defaultValue;
}

private UtcTimestampPrecision getTimestampPrecision(SessionSettings settings, SessionID sessionID,
UtcTimestampPrecision defaultValue) throws ConfigError, FieldConvertError {
UtcTimestampPrecision defaultValue) throws ConfigError, FieldConvertError {
if (settings.isSetting(sessionID, Session.SETTING_TIMESTAMP_PRECISION)) {
String string = settings.getString(sessionID, Session.SETTING_TIMESTAMP_PRECISION);
try {
Expand All @@ -462,13 +462,13 @@ private UtcTimestampPrecision getTimestampPrecision(SessionSettings settings, Se

private List<StringField> getLogonTags(SessionSettings settings, SessionID sessionID) throws ConfigError, FieldConvertError {
List<StringField> logonTags = new ArrayList<>();
for (int index = 0;; index++) {
for (int index = 0; ; index++) {
final String logonTagSetting = Session.SETTING_LOGON_TAG
+ (index == 0 ? "" : NumbersCache.get(index));
if (settings.isSetting(sessionID, logonTagSetting)) {
String tag = settings.getString(sessionID, logonTagSetting);
String[] split = tag.split("=", 2);
StringField stringField = new StringField(Integer.valueOf(split[0]), split[1]);
StringField stringField = new StringField(Integer.parseInt(split[0]), split[1]);
Copy link
Author

@abhishekraha abhishekraha Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed redundant auto-boxing

logonTags.add(stringField);
} else {
break;
Expand Down
7 changes: 3 additions & 4 deletions quickfixj-core/src/main/java/quickfix/FileLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ public class FileLog extends AbstractLog {
eventFileName = prefix + "event.log";

File directory = new File(messagesFileName).getParentFile();
if (!directory.exists()) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant check as directory.mkdir() has exists check inbuilt

directory.mkdirs();
}
directory.mkdirs();


this.includeMillis = includeMillis;
this.includeTimestampForMessages = includeTimestampForMessages;
Expand All @@ -94,7 +93,7 @@ protected void logOutgoing(String message) {

private void writeMessage(FileOutputStream stream, Object lock, String message, boolean forceTimestamp) {
try {
synchronized(lock) {
synchronized (lock) {
if (forceTimestamp || includeTimestampForMessages) {
writeTimeStamp(stream);
}
Expand Down
6 changes: 2 additions & 4 deletions quickfixj-core/src/main/java/quickfix/FileStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public class FileStore implements MessageStore, Closeable {
sessionFileName = prefix + "session";

final File directory = new File(msgFileName).getParentFile();
if (!directory.exists()) {
directory.mkdirs();
}
directory.mkdirs();

initialize(false);
}
Expand Down Expand Up @@ -203,7 +201,7 @@ private void updateMessageIndex(long sequenceNum, long offset, int size) {
messageIndex.pollFirstEntry();
}

messageIndex.put(sequenceNum, new long[] { offset, size });
messageIndex.put(sequenceNum, new long[]{offset, size});
}

/**
Expand Down
6 changes: 3 additions & 3 deletions quickfixj-core/src/main/java/quickfix/MessageCracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class MessageCracker {
public @interface Handler {
}

public class RedundantHandlerException extends RuntimeException {
public static class RedundantHandlerException extends RuntimeException {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-static inner class will unnecessarily carry a reference to the outer class

private final Class<?> messageClass;
private final Method originalMethod;
private final Method redundantMethod;
Expand All @@ -55,7 +55,7 @@ public RedundantHandlerException(Class<?> messageClass, Method originalMethod,

@Override
public String toString() {
return "Duplicate handler method for " + messageClass + ", orginal method is "
return "Duplicate handler method for " + messageClass + ", original method is "
+ originalMethod + ", redundant method is " + redundantMethod;
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ private boolean matchesConventionOrAnnotation(Method method) {
return method.getName().equals("onMessage") || method.isAnnotationPresent(Handler.class);
}

private class Invoker {
private static class Invoker {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-static inner class will unnecessarily carry a reference to the outer class

private final Object target;
private final Method method;

Expand Down
8 changes: 4 additions & 4 deletions quickfixj-core/src/main/java/quickfix/SleepycatStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public synchronized void get(int startSequence, int endSequence, Collection<Stri
Cursor cursor = null;
try {
DatabaseEntry sequenceKey = new DatabaseEntry();
EntryBinding sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class);
EntryBinding<Integer> sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making variable type safe at source instead of doing type-casting everytime it is used

// Must start at start-1 because db will look for next record larger
sequenceBinding.objectToEntry(startSequence - 1, sequenceKey);

Expand All @@ -223,15 +223,15 @@ public synchronized void get(int startSequence, int endSequence, Collection<Stri
if (retVal == OperationStatus.NOTFOUND) {
log.debug("{}/{} not matched in database {}", sequenceKey, messageBytes, messageDatabase.getDatabaseName());
} else {
Integer sequenceNumber = (Integer) sequenceBinding.entryToObject(sequenceKey);
Integer sequenceNumber = sequenceBinding.entryToObject(sequenceKey);
while (sequenceNumber <= endSequence) {
messages.add(new String(messageBytes.getData(), charsetEncoding));
if (log.isDebugEnabled()) {
log.debug("Found record {}=>{} for search key/data: {}=>{}",
sequenceNumber, new String(messageBytes.getData(), charsetEncoding), sequenceKey, messageBytes);
}
cursor.getNext(sequenceKey, messageBytes, LockMode.DEFAULT);
sequenceNumber = (Integer) sequenceBinding.entryToObject(sequenceKey);
sequenceNumber = sequenceBinding.entryToObject(sequenceKey);
}
}
} catch (Exception e) {
Expand Down Expand Up @@ -309,7 +309,7 @@ public void reset() throws IOException {
public boolean set(int sequence, String message) throws IOException {
try {
DatabaseEntry sequenceKey = new DatabaseEntry();
EntryBinding sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class);
EntryBinding<Integer> sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class);
sequenceBinding.objectToEntry(sequence, sequenceKey);
DatabaseEntry messageBytes = new DatabaseEntry(message.getBytes(CharsetSupport.getCharset()));
messageDatabase.put(null, sequenceKey, messageBytes);
Expand Down
12 changes: 6 additions & 6 deletions quickfixj-core/src/main/java/quickfix/mina/SessionConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public SessionConnector(SessionSettings settings, SessionFactory sessionFactory)
* If using external Executors, this method should be called immediately after the constructor. Once set, the
* Executors cannot be changed.
* </p>
*
*
* @param executorFactory See {@link ExecutorFactory} for detailed requirements.
*/
public void setExecutorFactory(ExecutorFactory executorFactory) {
Expand Down Expand Up @@ -296,7 +296,7 @@ protected void waitForLogout() {
}

protected void logError(SessionID sessionID, IoSession protocolSession, String message, Throwable t) {
log.error(message + getLogSuffix(sessionID, protocolSession), t);
log.error("{}{}", message, getLogSuffix(sessionID, protocolSession), t);
}

private String getLogSuffix(SessionID sessionID, IoSession protocolSession) {
Expand Down Expand Up @@ -329,7 +329,7 @@ protected void stopSessionTimer() {

// visible for testing
boolean checkSessionTimerRunning() {
if ( sessionTimerFuture != null ) {
if (sessionTimerFuture != null) {
return !sessionTimerFuture.isDone();
}
return false;
Expand Down Expand Up @@ -433,13 +433,13 @@ public void setIoFilterChainBuilder(IoFilterChainBuilder ioFilterChainBuilder) {
protected IoFilterChainBuilder getIoFilterChainBuilder() {
return ioFilterChainBuilder;
}

/**
* Closes all managed sessions of an Initiator/Acceptor.
*
* @param ioService Acceptor or Initiator implementation
* @param ioService Acceptor or Initiator implementation
* @param awaitTermination whether to wait for underlying ExecutorService to terminate
* @param logger used for logging WARNING when IoSession could not be closed
* @param logger used for logging WARNING when IoSession could not be closed
*/
public static void closeManagedSessionsAndDispose(IoService ioService, boolean awaitTermination, Logger logger) {
Map<Long, IoSession> managedSessions = ioService.getManagedSessions();
Expand Down
Loading