Skip to content

Commit

Permalink
Merge pull request #1554 from koo-taejin/#1553
Browse files Browse the repository at this point in the history
allow whitespace for collector.l4.ip configuration in pinpoint-collec…
:+1:
  • Loading branch information
Xylus committed Feb 25, 2016
2 parents cb16eff + 634c8d7 commit c0460d1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Expand Up @@ -19,7 +19,6 @@
import com.navercorp.pinpoint.common.util.PropertyUtils;
import com.navercorp.pinpoint.common.util.SimpleProperty;
import com.navercorp.pinpoint.common.util.SystemProperty;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
Expand All @@ -28,7 +27,7 @@
import org.springframework.util.Assert;

import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
Expand Down Expand Up @@ -316,7 +315,12 @@ private void readPropertyValues(Properties properties) {
if (l4Ips == null) {
this.l4IpList = Collections.emptyList();
} else {
this.l4IpList = Arrays.asList(l4Ips);
this.l4IpList = new ArrayList<>(l4Ips.length);
for (String l4Ip : l4Ips) {
if (!StringUtils.isEmpty(l4Ip)) {
this.l4IpList.add(StringUtils.trim(l4Ip));
}
}
}

this.clusterEnable = readBoolean(properties, "cluster.enable");
Expand Down
Expand Up @@ -16,9 +16,11 @@

package com.navercorp.pinpoint.collector.config;

import org.junit.Assert;
import org.junit.Test;

import java.io.InputStream;
import java.util.Properties;

/**
* @author emeroad
Expand All @@ -30,4 +32,20 @@ public void testReadConfigFile() throws Exception {


}

@Test
public void l4IpTest() throws Exception {
Properties properties = new Properties();
properties.put("collector.l4.ip", "127.0.0.1 , 192.168.0.1, 255.255.255.255");

CollectorConfiguration collectorConfiguration = new CollectorConfiguration();
collectorConfiguration.setProperties(properties);

collectorConfiguration.afterPropertiesSet();

Assert.assertTrue(collectorConfiguration.getL4IpList().contains("127.0.0.1"));
Assert.assertTrue(collectorConfiguration.getL4IpList().contains("192.168.0.1"));
Assert.assertTrue(collectorConfiguration.getL4IpList().contains("255.255.255.255"));
}

}

0 comments on commit c0460d1

Please sign in to comment.