Skip to content

Commit

Permalink
Re-add synchronization to ExtItemDict. (MID-4799)
Browse files Browse the repository at this point in the history
The Java synchronization was left out to make ExtItem conflicts more
visible and therefore resolvable during 3.9 development. Otherwise
they are masked by the synchronization and manifest themselves
only in e.g. clustered environment.

Unfortunately we had no time to fix them. So here we re-enable
Java synchronization for RExtItemDictionary methods.
  • Loading branch information
mederly committed Oct 24, 2018
1 parent 5560983 commit e5906a9
Showing 1 changed file with 8 additions and 9 deletions.
Expand Up @@ -91,22 +91,22 @@ private void fetchItemsAttempt() {
}
}

@NotNull // TODO synchronized (before release)
public RExtItem createOrFindItemDefinition(@NotNull ItemDefinition<?> definition, boolean throwExceptionAfterCreate) {
@NotNull
public synchronized RExtItem createOrFindItemDefinition(@NotNull ItemDefinition<?> definition, boolean throwExceptionAfterCreate) {
return createOrFindItemByDefinitionInternal(definition, true, throwExceptionAfterCreate);
}

@NotNull // TODO synchronized (before release)
public RExtItem createOrFindItemDefinition(@NotNull ItemDefinition<?> definition) {
@NotNull
public synchronized RExtItem createOrFindItemDefinition(@NotNull ItemDefinition<?> definition) {
return createOrFindItemByDefinitionInternal(definition, true, true);
}

@Nullable // TODO synchronized (before release)
public RExtItem findItemByDefinition(@NotNull ItemDefinition<?> definition) {
@Nullable
public synchronized RExtItem findItemByDefinition(@NotNull ItemDefinition<?> definition) {
return createOrFindItemByDefinitionInternal(definition, false, true);
}

@Contract("_, _, true -> !null") // TODO synchronized (before release)
@Contract("_, _, true -> !null")
private RExtItem createOrFindItemByDefinitionInternal(
@NotNull ItemDefinition<?> definition, boolean create, boolean throwExceptionAfterCreate) {

Expand Down Expand Up @@ -173,8 +173,7 @@ private void executeAttempts(String operationName, String operationVerb, Runnabl
}
}

// TODO synchronized (before release)
public RExtItem getItemById(Integer extItemId) {
public synchronized RExtItem getItemById(Integer extItemId) {
boolean fresh = fetchItemsIfNeeded();
RExtItem extItem = itemsById.get(extItemId);
if (extItem != null || fresh) {
Expand Down

0 comments on commit e5906a9

Please sign in to comment.