-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw a separate exception if ESGetToken is uninitialized #30506
Conversation
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30506/16700
|
A new Pull Request was created by @makortel (Matti Kortelainen) for master. It involves the following packages: FWCore/Framework @makortel, @smuzaffar, @cmsbuild, @Dr15Jones can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@cmsbuild, please test |
The tests are being triggered in jenkins.
|
assert(iToken.isInitialized()); | ||
if UNLIKELY (not iToken.isInitialized()) { | ||
std::rethrow_exception(makeInvalidTokenException(this->key(), DataKey::makeTypeTag<T>())); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dr15Jones I ended up re-using makeInvalidTokenException()
because the exception message of that was about the same I had in mind. But that makes me ask ...
UNLIKELY(not iToken.hasValidIndex()) { return invalidTokenHandle<H>(iToken); } | ||
if UNLIKELY (not iToken.hasValidIndex()) { | ||
return invalidTokenHandle<H>(iToken); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... if this check (which is the only caller of makeInvalidTokenException()
) would still be useful? Can ESGetToken
be constructed with a valid transition ID but invalid index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the data product is not available that would happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the exception message of that appears to be confusing. invalidTokenHandle()
cmssw/FWCore/Framework/interface/EventSetupRecord.h
Lines 252 to 256 in cea1d1b
H<T> invalidTokenHandle(ESGetToken<T, R> const& iToken) const { | |
auto const key = this->key(); | |
return H<T>{ | |
makeESHandleExceptionFactory([key] { return makeInvalidTokenException(key, DataKey::makeTypeTag<T>()); })}; | |
} |
just leads to
makeInvalidTokenException()
that createscmssw/FWCore/Framework/src/EventSetupRecord.cc
Lines 73 to 81 in cea1d1b
std::exception_ptr EventSetupRecord::makeInvalidTokenException(EventSetupRecordKey const& iRecordKey, | |
TypeTag const& iDataKey) { | |
cms::Exception ex("InvalidESGetToken"); | |
ex << "Attempted to get data using an invalid token of type ESGetToken<" << iDataKey.name() << "," | |
<< iRecordKey.name() | |
<< ">.\n" | |
"Please call consumes to properly initialize the token."; | |
return std::make_exception_ptr(ex); | |
} |
that suggests to call consumes, which should be unrelated to (in)availability of the data product.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We concluded that a valid transition ID and invalid index should not happen, so I'll replace this exception message.
+1 |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30506/18163
|
Pull request #30506 was updated. @makortel, @smuzaffar, @cmsbuild, @Dr15Jones can you please check and sign again. |
@cmsbuild, please test |
The tests are being triggered in jenkins.
|
+1 |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
+1 |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @silviodonato, @dpiparo, @qliphy (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
PR description:
In #30482 it was noticed that a
get()
with uninitializedESGetToken
throws an exception complaining on incorrect transition ID. This is confusing and inconsistent withEDGetToken
andEDPutToken
. This PR changesEventSetupRecord::getHandleImpl()
to first check if a token is initialized, and then check if the transition is correct.In addition,
scram b code-format
lead to partial reformatting ofEventSetupRecord.h
(perhaps this file was missed in code formatting campaign after a clang version update or something), I included those changes in a separate commit.PR validation:
Framework unit tests run.