Permalink
Browse files

Bug 54584 - MongoDB plugin

Fix Exception
Bugzilla Id: 54584

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1451963 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent f09c40a commit 180293846f42dda6cb908b37818aaf46a394e948 @pmouawad pmouawad committed Mar 3, 2013
@@ -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);
+ }
}
}
@@ -21,35 +21,24 @@
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;
/**
*/
public class MongoUtils {
- private static final Logger log = LoggingManager.getLoggerForClass();
-
- public static ArrayList<ServerAddress> toServerAddresses(String connections) {
+ public static List<ServerAddress> toServerAddresses(String connections) throws UnknownHostException {
- ArrayList<ServerAddress> addresses = new ArrayList<ServerAddress>();
- 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<ServerAddress> addresses = new ArrayList<ServerAddress>();
+ 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;
}

0 comments on commit 1802938

Please sign in to comment.