Skip to content

[#12975] fix(core): Preserve errors thrown by PrincipalUtils.doAs - #12976

Open
roryqi wants to merge 2 commits into
apache:mainfrom
qqqttt123:fix/principal-utils-propagate-error
Open

[#12975] fix(core): Preserve errors thrown by PrincipalUtils.doAs#12976
roryqi wants to merge 2 commits into
apache:mainfrom
qqqttt123:fix/principal-utils-propagate-error

Conversation

@roryqi

@roryqi roryqi commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Rethrow the original Error from PrincipalUtils.doAs after logging it,
instead of wrapping it in a RuntimeException.

Add a unit test to verify that the original error instance is preserved.

Why are the changes needed?

Wrapping fatal JVM errors such as OutOfMemoryError in a
RuntimeException changes their classification and prevents callers and
error handlers from recognizing the actual failure.

Fix: #12975

Does this PR introduce any user-facing change?

Yes. Errors thrown by privileged actions retain their original type instead
of being exposed as RuntimeException.

How was this patch tested?

Ran:

./gradlew :core:spotlessApply :core:test --tests org.apache.gravitino.utils.TestPrincipalUtils

@roryqi
roryqi requested a review from yuqi1129 September 8, 2026 06:48
yuqi1129
yuqi1129 previously approved these changes Sep 8, 2026
@roryqi roryqi self-assigned this Sep 8, 2026
@roryqi roryqi added the branch-1.3 Automatically cherry-pick commit to branch-1.3 label Sep 8, 2026
throw new RuntimeException("doAs method encountered an unexpected exception", t);
} catch (Error error) {
LOG.warn("doAs method encountered an unexpected error", error);
throw error;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will be the exception when propogating to the client side?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current behavior is the server will crash.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Code Coverage Report

Overall Project 69.54% +0.38% 🟢
Files changed 93.79% 🟢

Module Coverage
aliyun 19.74% 🔴
api 51.57% 🟢
authorization-common 85.96% 🟢
authorization-ranger 4.38% 🔴
aws 53.54% 🟢
azure 32.1% 🔴
catalog-common 22.89% 🔴
catalog-fileset 82.17% 🟢
catalog-glue 69.8% 🟢
catalog-hive 82.96% 🟢
catalog-jdbc-common 45.09% 🟢
catalog-jdbc-doris 82.69% 🟢
catalog-jdbc-mysql 79.33% 🟢
catalog-jdbc-postgresql 83.83% 🟢
catalog-jdbc-starrocks 79.16% 🟢
catalog-kafka 76.99% 🟢
catalog-lakehouse-generic 60.88% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.9% 🟢
catalog-lakehouse-paimon 84.29% 🟢
catalog-model 77.99% 🟢
cli 44.51% 🟢
client-java 77.5% 🟢
common 56.89% 🟢
core 84.31% +0.52% 🟢
filesystem-hadoop3 76.48% 🟢
flink 0.0% 🔴
flink-common 53.22% 🟢
flink-runtime 0.0% 🔴
gcp 32.2% 🔴
hadoop-auth 68.0% 🟢
hadoop-common 17.84% 🔴
hive-metastore-common 53.5% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 66.58% 🟢
iceberg-rest-server 76.59% 🟢
idp-basic 87.1% 🟢
integration-test-common 0.0% 🔴
jobs 62.92% 🟢
lance-common 32.52% 🔴
lance-rest-server 68.12% 🟢
lineage 59.39% 🟢
optimizer 83.24% 🟢
optimizer-api 21.95% 🔴
server 90.11% 🟢
server-common 81.23% +0.03% 🟢
spark 56.27% 🟢
tencent 81.78% 🟢
trino-connector 58.36% 🟢
Files
Module File Coverage
core FunctionVersionMetaBaseSQLProvider.java 100.0% 🟢
FunctionMetaPostgreSQLProvider.java 100.0% 🟢
FunctionVersionMetaPostgreSQLProvider.java 100.0% 🟢
ViewMetaPostgreSQLProvider.java 100.0% 🟢
FunctionMetaService.java 100.0% 🟢
MetalakeMetaService.java 100.0% 🟢
OccWriteSupport.java 100.0% 🟢
ViewMetaService.java 100.0% 🟢
SchemaMetaService.java 99.56% 🟢
Configs.java 99.06% 🟢
CatalogMetaService.java 98.18% 🟢
TagMetaService.java 97.56% 🟢
FunctionVersionMetaSQLProviderFactory.java 95.24% 🟢
MetricsSource.java 86.36% 🟢
FunctionMetaSQLProviderFactory.java 80.77% 🟢
ViewMetaSQLProviderFactory.java 80.77% 🟢
PrincipalUtils.java 80.0% 🟢
ViewVersionInfoSQLProviderFactory.java 73.68% 🟢
FunctionMetaBaseSQLProvider.java 70.59% 🟢
ViewMetaBaseSQLProvider.java 70.59% 🟢
ViewVersionInfoPostgreSQLProvider.java 57.14% 🔴
ViewVersionInfoBaseSQLProvider.java 55.56% 🔴
FunctionPOStorageOps.java 40.0% 🔴
ViewPOStorageOps.java 27.03% 🔴
FunctionMetaMapper.java 0.0% 🔴
FunctionVersionMetaMapper.java 0.0% 🔴
TagMetaMapper.java 0.0% 🔴
ViewMetaMapper.java 0.0% 🔴
ViewVersionInfoMapper.java 0.0% 🔴
server-common HttpServerMetricsSource.java 87.5% 🟢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch-1.3 Automatically cherry-pick commit to branch-1.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug report] PrincipalUtils.doAs wraps Error as RuntimeException

3 participants