Skip to content

Commit 4b9d617

Browse files
committed
ESDK-2570: Setting a blank userName on an EMA OmmConsumer or OmmNIProvider configuration will now result in an InvalidUsageException. The Performance tools have been updated to reflect this change.
1 parent 01f1e95 commit 4b9d617

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

Java/Ema/Core/src/main/java/com/thomsonreuters/ema/access/EmaConfigImpl.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ abstract class EmaConfigBaseImpl
4444
protected ProgrammaticConfigure _programmaticConfigure;
4545

4646
private OmmInvalidConfigurationExceptionImpl _oommICExcept;
47+
private OmmInvalidUsageExceptionImpl _ommIUExcept;
4748

4849
protected StringBuilder _configStrBuilder;
4950
protected String _configSessionName = null;
@@ -71,6 +72,15 @@ protected OmmInvalidConfigurationExceptionImpl oommICExcept()
7172
return _oommICExcept;
7273
}
7374

75+
protected OmmInvalidUsageExceptionImpl ommIUExcept()
76+
{
77+
if (_ommIUExcept == null)
78+
_ommIUExcept = new OmmInvalidUsageExceptionImpl();
79+
80+
return _ommIUExcept;
81+
}
82+
83+
7484
protected StringBuilder configStrBuilder()
7585
{
7686
if (_configStrBuilder == null)
@@ -183,6 +193,12 @@ protected void clearInt()
183193

184194
protected void usernameInt(String username)
185195
{
196+
if(username == null || username.length() == 0)
197+
{
198+
configStrBuilder().append("EmaConfigImpl:UserName input String cannot be blank.");
199+
throw ( ommIUExcept().message( _configStrBuilder.toString()));
200+
}
201+
186202
_rsslLoginReq.userName().data(username);
187203
}
188204

Java/Ema/PerfTools/src/main/java/com/thomsonreuters/ema/perftools/emajconsperf/ConsumerThread.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.thomsonreuters.ema.access.GenericMsg;
1010
import com.thomsonreuters.ema.access.OmmConsumer;
1111
import com.thomsonreuters.ema.access.OmmConsumerClient;
12+
import com.thomsonreuters.ema.access.OmmConsumerConfig;
1213
import com.thomsonreuters.ema.access.OmmConsumerEvent;
1314
import com.thomsonreuters.ema.access.OmmState;
1415
import com.thomsonreuters.ema.access.ReqMsg;
@@ -57,6 +58,7 @@ public class ConsumerThread implements Runnable, OmmConsumerClient
5758
protected LatencyRandomArray _genMsgLatencyRandomArray; /* generic msg random latency array */
5859
private int _JVMPrimingRefreshCount; /* used to determine when JVM priming is complete */
5960
private OmmConsumer _consumer;
61+
private OmmConsumerConfig _ommConfig;
6062
private long _itemHandle;
6163

6264
{
@@ -165,10 +167,24 @@ protected void initialize()
165167

166168
protected void initializeOmmConsumer()
167169
{
168-
if (_consPerfConfig.useUserDispatch())
169-
_consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().username(_consPerfConfig.username()).operationModel(OperationModel.USER_DISPATCH));
170-
else
171-
_consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().username(_consPerfConfig.username()).operationModel(OperationModel.API_DISPATCH));
170+
try
171+
{
172+
_ommConfig = EmaFactory.createOmmConsumerConfig();
173+
// A blank user name is an invalid input to OmmConsumerConfig.username and will trigger an invalid usage exception.
174+
if(_consPerfConfig.username().length() != 0)
175+
_ommConfig.username(_consPerfConfig.username());
176+
177+
if(_consPerfConfig.useUserDispatch())
178+
_ommConfig.operationModel(OperationModel.USER_DISPATCH);
179+
else
180+
_ommConfig.operationModel(OperationModel.API_DISPATCH);
181+
182+
_consumer = EmaFactory.createOmmConsumer(_ommConfig);
183+
}
184+
catch(Exception e)
185+
{
186+
System.out.println("Exception found"+e);
187+
}
172188

173189
_srcDirHandler.serviceName(_consPerfConfig.serviceName());
174190
long directoryHandle = _consumer.registerClient(_srcDirHandler.getRequest(), _srcDirHandler);

0 commit comments

Comments
 (0)