Index: hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RegexStringComparator.java =================================================================== --- hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RegexStringComparator.java (revision 1520083) +++ hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RegexStringComparator.java (working copy) @@ -30,6 +30,7 @@ import java.nio.charset.Charset; import java.nio.charset.IllegalCharsetNameException; +import java.util.Arrays; import java.util.regex.Pattern; /** @@ -108,10 +109,12 @@ @Override public int compareTo(byte[] value, int offset, int length) { + // See HBASE-9428. Make a copy of the relevant part of the byte[], + // or the JDK will copy the entire byte[] during String decode + byte[] tmp = Arrays.copyOfRange(value, offset, offset+length); // Use find() for subsequence match instead of matches() (full sequence // match) to adhere to the principle of least surprise. - return pattern.matcher(new String(value, offset, length, charset)).find() ? 0 - : 1; + return pattern.matcher(new String(tmp, charset)).find() ? 0 : 1; } /**