Null behaviour of begin method #3189
Replies: 9 comments
-
My current take on this is that I agree it should be documented that it accepts I'm not sure what you mean with making |
Beta Was this translation helpful? Give feedback.
-
I think it shouldn't take null. |
Beta Was this translation helpful? Give feedback.
-
Why is that? |
Beta Was this translation helpful? Give feedback.
-
Because we have two begin methods. One that takes an isolation level and one that doesn't. It makes a lot more sense to require an isolation level when there is a method specifically designed to handle the cases where you don't have an isolation level. |
Beta Was this translation helpful? Give feedback.
-
Furthermore, starting a transaction explicitly with null as the isolation level should be equivalent to specifying NONE, since null feels a lot more like NONE than it does "unknown" in Java (unlike SQL). |
Beta Was this translation helpful? Give feedback.
-
Alternatively we deprecate the begin() method (without any arguments) so that we in the future are left with only one begin method in the sail, but multiple in the repository api signaling that the repository api is targeted at users while the sail api is targeted at implementers and is thus as concise as possible. I actually prefer this approach to be honest. |
Beta Was this translation helpful? Give feedback.
-
To be honest if we were designing this from scratch I would probably agree with you that a null-check is more elegant, but it's been implemented for quite a while now to accept As an aside: the reason we have two begin methods is itself a backward compatibility issue: transaction isolation levels were introduced much later than the notion of transactions itself. Anyway, at the end of the day I'm fine with either approach. We can go ahead and make non-null argument mandatory at the sail level, and if someone complains about their code suddenly breaking we can point out that they were relying on undocumented behavior (so we can argue that it's not a backward incompatible change). I don't know how likely it is that this will happen, just be prepared to not make friends if it does occur. As for deprecating |
Beta Was this translation helpful? Give feedback.
-
I'm actually thinking we should both deprecate the empty begin method and at the same time remove support for null in the begin method with isolation level. At the same time we should also introduce a getDefaultIsolationLevel method to the SailConnection. That way there is no way for an implementer to start a transaction without specifying an isolation level. |
Beta Was this translation helpful? Give feedback.
-
I think that's what I suggested in the end as well. Except getDefaultisolationlevel already exists. At the sail level. And I don't see any benefit to moving it to the connection. |
Beta Was this translation helpful? Give feedback.
-
The begin method in the
RepositoryConnection
specifically states that it handlesnull
as an isolation level, while the same method in theSailConnection
does not say this.If the begin method in the
SailConnection
should handle null it should be:We should also consider making "getDefaultIsolationLevel" a required method in the
Sail
, since it would then be required to be able to support nulls.We should also remove any unneeded null handling, like in the
SchemaCachingRDFSInferencerConnection
where we check if the isolation level is null, even though we could just pass null to super.begin.Beta Was this translation helpful? Give feedback.
All reactions