Skip to content

Commit

Permalink
Incorrect implementation of tuple factory method - fixes eclipse-vert…
Browse files Browse the repository at this point in the history
…x#400

Signed-off-by: Jeoffrey Lim <jeoffreyl@gmail.com>
  • Loading branch information
vietj committed Aug 24, 2019
1 parent 7a2766f commit 96317d1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
7 changes: 4 additions & 3 deletions vertx-sql-client/src/main/java/io/vertx/sqlclient/Tuple.java
Expand Up @@ -195,14 +195,15 @@ static Tuple of(Object elt1, Object... elts) {
}

/**
* Create a tuple of six elements.
* Create a tuple with the provided {@code elements} list.
* <p/>
* The {@code elements} list is not modified.
*
* @param elements the list of elements
* @return the tuple
*/
static Tuple tuple(List<Object> elements) {
ArrayTuple tuple = new ArrayTuple(5);
return tuple;
return new ArrayTuple(elements);
}

/**
Expand Down
Expand Up @@ -39,7 +39,7 @@ public class TupleTest {

enum TupleKind {

DEFAULT() {
ELEMENTS() {
@Override
Tuple tuple() {
return Tuple.tuple();
Expand All @@ -52,6 +52,19 @@ Tuple of(Object... elements) {
}
return Tuple.of(elements[0], Arrays.copyOfRange(elements, 1, elements.length));
}
},LIST() {
@Override
Tuple tuple() {
return Tuple.tuple();
}

@Override
Tuple of(Object... elements) {
if (elements.length == 0) {
throw new IllegalArgumentException();
}
return Tuple.tuple(Arrays.asList(elements));
}
}, WRAP_LIST() {
@Override
Tuple tuple() {
Expand Down Expand Up @@ -85,8 +98,10 @@ Tuple of(Object... elements) {
@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{ TupleKind.DEFAULT },
{ TupleKind.WRAP_LIST}
{ TupleKind.ELEMENTS},
{ TupleKind.LIST},
{ TupleKind.WRAP_LIST},
{ TupleKind.WRAP_ARRAY}
});
}

Expand Down

0 comments on commit 96317d1

Please sign in to comment.