Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Aug 14, 2023
2 parents 1d2d786 + 5d02383 commit d3caa91
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.yegor256.xsline.Xsline;
import java.io.File;
import java.io.IOException;
import java.nio.file.AccessDeniedException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -251,12 +250,21 @@ private List<Path> transpile(
* In order to prevent this, we remove all classes that have the java analog in the
* generated sources. In other words, if generated-sources (or generated-test-sources) folder
* has java classes, we expect that they will be only compiled from that folder.
* _____
* Synchronization in this method is necessary to prevent
* {@link java.nio.file.AccessDeniedException} on the Windows OS.
* You can read more about the original problem in the following issue:
* - <a href="https://github.com/objectionary/eo/issues/2370">issue link</a>
* In other words, concurrent file deletions on the Windows OS can lead to an
* {@link java.nio.file.AccessDeniedException}, which could crash the build.
* _____
* @param java The list of java files.
* @todo #2281:90min Remove AccessDeniedException catch block from cleanUpClasses method.
* This catch block was added to prevent the build from failing when the file can't be
* deleted due to access denied. This is a temporary solution and should be removed when
* the root cause of the problem is found.
* See <a href="https://github.com/objectionary/eo/issues/2370">issue.</a>
* @todo #2375:90min. Add concurrency tests for the TranspileMojo.cleanUpClasses method.
* We should be sure that the method works correctly in a concurrent environment.
* In order to do so we should add a test that will run the cleanUpClasses method in
* multiple threads and check that the method works correctly without exceptions.
* We can apply the same approach as mentioned in that post:
* <a href="https://www.yegor256.com/2018/03/27/how-to-test-thread-safety.html">Post</a>
*/
private void cleanUpClasses(final Collection<? extends Path> java) {
final Set<Path> unexpected = java.stream()
Expand All @@ -266,12 +274,9 @@ private void cleanUpClasses(final Collection<? extends Path> java) {
.collect(Collectors.toSet());
for (final Path binary : unexpected) {
try {
Files.deleteIfExists(binary);
} catch (final AccessDeniedException ignore) {
Logger.warn(
this,
String.format("Can't delete file %s due to access denied", binary)
);
synchronized (TranspileMojo.class) {
Files.deleteIfExists(binary);
}
} catch (final IOException cause) {
throw new IllegalStateException(
String.format("Can't delete file %s", binary),
Expand Down

2 comments on commit d3caa91

@0pdd
Copy link

@0pdd 0pdd commented on d3caa91 Aug 14, 2023

Choose a reason for hiding this comment

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

Puzzle 2281-bc29f0be disappeared from eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java), that's why I closed #2375. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on d3caa91 Aug 14, 2023

Choose a reason for hiding this comment

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

Puzzle 2375-409ab48f discovered in eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java) and submitted as #2390. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.