Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

public class ElementMultiFlagsFilter extends ElementFlagFilter {

final static int MAX_EFLAGS = 100;
private ArrayList<byte[]> compValue = new ArrayList<>();
private static final int MAX_COMP_VALUE_COUNT = 100;
private final ArrayList<byte[]> compValue = new ArrayList<>();

public ElementMultiFlagsFilter() {
}
Expand Down Expand Up @@ -61,10 +61,10 @@ public ElementMultiFlagsFilter addCompValue(byte[] compValue) {
+ MAX_EFLAG_LENGTH);
}

if (this.compValue.size() > MAX_EFLAGS) {
if (this.compValue.size() >= MAX_COMP_VALUE_COUNT) {
throw new IllegalArgumentException(
"Count of comparison values must be less than "
+ MAX_EFLAGS);
"Count of comparison values must not exceed "
+ MAX_COMP_VALUE_COUNT);
}

if (!this.compValue.isEmpty()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package net.spy.memcached.collection;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertThrows;

class ElementMultiFlagsFilterTest {

@Test
void shouldRejectCompValueExceedingMaximumCount() {
ElementMultiFlagsFilter filter = new ElementMultiFlagsFilter();

for (int i = 0; i < 100; i++) {
filter.addCompValue(new byte[]{(byte) i});
}

assertThrows(IllegalArgumentException.class, () -> filter.addCompValue(new byte[]{0}));
}
}
Loading