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

Updates for Reevaluate Functions for Exception Throwing #6

Merged
merged 6 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/main/java/com/senzing/sdk/SzEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ String deleteRecord(SzRecordKey recordKey, Set<SzFlag> flags)
* Reevaluate the record identified by the data source code and record ID
* from the specified {@link SzRecordKey}.
* <p>
* If the data source code is not recognized then an {@link
* SzUnknownDataSourceException} is thrown but if the record for the
* record ID is not found, then the operation silently does nothing with
* no exception. This is to ensure consistent behavior in case of a race
* condition with record deletion. To ensure that the record was found,
* specify the {@link SzFlag#SZ_WITH_INFO} flag and check the returned
* INFO document for affected entities.
* <p>
* The specified {@link Set} of {@link SzFlag} instances may contain any
* {@link SzFlag} value, but only flags belonging to the {@link
* SzFlagUsageGroup#SZ_MODIFY} group will be recognized (other {@link SzFlag}
Expand All @@ -135,8 +143,6 @@ String deleteRecord(SzRecordKey recordKey, Set<SzFlag> flags)
* @throws SzUnknownDataSourceException If an unrecognized data source
* code is specified.
*
* @throws SzNotFoundException If the record ID is not found.
*
* @throws SzException If a failure occurs.
*
* @see SzFlag#SZ_WITH_INFO_FLAGS
Expand All @@ -149,6 +155,12 @@ String reevaluateRecord(SzRecordKey recordKey, Set<SzFlag> flags)
* Reevaluate a resolved entity identified by the specified entity ID.
* If the entity is not found then this method does nothing.
* <p>
* If the entity for the entity ID is not found, then the operation
* silently does nothing with no exception. This is to ensure consistent
* behavior in case of a race condition with entity re-resolve or unresolve.
* To ensure that the entity was found, specify the {@link SzFlag#SZ_WITH_INFO}
* flag and check the returned INFO document for affected entities.
* <p>
* The specified {@link Set} of {@link SzFlag} instances may contain any
* {@link SzFlag} value, but only flags belonging to the {@link
* SzFlagUsageGroup#SZ_MODIFY} group will be recognized (other {@link SzFlag}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ void handleReturnCode(int returnCode, NativeApi nativeApi)
case 24:
case 88:
throw new SzBadInputException(errorCode, message);
case 27: // this is going away
case 2207:
throw new SzUnknownDataSourceException(errorCode, message);
case 33:
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/com/senzing/sdk/core/SzCoreEngineWriteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,8 @@ public List<Arguments> getReevaluateRecordArguments() {
// do a good data source with a bad record ID
key = SzRecordKey.of(key.dataSourceCode(), key.recordId() + "-UNKNOWN");

// TODO(bcaceres) -- change this depending on the outcome of GDEV-3790
//exceptionType = SzNotFoundException.class;
// Per decision, reevaluate record silently does nothing if record ID not found
// exceptionType = SzNotFoundException.class;

break;
default:
Expand Down Expand Up @@ -758,15 +758,15 @@ public List<Arguments> getReevaluateEntityArguments() {
case 0:
// do a negative entity ID
entityId = -1 * entityId;
// TODO(bcaceres) -- change this depending on the outcome of GDEV-3790
//exceptionType = SzNotFoundException.class;
// Per decision, reevaluate entity silently does nothing if enitty ID not found
// exceptionType = SzNotFoundException.class;

break;
case 1:
// do a large entity that does not exist
entityId = 1000000000L;
// TODO(bcaceres) -- change this depending on the outcome of GDEV-3790
//exceptionType = SzNotFoundException.class;
// Per decision, reevaluate entity silently does nothing if enitty ID not found
// exceptionType = SzNotFoundException.class;

break;
default:
Expand Down Expand Up @@ -819,8 +819,8 @@ void testReevaluateEntity(Long entityId,
}
} else {
assertEquals(SzCoreEngine.NO_INFO, result,
"No INFO requested, but non-empty response received: "
+ testData);
"No INFO requested, but non-empty response received: "
+ testData);
}

} catch (Exception e) {
Expand Down