Hello all,
I'd like feedback on a refactoring started on banch
refactor/strict_storage_connector
<https://github.com/apache/sis/tree/refactor/strict_storage_connector>. If
any experienced developper could make a feedback on the work in progress,
it would be greatly appreciated.
In details:
The aim is to refactor class StorageConnector in sis-storage module. I
think this change is
needed for safety of use. Currently, the API gives a lot of freedom to the
user, forcing him/her to be very cautious about the lifecycle of the
component.
In details, StorageConnector provides access to its internal mutable state
(opened resources) to user, without performing any validation over its
actions. Currently, a mistake is likely to cause corruption of the
resources opened by the connector, therefore any errors caused by such
corruption cannot be detected uphill, and may "riple" to undesired and not
easily detectable side-effects.
What I'm trying to do is modifying API to provide functional style methods
(useAs*). Such method would:
1. Relieve user of the responsability to mark/rewind used resources.
2. Provide fail-fast behavior when detecting:
- Concurrent usage of the resource.
- Inability to properly rewind used resource to its initial state.
3. Better guidance for user, by providing:
- fully-typed endpoints
- AutoCloseable inheritance to mimic standard resource usage.
For now, I have isolated changes in a dedicated class ->
StrictStorageConnector
<https://github.com/apache/sis/blob/refactor/strict_storage_connector/storage/sis-storage/src/main/java/org/apache/sis/storage/StrictStorageConnector.java>
.
By doing so, I hope initial review to be easier. You'll find a dedicated
test class also.
If I receive positive feedback, the next steps would be :
* Porting work directly in StorageConnector
* Migrating usages of storage connector to new API
* Iterating as neccessary to improve API/ fix problems
* Completing doc/tests
* Merging in geoapi-4.0 & master branches.
Thanks in advance to any reviewers.
Regards,