Skip to content

Conversation

@hezhangjian
Copy link
Member

@hezhangjian hezhangjian commented Apr 29, 2024

Motivation

In JDK21, it's is no way to change private static final variable currently, before figure out how to replace, disable it first

        Field logField = repp.getClass().getDeclaredField("LOG");
        Logger mockLogger = mock(Logger.class);
        Field modifiers = Field.class.getDeclaredField("modifiers");
        modifiers.setAccessible(true);
        modifiers.setInt(logField, logField.getModifiers() & ~Modifier.FINAL);

See also https://issues.apache.org/jira/browse/CASSANDRA-18181

Changes

  1. Added junit5 annotation @EnabledForJreRange(max = JRE.JAVA_17)(It's modern and better than junit4) to tests that use suspend and resume, effectively disabling these tests on JDK versions higher than 17 where these methods are not supported.
  2. BookieZKExpireTest should be annotated as junit5 test.
  3. Make BookKeeperClusterTestCase compatible to junit5.

…RegionAwareEnsemblePlacementPolicy beyond jdk11

Signed-off-by: ZhangJian He <shoothzj@gmail.com>
Signed-off-by: ZhangJian He <shoothzj@gmail.com>
@hezhangjian
Copy link
Member Author

Copy link
Member

@StevenLuMT StevenLuMT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hezhangjian hezhangjian merged commit b38b171 into apache:master May 5, 2024
@hezhangjian hezhangjian deleted the fix-jdk21-test branch May 5, 2024 23:27
@hangc0276 hangc0276 added this to the 4.18.0 milestone May 25, 2024
zhiheng123 pushed a commit to zhiheng123/bookkeeper that referenced this pull request Jun 5, 2024
…RegionAwareEnsemblePlacementPolicy beyond jdk11 (apache#4323)

### Motivation

In JDK21, it's is no way to change private static final variable currently, before figure out how to replace, disable it first

```
        Field logField = repp.getClass().getDeclaredField("LOG");
        Logger mockLogger = mock(Logger.class);
        Field modifiers = Field.class.getDeclaredField("modifiers");
        modifiers.setAccessible(true);
        modifiers.setInt(logField, logField.getModifiers() & ~Modifier.FINAL);
```

See also https://issues.apache.org/jira/browse/CASSANDRA-18181

### Changes

1. Added junit5 annotation `@EnabledForJreRange(max = JRE.JAVA_17)`(It's modern and better than junit4) to tests that use `suspend` and `resume`, effectively disabling these tests on JDK versions higher than 17 where these methods are not supported.
2. BookieZKExpireTest should be annotated as junit5 test.
3. Make `BookKeeperClusterTestCase` compatible to junit5.

Signed-off-by: ZhangJian He <shoothzj@gmail.com>
zhiheng123 pushed a commit to zhiheng123/bookkeeper that referenced this pull request Jun 7, 2024
…RegionAwareEnsemblePlacementPolicy beyond jdk11 (apache#4323)

### Motivation

In JDK21, it's is no way to change private static final variable currently, before figure out how to replace, disable it first

```
        Field logField = repp.getClass().getDeclaredField("LOG");
        Logger mockLogger = mock(Logger.class);
        Field modifiers = Field.class.getDeclaredField("modifiers");
        modifiers.setAccessible(true);
        modifiers.setInt(logField, logField.getModifiers() & ~Modifier.FINAL);
```

See also https://issues.apache.org/jira/browse/CASSANDRA-18181

### Changes

1. Added junit5 annotation `@EnabledForJreRange(max = JRE.JAVA_17)`(It's modern and better than junit4) to tests that use `suspend` and `resume`, effectively disabling these tests on JDK versions higher than 17 where these methods are not supported.
2. BookieZKExpireTest should be annotated as junit5 test.
3. Make `BookKeeperClusterTestCase` compatible to junit5.

Signed-off-by: ZhangJian He <shoothzj@gmail.com>
zhiheng123 pushed a commit to zhiheng123/bookkeeper that referenced this pull request Jun 7, 2024
…RegionAwareEnsemblePlacementPolicy beyond jdk11 (apache#4323)

### Motivation

In JDK21, it's is no way to change private static final variable currently, before figure out how to replace, disable it first

```
        Field logField = repp.getClass().getDeclaredField("LOG");
        Logger mockLogger = mock(Logger.class);
        Field modifiers = Field.class.getDeclaredField("modifiers");
        modifiers.setAccessible(true);
        modifiers.setInt(logField, logField.getModifiers() & ~Modifier.FINAL);
```

See also https://issues.apache.org/jira/browse/CASSANDRA-18181

### Changes

1. Added junit5 annotation `@EnabledForJreRange(max = JRE.JAVA_17)`(It's modern and better than junit4) to tests that use `suspend` and `resume`, effectively disabling these tests on JDK versions higher than 17 where these methods are not supported.
2. BookieZKExpireTest should be annotated as junit5 test.
3. Make `BookKeeperClusterTestCase` compatible to junit5.

Signed-off-by: ZhangJian He <shoothzj@gmail.com>
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
…RegionAwareEnsemblePlacementPolicy beyond jdk11 (apache#4323)

### Motivation

In JDK21, it's is no way to change private static final variable currently, before figure out how to replace, disable it first

```
        Field logField = repp.getClass().getDeclaredField("LOG");
        Logger mockLogger = mock(Logger.class);
        Field modifiers = Field.class.getDeclaredField("modifiers");
        modifiers.setAccessible(true);
        modifiers.setInt(logField, logField.getModifiers() & ~Modifier.FINAL);
```

See also https://issues.apache.org/jira/browse/CASSANDRA-18181

### Changes

1. Added junit5 annotation `@EnabledForJreRange(max = JRE.JAVA_17)`(It's modern and better than junit4) to tests that use `suspend` and `resume`, effectively disabling these tests on JDK versions higher than 17 where these methods are not supported.
2. BookieZKExpireTest should be annotated as junit5 test.
3. Make `BookKeeperClusterTestCase` compatible to junit5.

Signed-off-by: ZhangJian He <shoothzj@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants