Skip to content

Commit

Permalink
Merge branch 'master' into qfj-removeSleepycat
Browse files Browse the repository at this point in the history
  • Loading branch information
chrjohn authored Feb 5, 2025
2 parents ac023d6 + 974dc7f commit 30c4312
Show file tree
Hide file tree
Showing 18 changed files with 523 additions and 196 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Test with Maven
run: ./mvnw install -B -V -D"maven.javadoc.skip"="true" -P"skipBundlePlugin,minimal-fix-latest" -D"java.util.logging.config.file"="./quickfixj-core/src/test/resources/logging.properties" -D"http.keepAlive"="false" -D"maven.wagon.http.pool"="false" -D"maven.wagon.httpconnectionManager.ttlSeconds"="120"
run: ./mvnw install -B -V -D"maven.javadoc.skip"="true" -P"skipBundlePlugin,minimal-fix-latest" -D"java.util.logging.config.file"="${{github.workspace}}/quickfixj-core/src/test/resources/logging.properties" -D"http.keepAlive"="false" -D"maven.wagon.http.pool"="false" -D"maven.wagon.httpconnectionManager.ttlSeconds"="120"

test-windows:
runs-on: ${{ matrix.os }}
Expand All @@ -55,4 +55,4 @@ jobs:
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Test with Maven on Windows
run: ./mvnw.cmd install -B -V -D"maven.javadoc.skip"="true" -P"skipBundlePlugin,minimal-fix-latest" -D"java.util.logging.config.file"="./quickfixj-core/src/test/resources/logging.properties" -D"http.keepAlive"="false" -D"maven.wagon.http.pool"="false" -D"maven.wagon.httpconnectionManager.ttlSeconds"="120"
run: ./mvnw.cmd install -B -V -D"maven.javadoc.skip"="true" -P"skipBundlePlugin,minimal-fix-latest" -D"java.util.logging.config.file"="${{github.workspace}}/quickfixj-core/src/test/resources/logging.properties" -D"http.keepAlive"="false" -D"maven.wagon.http.pool"="false" -D"maven.wagon.httpconnectionManager.ttlSeconds"="120"
6 changes: 4 additions & 2 deletions quickfixj-base/src/main/java/quickfix/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ private void parseGroup(String msgType, StringField field, DataDictionary dd, Da
throw MessageUtils.newInvalidMessageException("Repeating group count requires an Integer but found '" + field.getValue() + "' in " + messageData, this);
}
parent.setField(groupCountTag, field);
final int firstField = rg.getDelimiterField();
int firstField = dds.isFirstFieldInGroupIsDelimiter() ? -1 : rg.getDelimiterField();
Group group = null;
boolean inGroupParse = true;
while (inGroupParse) {
Expand All @@ -743,7 +743,9 @@ private void parseGroup(String msgType, StringField field, DataDictionary dd, Da
break;
}
int tag = field.getTag();
if (tag == firstField) {
boolean shouldCreateNewGroup = tag == firstField || (dds.isFirstFieldInGroupIsDelimiter() && firstField == -1);
if (shouldCreateNewGroup) {
firstField = tag;
addGroupRefToParent(group, parent);
group = new Group(groupCountTag, firstField, groupDataDictionary.getOrderedFields());
group.setField(field);
Expand Down
17 changes: 17 additions & 0 deletions quickfixj-base/src/main/java/quickfix/ValidationSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ValidationSettings {
boolean checkUserDefinedFields = true;
boolean checkUnorderedGroupFields = true;
boolean allowUnknownMessageFields = false;
boolean firstFieldInGroupIsDelimiter = false;

public ValidationSettings() {}

Expand All @@ -34,6 +35,7 @@ public ValidationSettings(ValidationSettings validationSettings) {
this.checkUserDefinedFields = validationSettings.checkUserDefinedFields;
this.checkUnorderedGroupFields = validationSettings.checkUnorderedGroupFields;
this.allowUnknownMessageFields = validationSettings.allowUnknownMessageFields;
this.firstFieldInGroupIsDelimiter = validationSettings.firstFieldInGroupIsDelimiter;
}

/**
Expand Down Expand Up @@ -65,6 +67,10 @@ public boolean isAllowUnknownMessageFields() {
return allowUnknownMessageFields;
}

public boolean isFirstFieldInGroupIsDelimiter() {
return firstFieldInGroupIsDelimiter;
}

/**
* Controls whether group fields are in the same order
*
Expand Down Expand Up @@ -95,4 +101,15 @@ public void setCheckUserDefinedFields(boolean flag) {
public void setAllowUnknownMessageFields(boolean allowUnknownFields) {
allowUnknownMessageFields = allowUnknownFields;
}

/**
* Controls whether any field which is
* first in the repeating group would be used as delimiter
*
* @param flag true = use first field from message, false = follow data dictionary
* Must be used with disabled {@link #setCheckUnorderedGroupFields(boolean)}
*/
public void setFirstFieldInGroupIsDelimiter(boolean flag) {
firstFieldInGroupIsDelimiter = flag;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void copyConstructor_retains_settings() {
validationSettings.setCheckFieldsOutOfOrder(false);
validationSettings.setCheckUnorderedGroupFields(false);
validationSettings.setCheckUserDefinedFields(false);
validationSettings.setFirstFieldInGroupIsDelimiter(true);

ValidationSettings validationSettingsCopy = new ValidationSettings(validationSettings);

Expand All @@ -22,5 +23,6 @@ public void copyConstructor_retains_settings() {
assertEquals(validationSettingsCopy.isCheckFieldsOutOfOrder(), validationSettings.isCheckFieldsOutOfOrder());
assertEquals(validationSettingsCopy.isCheckUnorderedGroupFields(), validationSettings.isCheckUnorderedGroupFields());
assertEquals(validationSettingsCopy.isCheckUserDefinedFields(), validationSettings.isCheckUserDefinedFields());
assertEquals(validationSettingsCopy.isFirstFieldInGroupIsDelimiter(), validationSettings.isFirstFieldInGroupIsDelimiter());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void execute()
}

if (null == fileset) {
String errorMsg = "filset must not be null.";
String errorMsg = "fileset must not be null.";
this.getLog().error(errorMsg);
throw new MojoExecutionException( errorMsg );
}
Expand Down Expand Up @@ -115,7 +115,7 @@ private void prune(Set<String> fieldNames, File targetDirectory, String fileSuff
Collections.sort(fileList);
this.getLog().info(descriptor + "s to delete : " + fileList.size());
for (String fileName : fileList) {
this.getLog().info("Deleting " + descriptor + " : " + fileName);
this.getLog().debug("Deleting " + descriptor + " : " + fileName);
File file = new File( targetDirectory, fileName );
Files.delete(file.toPath());
}
Expand Down Expand Up @@ -163,7 +163,7 @@ private void collectFieldNames(Set<String> fieldNames) throws MojoExecutionExcep
List<String> fieldList = new ArrayList<String>(fieldNames);
Collections.sort(fieldList);
for (String fieldName : fieldList) {
this.getLog().info("Found field : " + fieldName);
this.getLog().debug("Found field : " + fieldName);
}
this.getLog().info("Found field total : " + fieldList.size());
}
Expand Down
2 changes: 1 addition & 1 deletion quickfixj-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-example</artifactId>
<version>4.1.116.Final</version>
<version>4.1.117.Final</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,14 @@ <H3>QuickFIX Settings</H3>
N</TD>
<TD>Y</TD>
</TR>
<TR ALIGN="left" VALIGN="middle">
<TD><I>FirstFieldInGroupIsDelimiter</I></TD>
<TD>Session validation setting for enabling whether first found field in repeating group will be used as
delimiter. Values are "Y" or "N". Default is "N". ValidateUnorderedGroupFields should be set to "N"</TD>
<TD>Y<br>
N</TD>
<TD>N</TD>
</TR>
<TR ALIGN="left" VALIGN="middle">
<TD><I>ValidateIncomingMessage</I></TD>
<TD>Allow to bypass the message validation (against the dictionary). Default is "Y".</TD>
Expand Down
12 changes: 6 additions & 6 deletions quickfixj-core/src/main/java/quickfix/CompositeLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public void clear() {
for (Log log : logs) {
try {
log.clear();
} catch (Throwable e) {
} catch (Exception e) {
handleError(e);
}
}
}

private void handleError(Throwable e) {
private void handleError(Exception e) {
if (rethrowException) {
throw new RuntimeException(e);
}
Expand All @@ -57,7 +57,7 @@ public void onIncoming(String message) {
for (Log log : logs) {
try {
log.onIncoming(message);
} catch (Throwable e) {
} catch (Exception e) {
handleError(e);
}
}
Expand All @@ -67,7 +67,7 @@ public void onOutgoing(String message) {
for (Log log : logs) {
try {
log.onOutgoing(message);
} catch (Throwable e) {
} catch (Exception e) {
defaultLog.error(e.getMessage() + ", continuing", e);
}
}
Expand All @@ -77,7 +77,7 @@ public void onEvent(String text) {
for (Log log : logs) {
try {
log.onEvent(text);
} catch (Throwable e) {
} catch (Exception e) {
handleError(e);
}
}
Expand All @@ -87,7 +87,7 @@ public void onErrorEvent(String text) {
for (Log log : logs) {
try {
log.onErrorEvent(text);
} catch (Throwable e) {
} catch (Exception e) {
handleError(e);
}
}
Expand Down
49 changes: 27 additions & 22 deletions quickfixj-core/src/main/java/quickfix/DefaultSessionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import org.quickfixj.QFJException;
import org.quickfixj.SimpleCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import quickfix.field.ApplVerID;
import quickfix.field.DefaultApplVerID;

Expand All @@ -37,7 +39,8 @@
* initiators) for creating sessions.
*/
public class DefaultSessionFactory implements SessionFactory {
private static final SimpleCache<String, DataDictionary> dictionaryCache = new SimpleCache<>(path -> {
private static final Logger LOG = LoggerFactory.getLogger(DefaultSessionFactory.class);
private static final SimpleCache<String, DataDictionary> DICTIONARY_CACHE = new SimpleCache<>(path -> {
try {
return new DataDictionary(path);
} catch (ConfigError e) {
Expand Down Expand Up @@ -289,34 +292,36 @@ private DataDictionary createDataDictionary(SessionID sessionID, SessionSettings
private ValidationSettings createValidationSettings(SessionID sessionID, SessionSettings settings) throws FieldConvertError, ConfigError {
ValidationSettings validationSettings = new ValidationSettings();

if (settings.isSetting(sessionID, Session.SETTING_VALIDATE_FIELDS_OUT_OF_ORDER)) {
validationSettings.setCheckFieldsOutOfOrder(settings.getBool(sessionID,
Session.SETTING_VALIDATE_FIELDS_OUT_OF_ORDER));
}
validationSettings.setCheckFieldsOutOfOrder(settings.getBoolOrDefault(sessionID,
Session.SETTING_VALIDATE_FIELDS_OUT_OF_ORDER, validationSettings.isCheckFieldsOutOfOrder()));

if (settings.isSetting(sessionID, Session.SETTING_VALIDATE_FIELDS_HAVE_VALUES)) {
validationSettings.setCheckFieldsHaveValues(settings.getBool(sessionID,
Session.SETTING_VALIDATE_FIELDS_HAVE_VALUES));
}
validationSettings.setCheckFieldsHaveValues(settings.getBoolOrDefault(sessionID,
Session.SETTING_VALIDATE_FIELDS_HAVE_VALUES, validationSettings.isCheckFieldsHaveValues()));

if (settings.isSetting(sessionID, Session.SETTING_VALIDATE_UNORDERED_GROUP_FIELDS)) {
validationSettings.setCheckUnorderedGroupFields(settings.getBool(sessionID,
Session.SETTING_VALIDATE_UNORDERED_GROUP_FIELDS));
}
validationSettings.setCheckUnorderedGroupFields(settings.getBoolOrDefault(sessionID,
Session.SETTING_VALIDATE_UNORDERED_GROUP_FIELDS, validationSettings.isCheckUnorderedGroupFields()));

if (settings.isSetting(sessionID, Session.SETTING_VALIDATE_USER_DEFINED_FIELDS)) {
validationSettings.setCheckUserDefinedFields(settings.getBool(sessionID,
Session.SETTING_VALIDATE_USER_DEFINED_FIELDS));
}
validationSettings.setCheckUserDefinedFields(settings.getBoolOrDefault(sessionID,
Session.SETTING_VALIDATE_USER_DEFINED_FIELDS, validationSettings.isCheckUserDefinedFields()));

if (settings.isSetting(sessionID, Session.SETTING_ALLOW_UNKNOWN_MSG_FIELDS)) {
validationSettings.setAllowUnknownMessageFields(settings.getBool(sessionID,
Session.SETTING_ALLOW_UNKNOWN_MSG_FIELDS));
}
validationSettings.setAllowUnknownMessageFields(settings.getBoolOrDefault(sessionID,
Session.SETTING_ALLOW_UNKNOWN_MSG_FIELDS, validationSettings.isAllowUnknownMessageFields()));

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

validateValidationSettings(validationSettings);

return validationSettings;
}

private void validateValidationSettings(ValidationSettings validationSettings) {
if (validationSettings.isFirstFieldInGroupIsDelimiter() && validationSettings.isCheckUnorderedGroupFields()) {
LOG.warn("Setting " + Session.SETTING_FIRST_FIELD_IN_GROUP_IS_DELIMITER
+ " requires " + Session.SETTING_VALIDATE_UNORDERED_GROUP_FIELDS + " to be set to false");
}
}

private void processFixtDataDictionaries(SessionID sessionID, SessionSettings settings,
DefaultDataDictionaryProvider dataDictionaryProvider) throws ConfigError,
FieldConvertError {
Expand Down Expand Up @@ -384,7 +389,7 @@ private String toDictionaryPath(String beginString) {

private DataDictionary getDataDictionary(String path) throws ConfigError {
try {
return dictionaryCache.computeIfAbsent(path);
return DICTIONARY_CACHE.computeIfAbsent(path);
} catch (QFJException e) {
final Throwable cause = e.getCause();
if (cause instanceof ConfigError) {
Expand Down
6 changes: 6 additions & 0 deletions quickfixj-core/src/main/java/quickfix/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ public class Session implements Closeable {
*/
public static final String SETTING_VALIDATE_UNORDERED_GROUP_FIELDS = "ValidateUnorderedGroupFields";

/**
* Session validation setting for enabling whether first found field in repeating group will be used as
* delimiter. Values are "Y" or "N". Default is "N".
*/
public static final String SETTING_FIRST_FIELD_IN_GROUP_IS_DELIMITER = "FirstFieldInGroupIsDelimiter";

/**
* Session validation setting for enabling whether field values are
* validated. Empty fields values are not allowed. Values are "Y" or "N".
Expand Down
35 changes: 0 additions & 35 deletions quickfixj-core/src/main/java/quickfix/mina/CustomSslFilter.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import quickfix.SessionID;
import quickfix.SessionSettings;
import quickfix.mina.CompositeIoFilterChainBuilder;
import quickfix.mina.CustomSslFilter;
import quickfix.mina.EventHandlingStrategy;
import quickfix.mina.NetworkingOptions;
import quickfix.mina.ProtocolFactory;
Expand Down Expand Up @@ -135,7 +134,7 @@ private void installSSL(AcceptorSocketDescriptor descriptor,
log.info("Installing SSL filter for {}", descriptor.getAddress());
SSLConfig sslConfig = descriptor.getSslConfig();
SSLContext sslContext = SSLContextFactory.getInstance(sslConfig);
SslFilter sslFilter = new CustomSslFilter(sslContext);
SslFilter sslFilter = new SslFilter(sslContext);
sslFilter.setNeedClientAuth(sslConfig.isNeedClientAuth());
sslFilter.setEnabledCipherSuites(sslConfig.getEnabledCipherSuites() != null ? sslConfig.getEnabledCipherSuites()
: SSLSupport.getDefaultCipherSuites(sslContext));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import quickfix.SessionSettings;
import quickfix.SystemTime;
import quickfix.mina.CompositeIoFilterChainBuilder;
import quickfix.mina.CustomSslFilter;
import quickfix.mina.EventHandlingStrategy;
import quickfix.mina.NetworkingOptions;
import quickfix.mina.ProtocolFactory;
Expand Down Expand Up @@ -159,9 +158,8 @@ private void setupIoConnector() throws ConfigError, GeneralSecurityException {

boolean hasProxy = proxyType != null && proxyPort > 0 && socketAddresses[nextSocketAddressIndex] instanceof InetSocketAddress;

SslFilter sslFilter = null;
if (sslEnabled) {
sslFilter = installSslFilter(ioFilterChainBuilder);
installSslFilter(ioFilterChainBuilder);
}

ioFilterChainBuilder.addLast(FIXProtocolCodecFactory.FILTER_NAME, new ProtocolCodecFilter(new FIXProtocolCodecFactory()));
Expand Down Expand Up @@ -192,17 +190,16 @@ private void setupIoConnector() throws ConfigError, GeneralSecurityException {
ioConnector = newConnector;
}

private SslFilter installSslFilter(CompositeIoFilterChainBuilder ioFilterChainBuilder)
private void installSslFilter(CompositeIoFilterChainBuilder ioFilterChainBuilder)
throws GeneralSecurityException {
final SSLContext sslContext = SSLContextFactory.getInstance(sslConfig);
final SslFilter sslFilter = new CustomSslFilter(sslContext, false);
final SslFilter sslFilter = new SslFilter(sslContext, false);
sslFilter.setEnabledCipherSuites(sslConfig.getEnabledCipherSuites() != null ? sslConfig.getEnabledCipherSuites()
: SSLSupport.getDefaultCipherSuites(sslContext));
sslFilter.setEnabledProtocols(sslConfig.getEnabledProtocols() != null ? sslConfig.getEnabledProtocols()
: SSLSupport.getSupportedProtocols(sslContext));
sslFilter.setEndpointIdentificationAlgorithm(sslConfig.getEndpointIdentificationAlgorithm());
ioFilterChainBuilder.addLast(SSLSupport.FILTER_NAME, sslFilter);
return sslFilter;
}

@Override
Expand Down
Loading

0 comments on commit 30c4312

Please sign in to comment.