diff --git a/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElement.java b/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElement.java index be345eeb0dc..8ac0f22844c 100644 --- a/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElement.java +++ b/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElement.java @@ -18,6 +18,8 @@ package org.apache.jmeter.protocol.mongodb.config; +import java.net.UnknownHostException; + import org.apache.jmeter.config.ConfigElement; import org.apache.jmeter.protocol.mongodb.mongo.MongoDB; import org.apache.jmeter.protocol.mongodb.mongo.MongoUtils; @@ -240,7 +242,11 @@ public void testStarted() { if(log.isDebugEnabled()) { log.debug(getSource() + " is being defined."); } - getThreadContext().getVariables().putObject(getSource(), new MongoDB(MongoUtils.toServerAddresses(getConnection()), mongoOptions)); + try { + getThreadContext().getVariables().putObject(getSource(), new MongoDB(MongoUtils.toServerAddresses(getConnection()), mongoOptions)); + } catch (UnknownHostException e) { + throw new IllegalStateException(e); + } } } diff --git a/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoUtils.java b/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoUtils.java index 409002cfaac..1da3cc644c7 100644 --- a/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoUtils.java +++ b/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoUtils.java @@ -21,9 +21,7 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; - -import org.apache.jorphan.logging.LoggingManager; -import org.apache.log.Logger; +import java.util.List; import com.mongodb.ServerAddress; @@ -31,25 +29,16 @@ */ public class MongoUtils { - private static final Logger log = LoggingManager.getLoggerForClass(); - - public static ArrayList toServerAddresses(String connections) { + public static List toServerAddresses(String connections) throws UnknownHostException { - ArrayList addresses = new ArrayList(); - try { - for(String connection : Arrays.asList(connections.split(","))) { - int port = 27017; - String[] hostPort = connection.split(":"); - if(hostPort.length > 1 && hostPort[1] != null) { - port = Integer.parseInt(hostPort[1].trim()); - } - addresses.add(new ServerAddress(hostPort[0], port)); - } - } - catch(UnknownHostException uhe) { - if(log.isWarnEnabled()) { - log.warn("", uhe); + List addresses = new ArrayList(); + for(String connection : Arrays.asList(connections.split(","))) { + int port = 27017; + String[] hostPort = connection.split(":"); + if(hostPort.length > 1 && hostPort[1] != null) { + port = Integer.parseInt(hostPort[1].trim()); } + addresses.add(new ServerAddress(hostPort[0], port)); } return addresses; }