You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by dl...@apache.org on 2016/06/14 18:21:37 UTC
[1/2] accumulo git commit: ACCUMULO-4344: PortRange.parse with throw
an error instead of fixing an invalid range
Repository: accumulo
Updated Branches:
refs/heads/master c521cf810 -> 2b5b54bec
ACCUMULO-4344: PortRange.parse with throw an error instead of fixing an invalid range
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/08d279f5
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/08d279f5
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/08d279f5
Branch: refs/heads/master
Commit: 08d279f530920afecffbaee816cbac470074f561
Parents: 7f8f66d
Author: Dave Marion <dl...@apache.org>
Authored: Tue Jun 14 14:20:21 2016 -0400
Committer: Dave Marion <dl...@apache.org>
Committed: Tue Jun 14 14:20:21 2016 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/core/conf/PropertyType.java | 11 ++++-------
.../accumulo/core/conf/AccumuloConfigurationTest.java | 4 ++--
2 files changed, 6 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/08d279f5/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java b/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java
index f08ab5b..6733fc6 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java
@@ -25,6 +25,7 @@ import java.util.regex.Pattern;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.util.Pair;
+import org.apache.commons.lang.math.IntRange;
import org.apache.hadoop.fs.Path;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -270,6 +271,7 @@ public enum PropertyType {
public static class PortRange extends Matches {
private static final Logger log = LoggerFactory.getLogger(PortRange.class);
+ private static final IntRange VALID_RANGE = new IntRange(1024, 65535);
public PortRange(final String pattern) {
super(pattern);
@@ -293,14 +295,9 @@ public enum PropertyType {
int idx = portRange.indexOf('-');
if (idx != -1) {
int low = Integer.parseInt(portRange.substring(0, idx));
- if (low < 1024) {
- log.error("Invalid port number for low end of the range, using 1024");
- low = 1024;
- }
int high = Integer.parseInt(portRange.substring(idx + 1));
- if (high > 65535) {
- log.error("Invalid port number for high end of the range, using 65535");
- high = 65535;
+ if (!VALID_RANGE.containsInteger(low) || !VALID_RANGE.containsInteger(high) || !(low <= high)) {
+ throw new IllegalArgumentException("Invalid port range specified, only 1024 to 65535 supported.");
}
return new Pair<Integer,Integer>(low, high);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/08d279f5/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java
index 61186bd..f12ba63 100644
--- a/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java
@@ -115,7 +115,7 @@ public class AccumuloConfigurationTest {
assertEquals(9999, ports[2]);
}
- @Test
+ @Test(expected = IllegalArgumentException.class)
public void testGetPortRangeInvalidLow() {
AccumuloConfiguration c = AccumuloConfiguration.getDefaultConfiguration();
ConfigurationCopy cc = new ConfigurationCopy(c);
@@ -127,7 +127,7 @@ public class AccumuloConfigurationTest {
assertEquals(1026, ports[2]);
}
- @Test
+ @Test(expected = IllegalArgumentException.class)
public void testGetPortRangeInvalidHigh() {
AccumuloConfiguration c = AccumuloConfiguration.getDefaultConfiguration();
ConfigurationCopy cc = new ConfigurationCopy(c);
[2/2] accumulo git commit: Merge branch '1.8'
Posted by dl...@apache.org.
Merge branch '1.8'
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/2b5b54be
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/2b5b54be
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/2b5b54be
Branch: refs/heads/master
Commit: 2b5b54bec3de245b3e895ee8ffafeb141f77df46
Parents: c521cf8 08d279f
Author: Dave Marion <dl...@apache.org>
Authored: Tue Jun 14 14:21:02 2016 -0400
Committer: Dave Marion <dl...@apache.org>
Committed: Tue Jun 14 14:21:02 2016 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/core/conf/PropertyType.java | 11 ++++-------
.../accumulo/core/conf/AccumuloConfigurationTest.java | 4 ++--
2 files changed, 6 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/2b5b54be/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java
----------------------------------------------------------------------