Skip to content
Permalink
Browse files
IGNITE-16450 Fix the build on Java 17
  • Loading branch information
rpuch authored and SammyVimes committed Feb 4, 2022
1 parent 6f171d6 commit 916a007a5a907e4084dff7db028750eee1084c09
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 27 deletions.
@@ -111,8 +111,15 @@ public RunningNode start(
var cmdArgs = new ArrayList<String>();

cmdArgs.add("java");
cmdArgs.add("--add-opens");
cmdArgs.add("java.base/jdk.internal.misc=ALL-UNNAMED");

addAddOpens(cmdArgs, "java.base/java.lang=ALL-UNNAMED");
addAddOpens(cmdArgs, "java.base/java.lang.invoke=ALL-UNNAMED");
addAddOpens(cmdArgs, "java.base/java.lang.reflect=ALL-UNNAMED");
addAddOpens(cmdArgs, "java.base/java.io=ALL-UNNAMED");
addAddOpens(cmdArgs, "java.base/java.nio=ALL-UNNAMED");
addAddOpens(cmdArgs, "java.base/java.util=ALL-UNNAMED");
addAddOpens(cmdArgs, "java.base/jdk.internal.misc=ALL-UNNAMED");

cmdArgs.add("-Dio.netty.tryReflectionSetAccessible=true");

if (javaLogProps != null) {
@@ -158,6 +165,11 @@ public RunningNode start(
}
}

private void addAddOpens(ArrayList<String> cmdArgs, String addOpens) {
cmdArgs.add("--add-opens");
cmdArgs.add(addOpens);
}

/**
* Waits for node start by checking node logs in cycle.
*
@@ -17,6 +17,7 @@

package org.apache.ignite.client;

import static java.time.temporal.ChronoField.NANO_OF_SECOND;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -126,8 +127,8 @@ public void testAllColumnsBinaryPutPojoGet() {
assertEquals(1.5f, res.zfloat);
assertEquals(1.6, res.zdouble);
assertEquals(localDate, res.zdate);
assertEquals(localTime, res.ztime);
assertEquals(instant, res.ztimestamp);
assertEquals(localTime.withNano(truncateNanosToMicros(localTime.getNano())), res.ztime);
assertEquals(instant.with(NANO_OF_SECOND, truncateNanosToMicros(instant.getNano())), res.ztimestamp);
assertEquals("foo", res.zstring);
assertArrayEquals(new byte[]{1, 2}, res.zbytes);
assertEquals(BitSet.valueOf(new byte[]{32}), res.zbitmask);
@@ -136,6 +137,10 @@ public void testAllColumnsBinaryPutPojoGet() {
assertEquals(uuid, res.zuuid);
}

private int truncateNanosToMicros(int nanos) {
return nanos / 1000 * 1000;
}

@Test
public void testAllColumnsPojoPutBinaryGet() {
Table table = fullTable();
@@ -177,8 +182,8 @@ public void testAllColumnsPojoPutBinaryGet() {
assertEquals(1.17f, res.floatValue("zfloat"));
assertEquals(1.18, res.doubleValue("zdouble"));
assertEquals(localDate, res.dateValue("zdate"));
assertEquals(localTime, res.timeValue("ztime"));
assertEquals(instant, res.timestampValue("ztimestamp"));
assertEquals(localTime.withNano(truncateNanosToMicros(localTime.getNano())), res.timeValue("ztime"));
assertEquals(instant.with(NANO_OF_SECOND, truncateNanosToMicros(instant.getNano())), res.timestampValue("ztimestamp"));
assertEquals("119", res.stringValue("zstring"));
assertEquals(120, ((byte[]) res.value("zbytes"))[0]);
assertEquals(BitSet.valueOf(new byte[]{121}), res.bitmaskValue("zbitmask"));
@@ -17,6 +17,7 @@

package org.apache.ignite.client;

import static java.time.temporal.ChronoField.NANO_OF_SECOND;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -126,8 +127,8 @@ public void testAllColumnsBinaryPutPojoGet() {
assertEquals(1.5f, res.zfloat);
assertEquals(1.6, res.zdouble);
assertEquals(localDate, res.zdate);
assertEquals(localTime, res.ztime);
assertEquals(instant, res.ztimestamp);
assertEquals(localTime.withNano(truncateNanosToMicros(localTime.getNano())), res.ztime);
assertEquals(instant.with(NANO_OF_SECOND, truncateNanosToMicros(instant.getNano())), res.ztimestamp);
assertEquals("foo", res.zstring);
assertArrayEquals(new byte[]{1, 2}, res.zbytes);
assertEquals(BitSet.valueOf(new byte[]{32}), res.zbitmask);
@@ -136,6 +137,10 @@ public void testAllColumnsBinaryPutPojoGet() {
assertEquals(uuid, res.zuuid);
}

private int truncateNanosToMicros(int nanos) {
return nanos / 1000 * 1000;
}

@Test
public void testAllColumnsPojoPutBinaryGet() {
Table table = fullTable();
@@ -175,8 +180,8 @@ public void testAllColumnsPojoPutBinaryGet() {
assertEquals(1.17f, res.floatValue("zfloat"));
assertEquals(1.18, res.doubleValue("zdouble"));
assertEquals(localDate, res.dateValue("zdate"));
assertEquals(localTime, res.timeValue("ztime"));
assertEquals(instant, res.timestampValue("ztimestamp"));
assertEquals(localTime.withNano(truncateNanosToMicros(localTime.getNano())), res.timeValue("ztime"));
assertEquals(instant.with(NANO_OF_SECOND, truncateNanosToMicros(instant.getNano())), res.timestampValue("ztimestamp"));
assertEquals("119", res.stringValue("zstring"));
assertEquals(120, ((byte[]) res.value("zbytes"))[0]);
assertEquals(BitSet.valueOf(new byte[]{121}), res.bitmaskValue("zbitmask"));
@@ -17,6 +17,7 @@

package org.apache.ignite.internal.table;

import static java.time.temporal.ChronoField.NANO_OF_SECOND;
import static org.apache.ignite.internal.schema.NativeTypes.BYTES;
import static org.apache.ignite.internal.schema.NativeTypes.DATE;
import static org.apache.ignite.internal.schema.NativeTypes.DOUBLE;
@@ -47,6 +48,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.temporal.Temporal;
import java.util.BitSet;
import java.util.Random;
import java.util.UUID;
@@ -61,7 +63,9 @@
import org.apache.ignite.internal.schema.row.Row;
import org.apache.ignite.internal.table.impl.DummySchemaManagerImpl;
import org.apache.ignite.internal.testframework.IgniteTestUtils;
import org.apache.ignite.schema.definition.ColumnType;
import org.apache.ignite.table.Tuple;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;

/**
@@ -70,15 +74,17 @@
* <p>Should be in sync with org.apache.ignite.client.ClientTupleBuilderTest.
*/
public class MutableRowTupleAdapterTest {
private static final int NANOS_IN_SECOND = 9;

/** Schema descriptor. */
private SchemaDescriptor schema = new SchemaDescriptor(
private final SchemaDescriptor schema = new SchemaDescriptor(
42,
new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
new Column[]{new Column("name".toUpperCase(), NativeTypes.STRING, true)}
);

/** Schema descriptor. */
private SchemaDescriptor fullSchema = new SchemaDescriptor(42,
private final SchemaDescriptor fullSchema = new SchemaDescriptor(42,
new Column[]{new Column("keyUuidCol".toUpperCase(), NativeTypes.UUID, true)},
new Column[]{
new Column("valByteCol".toUpperCase(), INT8, true),
@@ -354,9 +360,9 @@ public void testVariousColumnTypes() throws TupleMarshallerException {
.set("valDoubleCol", 0.066d)
.set("keyUuidCol", UUID.randomUUID())
.set("valDateCol", LocalDate.now())
.set("valDateTimeCol", LocalDateTime.now())
.set("valTimeCol", LocalTime.now())
.set("valTimeStampCol", Instant.now())
.set("valDateTimeCol", truncatedLocalDateTimeNow())
.set("valTimeCol", truncatedLocalTimeNow())
.set("valTimeStampCol", truncatedInstantNow())
.set("valBitmask1Col", randomBitSet(rnd, 12))
.set("valBytesCol", IgniteTestUtils.randomBytes(rnd, 13))
.set("valStringCol", IgniteTestUtils.randomString(rnd, 14))
@@ -386,9 +392,9 @@ public void testSerialization() throws Exception {
.set("valDoubleCol", 0.066d)
.set("keyUuidCol", UUID.randomUUID())
.set("valDateCol", LocalDate.now())
.set("valDateTimeCol", LocalDateTime.now())
.set("valTimeCol", LocalTime.now())
.set("valTimeStampCol", Instant.now())
.set("valDateTimeCol", truncatedLocalDateTimeNow())
.set("valTimeCol", truncatedLocalTimeNow())
.set("valTimeStampCol", truncatedInstantNow())
.set("valBitmask1Col", randomBitSet(rnd, 12))
.set("valBytesCol", IgniteTestUtils.randomBytes(rnd, 13))
.set("valStringCol", IgniteTestUtils.randomString(rnd, 14))
@@ -405,6 +411,19 @@ public void testSerialization() throws Exception {
assertEquals(tup2, tup1);
}

private Instant truncatedInstantNow() {
return truncateToDefaultPrecision(Instant.now());
}

private LocalTime truncatedLocalTimeNow() {
return truncateToDefaultPrecision(LocalTime.now());
}

@NotNull
private LocalDateTime truncatedLocalDateTimeNow() {
return truncateToDefaultPrecision(LocalDateTime.now());
}

@Test
public void testTupleEquality() throws Exception {
Random rnd = new Random();
@@ -418,9 +437,9 @@ public void testTupleEquality() throws Exception {
.set("valFloatCol", 0.055f)
.set("valDoubleCol", 0.066d)
.set("valDateCol", LocalDate.now())
.set("valDateTimeCol", LocalDateTime.now())
.set("valTimeCol", LocalTime.now())
.set("valTimeStampCol", Instant.now())
.set("valDateTimeCol", truncatedLocalDateTimeNow())
.set("valTimeCol", truncatedLocalTimeNow())
.set("valTimeStampCol", truncatedInstantNow())
.set("valBitmask1Col", randomBitSet(rnd, 12))
.set("valBytesCol", IgniteTestUtils.randomBytes(rnd, 13))
.set("valStringCol", IgniteTestUtils.randomString(rnd, 14))
@@ -504,9 +523,9 @@ public void testKeyValueSerialization() throws Exception {
.set("valFloatCol", 0.055f)
.set("valDoubleCol", 0.066d)
.set("valDateCol", LocalDate.now())
.set("valDateTimeCol", LocalDateTime.now())
.set("valTimeCol", LocalTime.now())
.set("valTimeStampCol", Instant.now())
.set("valDateTimeCol", truncatedLocalDateTimeNow())
.set("valTimeCol", truncatedLocalTimeNow())
.set("valTimeStampCol", truncatedInstantNow())
.set("valBitmask1Col", randomBitSet(rnd, 12))
.set("valBytesCol", IgniteTestUtils.randomBytes(rnd, 13))
.set("valStringCol", IgniteTestUtils.randomString(rnd, 14))
@@ -524,6 +543,28 @@ public void testKeyValueSerialization() throws Exception {
assertEquals(val1, val2);
}

@SuppressWarnings("unchecked")
private <T extends Temporal> T truncateToDefaultPrecision(T temporal) {
return (T) temporal.with(NANO_OF_SECOND, truncateToDefaultPrecision(temporal.get(NANO_OF_SECOND)));
}

private int truncateToDefaultPrecision(int nanos) {
int factor = tailFactorForDefaultPrecision();
return nanos / factor * factor;
}

private int tailFactorForDefaultPrecision() {
return tailFactor(ColumnType.TemporalColumnType.DEFAULT_PRECISION);
}

private int tailFactor(int precision) {
if (precision >= NANOS_IN_SECOND) {
return 1;
}

return new BigInteger("10").pow(NANOS_IN_SECOND - precision).intValue();
}

/**
* Deserializes tuple.
*
@@ -61,8 +61,8 @@
<junit.version>5.8.1</junit.version>
<micronaut.version>2.1.2</micronaut.version>
<micronaut.test.junit5.version>2.3.1</micronaut.test.junit5.version>
<mockito.framework.version>3.8.0</mockito.framework.version>
<mockito.junit.jupiter.version>3.3.3</mockito.junit.jupiter.version>
<mockito.framework.version>4.3.1</mockito.framework.version>
<mockito.junit.jupiter.version>4.3.1</mockito.junit.jupiter.version>
<picocli.version>4.5.2</picocli.version>
<slf4j.version>1.7.32</slf4j.version>
<spoon.framework.version>8.4.0-beta-18</spoon.framework.version>
@@ -91,7 +91,7 @@
<!-- Plugins versions -->
<apache.rat.plugin.version>0.13</apache.rat.plugin.version>
<checkstyle.puppycrawl.version>8.45</checkstyle.puppycrawl.version>
<launch.maven.plugin.version>1.7.25</launch.maven.plugin.version>
<launch.maven.plugin.version>2.1.2</launch.maven.plugin.version>
<maven.antrun.plugin.version>3.0.0</maven.antrun.plugin.version>
<maven.assembly.plugin.version>3.2.0</maven.assembly.plugin.version>
<maven.build-helper.plugin.version>3.2.0</maven.build-helper.plugin.version>
@@ -1033,6 +1033,12 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.lang.invoke=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED
-Dio.netty.tryReflectionSetAccessible=true
-Djava.util.logging.config.file=../../config/java.util.logging.properties
@@ -1053,6 +1059,12 @@
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.lang.invoke=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED
-Dio.netty.tryReflectionSetAccessible=true
-Djava.util.logging.config.file=../../config/java.util.logging.properties

0 comments on commit 916a007

Please sign in to comment.