-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added significant amount of validation to components
Focus as on preventing lazy errors, where the primary issue is an incorrect configuration, but where the runtime error only occurs once the system is up and running, resulting in difficult to diagnose errors. The two ways this was accomplished by: - Add partyId validation whereever possible. - Add `Objects.requireNonNull` checks in component constructors. Additionally: - Added improved dianostics for failing futures in MASCOT `TestRuntime`.
- Loading branch information
1 parent
040477a
commit 83ed851
Showing
30 changed files
with
196 additions
and
81 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
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
34 changes: 34 additions & 0 deletions
34
core/src/main/java/dk/alexandra/fresco/framework/util/ValidationUtils.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,34 @@ | ||
package dk.alexandra.fresco.framework.util; | ||
|
||
/** Contains methods for validating ids. */ | ||
public final class ValidationUtils { | ||
|
||
private ValidationUtils() {} | ||
|
||
/** | ||
* Validates that the given party id is within the valid range of ids, without a known max id. | ||
* | ||
* @param partyId Id to validate | ||
* @exception IllegalArgumentException if id is not valid | ||
*/ | ||
public static void assertValidId(int partyId) { | ||
if (partyId < 1) { | ||
throw new IllegalArgumentException(String.format("Party id %d must be one-indexed", partyId)); | ||
} | ||
} | ||
|
||
/** | ||
* Validates that the given party id is within the valid range of ids, with a known max id. | ||
* | ||
* @param partyId Id to validate | ||
* @param numParties Max id | ||
* @exception IllegalArgumentException if id is not valid | ||
*/ | ||
public static void assertValidId(int partyId, int numParties) { | ||
assertValidId(partyId); | ||
if (numParties < partyId) { | ||
throw new IllegalArgumentException( | ||
String.format("Party id %d must be in range [1,%d]", partyId, numParties)); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.