Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error compare method in IT framework #12592

Merged
merged 1 commit into from
May 27, 2024
Merged
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 @@ -79,13 +79,37 @@ public final T requestAllAndCompare() throws SQLException {
T data = results.get(0);
for (int i = 1; i < results.size(); i++) {
T anotherData = results.get(i);
if (!Objects.equals(data, anotherData)) {
if (!compare(data, anotherData)) {
throw new InconsistentDataException(results, endpoints);
}
}
return data;
}

private boolean compare(T data, T anotherData) {
if (data instanceof byte[] && anotherData instanceof byte[]) {
return Arrays.equals((byte[]) data, (byte[]) anotherData);
} else if (data instanceof short[] && anotherData instanceof short[]) {
return Arrays.equals((short[]) data, (short[]) anotherData);
} else if (data instanceof int[] && anotherData instanceof int[]) {
return Arrays.equals((int[]) data, (int[]) anotherData);
} else if (data instanceof long[] && anotherData instanceof long[]) {
return Arrays.equals((long[]) data, (long[]) anotherData);
} else if (data instanceof char[] && anotherData instanceof char[]) {
return Arrays.equals((char[]) data, (char[]) anotherData);
} else if (data instanceof float[] && anotherData instanceof float[]) {
return Arrays.equals((float[]) data, (float[]) anotherData);
} else if (data instanceof double[] && anotherData instanceof double[]) {
return Arrays.equals((double[]) data, (double[]) anotherData);
} else if (data instanceof boolean[] && anotherData instanceof boolean[]) {
return Arrays.equals((boolean[]) data, (boolean[]) anotherData);
} else if (data instanceof Object[] && anotherData instanceof Object[]) {
return Arrays.equals((Object[]) data, (Object[]) anotherData);
} else {
return Objects.equals(data, anotherData);
}
}

protected void handleExceptions(Exception[] exceptions) throws SQLException {
if (exceptions.length == 0) {
return;
Expand Down
Loading