Skip to content

Commit

Permalink
LPD-35723 A temp logging support, revert in the end. Due to JAXRS con…
Browse files Browse the repository at this point in the history
…trols transaction scope, at this level after Resource call, the tx is not committed yet, therefore the timing was not including search indexing. Wrap up a new tx to ensure we time for search. Since this Resource works at top level under JAXRS, the new TX itself won't cause any other side affect, but we still need to revert it in the of the optimization.
  • Loading branch information
shuyangzhou committed Sep 14, 2024
1 parent 78aa78b commit d9c623c
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
import com.liferay.portal.kernel.search.filter.Filter;
import com.liferay.portal.kernel.security.auth.GuestOrUserUtil;
import com.liferay.portal.kernel.security.permission.ActionKeys;
import com.liferay.portal.kernel.transaction.Propagation;
import com.liferay.portal.kernel.transaction.TransactionConfig;
import com.liferay.portal.kernel.transaction.TransactionInvokerUtil;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.HashMapBuilder;
Expand Down Expand Up @@ -120,13 +123,25 @@ public void deleteObjectDefinition(Long objectDefinitionId)
startTime = System.currentTimeMillis();
}

_objectDefinitionService.deleteObjectDefinition(objectDefinitionId);
try {
TransactionInvokerUtil.invoke(
_transactionConfig,
() -> {
_objectDefinitionService.deleteObjectDefinition(
objectDefinitionId);

return null;
});
}
catch (Throwable throwable) {
throw new Exception(throwable);
}

if (_log.isInfoEnabled()) {
_log.info(
StringBundler.concat(
"Deleted object definition ", objectDefinitionId,
" in ", System.currentTimeMillis() - startTime, "ms"));
"Deleted object definition ", objectDefinitionId, " in ",
System.currentTimeMillis() - startTime, "ms"));
}
}

Expand Down Expand Up @@ -1442,6 +1457,9 @@ private void _validateRootObjectDefinition(

private static final EntityModel _entityModel =
new ObjectDefinitionEntityModel();
private static final TransactionConfig _transactionConfig =
TransactionConfig.Factory.create(
Propagation.REQUIRES_NEW, new Class<?>[] {Exception.class});

@Reference
private Language _language;
Expand Down

0 comments on commit d9c623c

Please sign in to comment.