-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1089 from eclipse-passage/1088
1088 Passage Operator 2.4.0-M3 fails on startup
- Loading branch information
Showing
13 changed files
with
175 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/io/ExistingFolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.base.io; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.function.Supplier; | ||
|
||
import org.eclipse.passage.lic.internal.base.Cached; | ||
|
||
public final class ExistingFolder implements Supplier<Path> { | ||
|
||
private final Cached<Supplier<Path>, Path> folder; | ||
|
||
public ExistingFolder(Supplier<Path> folder) { | ||
this.folder = new Cached<>(folder, this::existing); | ||
} | ||
|
||
@Override | ||
public Path get() { | ||
return folder.get(); | ||
} | ||
|
||
private Path existing(Supplier<Path> origin) { | ||
Path path = origin.get(); | ||
if (!Files.exists(path)) { | ||
path.toFile().mkdirs(); // do not use nio | ||
} | ||
return path; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/io/ExistingFolderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.internal.base.tests.io; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assume.assumeFalse; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.function.Supplier; | ||
|
||
import org.eclipse.passage.lic.base.io.ExistingFolder; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
public final class ExistingFolderTest { | ||
|
||
@Rule | ||
public TemporaryFolder folder = new TemporaryFolder(); | ||
|
||
@Test | ||
public void createsIfDoesNotExist() { | ||
Supplier<Path> faulty = notExistingFolder(); | ||
assumeFalse(Files.exists(faulty.get())); | ||
assertTrue(Files.exists(new ExistingFolder(faulty).get())); | ||
} | ||
|
||
private Supplier<Path> notExistingFolder() { | ||
return new NotExistingFolder(folder.getRoot().toPath()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
....lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/io/NotExistingFolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/package org.eclipse.passage.lic.internal.base.tests.io; | ||
|
||
import java.nio.file.Path; | ||
import java.util.function.Supplier; | ||
|
||
final class NotExistingFolder implements Supplier<Path> { | ||
|
||
private final Path base; | ||
|
||
NotExistingFolder(Path base) { | ||
this.base = base; | ||
} | ||
|
||
@Override | ||
public Path get() { | ||
return base.resolve(Long.toHexString(System.currentTimeMillis())); | ||
} | ||
|
||
} |