[midPoint-git] [Evolveum/midpoint] f066d5: Make the MockServiceClientImpl (partially) thread ...

Andrej noreply at github.com
Wed May 6 10:09:03 CEST 2026


  Branch: refs/heads/bugfix/t-4567-add-tests-to-suite
  Home:   https://github.com/Evolveum/midpoint
  Commit: f066d561fdc3144fdee48eb0f92c5a632033ecc7
      https://github.com/Evolveum/midpoint/commit/f066d561fdc3144fdee48eb0f92c5a632033ecc7
  Author: Andrej Zan <andrej.zan at evolveum.com>
  Date:   2026-05-06 (Wed, 06 May 2026)

  Changed paths:
    M model/model-test/src/main/java/com/evolveum/midpoint/model/test/smart/MockServiceClientImpl.java

  Log Message:
  -----------
  Make the MockServiceClientImpl (partially) thread safe

**What**

Make one of the crucial internal components of the mock service client
thread safe.

**Why**

There was a possible race condition in the internal structure, which
holds references to generated responses. It could be triggered if
multiple threads are used to send a requests to the mock service client.

Similar race condition was also present in case when the client was
constructed with the old constructor with the array of responses as
parameter.

The race condition could cause at least two problems:

- Rewrite already set instance of the iterator in the
  `IteratorReference` instance.
- Cause `NoSuchElementException` when calling `next` on the iterator.

**Notes**

This changes does **not** make the `MockServiceClientImpl` thread safe
as a whole. The only thread safe part is the `invoke` method which is
part of the `ServiceClient` contract.

I believe it is sufficient, because the proper usage of this class is to
configure it first (what is by default done in single thread) and only
then pass it as an instance of the `ServiceClient` where it is required
and used as such.

**Task**: 11125


  Commit: 3f3295dca45727f22e27b0c277c23c8399f79b75
      https://github.com/Evolveum/midpoint/commit/3f3295dca45727f22e27b0c277c23c8399f79b75
  Author: Andrej Zan <andrej.zan at evolveum.com>
  Date:   2026-05-06 (Wed, 06 May 2026)

  Changed paths:
    M model/model-test/src/main/java/com/evolveum/midpoint/model/test/smart/MockServiceClientImpl.java

  Log Message:
  -----------
  Allow `MockServiceClient` to throw configured `AssertionError`s

**What**

When mock service client is configured with response of the
`AssertionError`, throw it as such instead of returning it normally.

**Why**

There are tests, which expects, that some requests will never be sent to
the service. In these tests, the client is configured to return an
`AssertionError` if such request comes.

Before this change, such assertion error would be however just returned
as a normal response, what is of course wrong, because the code which
uses the client does not expect such responses. What it does now instead
is that if the response is an instance of the `AssertionError` it throws
it directly from the client.

**Notes**

The approach of configuring expected exceptions as a response is not
very clean and nice solution. It should have it's own method, something
like `thenThrow` or similar. But for now it is sufficient.

**Task**: 11125


Compare: https://github.com/Evolveum/midpoint/compare/0d3a2a416f46...3f3295dca457

To unsubscribe from these emails, change your notification settings at https://github.com/Evolveum/midpoint/settings/notifications


More information about the midPoint-svn mailing list