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 Java 19 build #2478

Merged
merged 10 commits into from
Mar 13, 2023
Merged

Fix Java 19 build #2478

merged 10 commits into from
Mar 13, 2023

Conversation

geofjamg
Copy link
Member

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem ? If so, link to this issue using '#XXX' and skip the rest
No

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix

What is the current behavior? (You can also link to an open issue here)
We cannot build using a JDK 19

What is the new behavior (if this is a feature change)?
Mockito core and Groovy need to be updated bu there is still an issue with Mockito when mocking java.util.ByeBuffer.

Does this PR introduce a breaking change or deprecate an API? If yes, check the following:

  • The Breaking Change or Deprecated label has been added
  • The migration guide has been updated in the github wiki (What changes might users need to make in their application due to this PR?)

Other information:

(if any of the questions/checkboxes don't apply, please delete them entirely)

Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
@geofjamg
Copy link
Member Author

mockito/mockito#2927

@geofjamg
Copy link
Member Author

So the mockito issue in time series api unit tests won't be solved as it is not recommended to mock JDK classes.
We have to redesign theses tests to avoid directly mock java.util.ByteBuffer.

Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
@geofjamg
Copy link
Member Author

It looks like jacoco is not working too. Maybe need to be updated?

@geofjamg
Copy link
Member Author

It looks like jacoco is not working too. Maybe need to be updated?

Confirmed. We need to update powsybl-parent to jacoco 0.8.8

We get an exception:
    org.mockito.exceptions.base.MockitoException:
    Mockito cannot mock this class: class java.nio.ByteBuffer.

Try to use java.nio APIs to use no resources (sparse, private), not sure
how this works on all platforms..

Signed-off-by: HARPER Jon <jon.harper87@gmail.com>
geofjamg and others added 2 commits February 28, 2023 21:38
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
for (FileChannel channel : channels) {
channel.close();
}
Files.delete(tempdir);
Copy link
Member Author

Choose a reason for hiding this comment

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

@jonenst On Windows test failed because directory is not empty. So a real file has been created on the file system even in private map mode.

Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
@geofjamg
Copy link
Member Author

geofjamg commented Mar 2, 2023

@jonenst thinking again not sure this is the right testing strategy. I tested on a 4Go Windows virtual machine and all tests failed with

Caused by: java.io.IOException: Le fichier de pagination est insuffisant pour terminer cette opération
	at java.base/sun.nio.ch.FileChannelImpl.map0(Native Method)
	at java.base/sun.nio.ch.FileChannelImpl.mapInternal(FileChannelImpl.java:1305)
	at java.base/sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:1181)
	at com.powsybl.timeseries.AbstractBigBufferTest.testAllocator(AbstractBigBufferTest.java:39)

We should not require so much memory for running unit test and not really allocate so big buffers.
Maybe we should revert back to old solution but not mocking ByteBuffer directly but instead introducing an intermediate abstraction (a wrapper of ByteBuffer) that will be the target of the mock.

…ility without bytebuffer

Signed-off-by: HARPER Jon <jon.harper87@gmail.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
@geofjamg geofjamg changed the title [WIP] Fix Java 19 build Fix Java 19 build Mar 13, 2023
@sonarcloud
Copy link

sonarcloud bot commented Mar 13, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@geofjamg geofjamg merged commit 7b347f9 into main Mar 13, 2023
@geofjamg geofjamg deleted the fix_java19_build branch March 13, 2023 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants