Skip to content

[OPENJPA-2978] Fix SchemaManagerImpl nits and unsupported-validation reporting - #155

Open
rzo1 wants to merge 2 commits into
masterfrom
OPENJPA-2978
Open

[OPENJPA-2978] Fix SchemaManagerImpl nits and unsupported-validation reporting#155
rzo1 wants to merge 2 commits into
masterfrom
OPENJPA-2978

Conversation

@rzo1

@rzo1 rzo1 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Cleans up the reported nits in SchemaManagerImpl (stray double semicolon, redundant (Exception) cast, javadoc typo) and stops validate() from wrapping an UnsupportedOperationException into SchemaValidationException("Schema could not be validated: null") — a store that does not implement validation now reports a missing capability, consistently with create(), drop() and truncate(). The message-less UnsupportedOperationExceptions in AbstractBrokerFactory got real messages, and a new TestSchemaManagerImpl covers both the unsupported and the real-failure path.

The Strucuture/Struture typos from the review comment are already fixed on master (commit cbb19f7, "[OPENJPA-2940] Fixes typos in BrokerFactory"), so no rename was needed.

rzo1 added 2 commits August 20, 2026 12:36
Removes the stray second semicolon in truncate(), drops the redundant
(Exception) cast when constructing SchemaValidationException, and corrects
the 'concretelly' javadoc typo. The Strucuture/Struture method name typos
reported in review were already corrected on master and need no change.
…ation failure

SchemaManagerImpl.validate() caught every Exception and rewrapped it into a
SchemaValidationException. A store which does not implement schema validation
throws UnsupportedOperationException from AbstractBrokerFactory, so a missing
capability was reported to the caller as
SchemaValidationException("Schema could not be validated: null") - which per
the jakarta.persistence 3.2 javadoc asserts that a database object is missing
or has an unexpected definition, although nothing was ever inspected.

validate() now lets UnsupportedOperationException reach the caller unchanged,
the same way create(), drop() and truncate() already do, and keeps wrapping
every other failure (MetaDataException / IllegalStateException from the JDBC
path) in SchemaValidationException. The wrapped message falls back to the
exception class name when the exception carries no message, so it can never
read "...: null" again.

For consistency the four unsupported operations in AbstractBrokerFactory now
carry a message instead of being thrown bare, which improves the create, drop
and truncate paths as well.

Adds TestSchemaManagerImpl, covering the unsupported case for all four
operations, the wrapping of a real validation failure and the message
fallback.
@rzo1 rzo1 self-assigned this Aug 20, 2026
@rzo1
rzo1 requested a review from solomax August 20, 2026 10:45
@Override
public void createPersistenceStructure(boolean createSchemas) {
throw new UnsupportedOperationException();
throw new UnsupportedOperationException("This BrokerFactory does not implement schema creation.");

@solomax solomax Aug 20, 2026

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.

this class is abstract maybe these methods need to be just removed?

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.

These can't just be removed: AbstractStoreBrokerFactory (openjpa-kernel/src/main/java/org/apache/openjpa/abstractstore/AbstractStoreBrokerFactory.java:51) is a concrete main-code subclass that implements none of the four, as is the BrokerFactory stub in TestPersistenceManagerFactoryImpl, so both would stop compiling and we'd end up pasting the same four throws into AbstractStoreBrokerFactory rather than deleting them. The methods are also new on the interface (@SInCE 4.2.0, unreleased), so any out-of-tree factory extending AbstractBrokerFactory compiles today only because these defaults exist - dropping them turns a clear UnsupportedOperationException into an AbstractMethodError at getSchemaManager() time. I'd rather keep one default here than duplicate it per subclass; this commit only makes the exception say which operation is missing. If you'd still prefer compile-time enforcement, that's a separate change that also has to decide what AbstractStoreBrokerFactory does for schema operations.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants