You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2024/04/10 10:38:48 UTC

[PR] new persistence exceptions [pekko]

pjfanning opened a new pull request, #1271:
URL: https://github.com/apache/pekko/pull/1271

   relates to https://github.com/apache/pekko/discussions/1233#discussioncomment-8975620


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #1271:
URL: https://github.com/apache/pekko/pull/1271#issuecomment-2048011656

   > > Does multiple files is need?
   > 
   > Not sure , may be @pjfanning can elaborate ?
   
   Does it really matter? Many people expect to find classes in their own source files. If you are going to force me to merge all these changes into 1 source file, please suggest a file name for it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #1271:
URL: https://github.com/apache/pekko/pull/1271#issuecomment-2048091693

   How about    PersistenceException.scala


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new durable state persistence exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1574097524


##########
persistence/src/main/scala/org/apache/pekko/persistence/state/exception/DurableStateException.scala:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.state.exception
+
+import scala.util.control.NoStackTrace
+
+/**
+ * Exception thrown when Durable State cannot be updated or deleted.

Review Comment:
   Yes, or `getObject`, so we can just update the description to something like `when doing durable state operations`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "Roiocam (via GitHub)" <gi...@apache.org>.
Roiocam commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1560326221


##########
persistence/src/main/scala/org/apache/pekko/persistence/OutOfDateRevisionException.scala:
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence

Review Comment:
   These exceptions are `durable-state` specific, why are they not created in `state` package?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1567193009


##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/exception/DurableStateStoreExceptions.scala:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.typed.state.exception

Review Comment:
   I think this should lives in the `persistence` package, instead the `persistence.typed`



##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/exception/DurableStateStoreExceptions.scala:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.typed.state.exception

Review Comment:
   I think this should live in the `persistence` package, instead the `persistence.typed`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1560733817


##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/internal/DurableStateStoreException.scala:
##########
@@ -13,18 +13,40 @@
 
 package org.apache.pekko.persistence.typed.state.internal
 
+import scala.util.control.NoStackTrace
+
 import org.apache.pekko
-import pekko.annotation.InternalApi
 import pekko.persistence.typed.PersistenceId
 
 /**
- * INTERNAL API
- *
- * Used for store failures. Private to pekko as only internal supervision strategies should use it.
+ * Base class for exceptions thrown by the Durable State implementations.
+ * Public since v1.1.0.
  */
-@InternalApi
-final private[pekko] class DurableStateStoreException(msg: String, cause: Throwable)
+class DurableStateStoreException(msg: String, cause: Throwable)

Review Comment:
   I think we should keep the 
   `@InternalApi` at least. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1560376104


##########
persistence/src/main/scala/org/apache/pekko/persistence/PersistenceException.scala:
##########
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence
+
+import scala.util.control.NoStackTrace
+
+import org.apache.pekko
+import pekko.PekkoException
+
+/**
+ * Base class for exceptions thrown by the persistence implementation.
+ *
+ * @param message the exception message
+ * @since 1.1.0
+ */
+abstract class PersistenceException(message: String)

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #1271:
URL: https://github.com/apache/pekko/pull/1271#issuecomment-2048848306

   > > > The module `persistence` mostly declared data access related, Who will directly come into contact with these exceptions? is a user or the pekko developer? If it is a user, then these exceptions should be placed in `persistence-typed`.
   > > > If these exceptions will be used by `DurableStateBehavior`, it should extend from `DurableStateStoreException`
   > > > https://github.com/apache/pekko/blob/1f20fa4aba841365f3fe9021b6f2f767d0139ff0/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/internal/DurableStateBehaviorImpl.scala#L156
   > > 
   > > 
   > > DurableStateStoreException is for issues when saving state.
   > 
   > I won't come to a conclusion so early. As the code below shows, they are not all of `saving state`
   > 
   > https://github.com/apache/pekko/blob/1f20fa4aba841365f3fe9021b6f2f767d0139ff0/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/internal/Recovering.scala#L133-L135
   > 
   > > These new exceptions are for issues deleting state - see [#1233 (comment)](https://github.com/apache/pekko/discussions/1233#discussioncomment-8975620)
   > 
   > We can treat DurableStateStoreException as a parent, as it is named.
   > 
   > otherwise, the **supervisionStrategy won't work**(that's what I most care about). Or we can add a new supervisionStrategy via the chain, but we already have a unified entry, doesn't it?
   
   DurableStateStoreException is final. I guess it can be changed to be non-final but it also is in a package called 'internal'. There is an argument that the new exceptions are internal too - but anyone who writes their own persistence implementation (and there are ecosystem libs out there) would ideally need to start throwing the new exceptions in their code. So having an 'internal' class is messy.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new durable state persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #1271:
URL: https://github.com/apache/pekko/pull/1271


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1560848629


##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/exception/DurableStateStoreExceptions.scala:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.typed.state.exception
+
+import scala.util.control.NoStackTrace
+
+import org.apache.pekko
+import pekko.persistence.typed.state.internal.DurableStateStoreException
+
+/**
+ * Exception thrown when Durable State cannot be deleted because the revision
+ * is out of date (i.e. the state has a newer revision set).
+ *
+ * @param msg the exception message
+ * @since 1.1.0
+ */
+final class OutOfDateRevisionException(msg: String)
+    extends DurableStateStoreException(msg) with NoStackTrace
+
+/**
+ * Exception thrown when Durable State cannot be deleted because the revision
+ * is unknown (i.e. the current revision is lower than the revision that we
+ * attempted to delete).
+ *
+ * @param msg the exception message
+ * @since 1.1.0
+ */
+final class UnknownRevisionException(msg: String)

Review Comment:
   It's passed to runtime exception



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "Roiocam (via GitHub)" <gi...@apache.org>.
Roiocam commented on PR #1271:
URL: https://github.com/apache/pekko/pull/1271#issuecomment-2048840013

   > > The module `persistence` mostly declared data access related, Who will directly come into contact with these exceptions? is a user or the pekko developer? If it is a user, then these exceptions should be placed in `persistence-typed`.
   > > If these exceptions will be used by `DurableStateBehavior`, it should extend from `DurableStateStoreException`
   > > https://github.com/apache/pekko/blob/1f20fa4aba841365f3fe9021b6f2f767d0139ff0/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/internal/DurableStateBehaviorImpl.scala#L156
   > 
   > DurableStateStoreException is for issues when saving state.
   
   I won't come to a conclusion so early. As the code below shows, they are not all of `saving state`
   
   https://github.com/apache/pekko/blob/1f20fa4aba841365f3fe9021b6f2f767d0139ff0/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/internal/Recovering.scala#L133-L135
   
   
   > These new exceptions are for issues deleting state - see [#1233 (comment)](https://github.com/apache/pekko/discussions/1233#discussioncomment-8975620)
   
   We can treat DurableStateStoreException as a parent, as it is named. 
   
   otherwise, the supervisionStrategy won't work. Or we can add a new supervisionStrategy via the chain, but we already have a unified entry, doesn't it?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1560842646


##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/exception/DurableStateStoreExceptions.scala:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.typed.state.exception
+
+import scala.util.control.NoStackTrace
+
+import org.apache.pekko
+import pekko.persistence.typed.state.internal.DurableStateStoreException
+
+/**
+ * Exception thrown when Durable State cannot be deleted because the revision
+ * is out of date (i.e. the state has a newer revision set).
+ *
+ * @param msg the exception message
+ * @since 1.1.0
+ */
+final class OutOfDateRevisionException(msg: String)

Review Comment:
   Should `msg` be a `val` so that users can access the value? Alternately we can use a `case class` but that could be excessive.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1572063000


##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/exception/DurableStateStoreExceptions.scala:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.typed.state.exception

Review Comment:
   refactored - please have a look when you have time



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new durable state persistence exceptions [pekko]

Posted by "Roiocam (via GitHub)" <gi...@apache.org>.
Roiocam commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1574012273


##########
persistence/src/main/scala/org/apache/pekko/persistence/state/exception/DurableStateException.scala:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.state.exception
+
+import scala.util.control.NoStackTrace
+
+/**
+ * Exception thrown when Durable State cannot be updated or deleted.

Review Comment:
   I think the scope of this exception is more wide now. we may want to update it too.



##########
persistence/src/main/scala/org/apache/pekko/persistence/state/javadsl/DurableStateUpdateStore.scala:
##########
@@ -26,12 +26,39 @@ import pekko.Done
 trait DurableStateUpdateStore[A] extends DurableStateStore[A] {
 
   /**
-   * @param seqNr sequence number for optimistic locking. starts at 1.
+   * Upsert the object with the given `persistenceId` and `revision`.
+   *
+   * @param persistenceId the persistenceId of the object to upsert
+   * @param revision the revision of the object to upsert
+   * @param value the value to upsert
+   * @param tag a tag to associate with the object
+   * @return a CompletionStage that completes when the object has been upserted
    */
   def upsertObject(persistenceId: String, revision: Long, value: A, tag: String): CompletionStage[Done]

Review Comment:
   The generics type parameter name `A` is unusual.  https://docs.oracle.com/javase/tutorial/java/generics/types.html
   
   But we could fixe it in another PR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #1271:
URL: https://github.com/apache/pekko/pull/1271#issuecomment-2048034669

   I think both OK, in Scala they just define the sub classes in the same file of the super trait, and the file name is the name of super trait/classes.
   
   Another thing is do you expect these classes to be sealed? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1560375947


##########
persistence/src/main/scala/org/apache/pekko/persistence/UnknownRevisionException.scala:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence
+
+/**
+ * Exception thrown when Durable State cannot be deleted because the revision
+ * is unknown (i.e. the current revision is lower than the revision that we
+ * attempted to delete).
+ *
+ * @param message the exception message
+ * @since 1.1.0
+ */
+class UnknownRevisionException(message: String) extends PersistenceException(message)

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1560803602


##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/internal/DurableStateStoreException.scala:
##########
@@ -13,18 +13,40 @@
 
 package org.apache.pekko.persistence.typed.state.internal
 
+import scala.util.control.NoStackTrace
+
 import org.apache.pekko
-import pekko.annotation.InternalApi
 import pekko.persistence.typed.PersistenceId
 
 /**
- * INTERNAL API
- *
- * Used for store failures. Private to pekko as only internal supervision strategies should use it.
+ * Base class for exceptions thrown by the Durable State implementations.
+ * Public since v1.1.0.
  */
-@InternalApi
-final private[pekko] class DurableStateStoreException(msg: String, cause: Throwable)
+class DurableStateStoreException(msg: String, cause: Throwable)

Review Comment:
   I reworked it again. Made DurableStateStoreException InteranlApi again but moved the new classes to a new package. The new classes are not internal, writers of persistence implementations like https://github.com/SwissBorg/pekko-persistence-postgres may want to make the same chnages that we are going to make to https://github.com/apache/pekko-persistence-jdbc and other projects to have the deleteObject function fail with one of these new exceptions if no DB row is deleted.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "Roiocam (via GitHub)" <gi...@apache.org>.
Roiocam commented on PR #1271:
URL: https://github.com/apache/pekko/pull/1271#issuecomment-2048855288

   > DurableStateStoreException is final. I guess it can be changed to be non-final but it also is in a package called 'internal'. 
   
   Fair to me.
   
   > There is an argument that the new exceptions are internal too - but anyone who writes their own persistence implementation (and there are ecosystem libs out there) would ideally need to start throwing the new exceptions in their code. So having an 'internal' class is messy.
   
   Maybe it won't be messy?
   
   plugin developer can write their own exceptions, that's fine, but in the end, those exceptions will be converted to DurableStateStoreException for the supervisor's purpose(we have to make sure that).
   
   for pekko-core change, we should be restrained. 
   
   Different plugins may have exceptions independent of the specific situation of the plugin, so there is a general entry, similar to DurableStateStoreException, which will be very good.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1560844874


##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/exception/DurableStateStoreExceptions.scala:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.typed.state.exception
+
+import scala.util.control.NoStackTrace
+
+import org.apache.pekko
+import pekko.persistence.typed.state.internal.DurableStateStoreException
+
+/**
+ * Exception thrown when Durable State cannot be deleted because the revision
+ * is out of date (i.e. the state has a newer revision set).
+ *
+ * @param msg the exception message
+ * @since 1.1.0
+ */
+final class OutOfDateRevisionException(msg: String)

Review Comment:
   these are Exceptions and as such, the `getMessage()` API works



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1560844238


##########
persistence/src/main/scala/org/apache/pekko/persistence/OutOfDateRevisionException.scala:
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence

Review Comment:
   moved



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new durable state persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #1271:
URL: https://github.com/apache/pekko/pull/1271#issuecomment-2068162647

   > New change look great to me.
   > 
   > link validator failure because the logback apidocs path changed.
   
   Thanks @Roiocam. I made some extra changes. Could you have a look if you have time? @He-Pin would you have time to review the latest changes too?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new durable state persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1575251789


##########
persistence/src/main/scala/org/apache/pekko/persistence/state/exception/DurableStateException.scala:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.state.exception
+
+import scala.util.control.NoStackTrace
+
+/**
+ * Exception thrown when Durable State cannot be updated or deleted.
+ *
+ * @param msg the exception message
+ * @param cause the exception cause
+ * @since 1.1.0
+ */
+abstract class DurableStateException(msg: String, cause: Throwable)
+    extends RuntimeException(msg, cause) {

Review Comment:
   I agree that PersistenceException could be useful but I think we can wait till we have a definite use case for it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new durable state persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #1271:
URL: https://github.com/apache/pekko/pull/1271#issuecomment-2066144993

   @He-Pin @Roiocam @nvollmar would you be able to take a look?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #1271:
URL: https://github.com/apache/pekko/pull/1271#issuecomment-2048829060

   > The module `persistence` mostly declared data access related, Who will directly come into contact with these exceptions? is a user or the pekko developer? If it is a user, then these exceptions should be placed in `persistence-typed`.
   > 
   > If these exceptions will be used by `DurableStateBehavior`, it should extend from `DurableStateStoreException`
   > 
   > https://github.com/apache/pekko/blob/1f20fa4aba841365f3fe9021b6f2f767d0139ff0/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/internal/DurableStateBehaviorImpl.scala#L156
   
   DurableStateStoreException is for issues when saving state.
   
   https://github.com/apache/pekko/blob/1f20fa4aba841365f3fe9021b6f2f767d0139ff0/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/internal/DurableStateStoreException.scala#L29
   
   These new exceptions are for issues deleting state - see https://github.com/apache/pekko/discussions/1233#discussioncomment-8975620


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1559272214


##########
persistence/src/main/scala/org/apache/pekko/persistence/PersistenceException.scala:
##########
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence
+
+import scala.util.control.NoStackTrace
+
+import org.apache.pekko
+import pekko.PekkoException
+
+/**
+ * Base class for exceptions thrown by the persistence implementation.
+ *
+ * @param message the exception message
+ * @since 1.1.0
+ */
+abstract class PersistenceException(message: String)

Review Comment:
   Add @Donotinherent



##########
persistence/src/main/scala/org/apache/pekko/persistence/OutOfDateRevisionException.scala:
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence
+
+/**
+ * Exception thrown when Durable State cannot be deleted because the revision
+ * is out of date (i.e. the state has a newer revision set).
+ *
+ * @param message the exception message
+ * @since 1.1.0
+ */
+class OutOfDateRevisionException(message: String) extends PersistenceException(message)

Review Comment:
   final class



##########
persistence/src/main/scala/org/apache/pekko/persistence/UnknownRevisionException.scala:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence
+
+/**
+ * Exception thrown when Durable State cannot be deleted because the revision
+ * is unknown (i.e. the current revision is lower than the revision that we
+ * attempted to delete).
+ *
+ * @param message the exception message
+ * @since 1.1.0
+ */
+class UnknownRevisionException(message: String) extends PersistenceException(message)

Review Comment:
   final



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #1271:
URL: https://github.com/apache/pekko/pull/1271#issuecomment-2047947359

   > Does multiple files is need?
   
   Not sure , may be @pjfanning can elaborate ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1560376205


##########
persistence/src/main/scala/org/apache/pekko/persistence/OutOfDateRevisionException.scala:
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence
+
+/**
+ * Exception thrown when Durable State cannot be deleted because the revision
+ * is out of date (i.e. the state has a newer revision set).
+ *
+ * @param message the exception message
+ * @since 1.1.0
+ */
+class OutOfDateRevisionException(message: String) extends PersistenceException(message)

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1560842646


##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/exception/DurableStateStoreExceptions.scala:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.typed.state.exception
+
+import scala.util.control.NoStackTrace
+
+import org.apache.pekko
+import pekko.persistence.typed.state.internal.DurableStateStoreException
+
+/**
+ * Exception thrown when Durable State cannot be deleted because the revision
+ * is out of date (i.e. the state has a newer revision set).
+ *
+ * @param msg the exception message
+ * @since 1.1.0
+ */
+final class OutOfDateRevisionException(msg: String)

Review Comment:
   Should `msg` be a `val` so that users can access the value?



##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/exception/DurableStateStoreExceptions.scala:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.typed.state.exception
+
+import scala.util.control.NoStackTrace
+
+import org.apache.pekko
+import pekko.persistence.typed.state.internal.DurableStateStoreException
+
+/**
+ * Exception thrown when Durable State cannot be deleted because the revision
+ * is out of date (i.e. the state has a newer revision set).
+ *
+ * @param msg the exception message
+ * @since 1.1.0
+ */
+final class OutOfDateRevisionException(msg: String)
+    extends DurableStateStoreException(msg) with NoStackTrace
+
+/**
+ * Exception thrown when Durable State cannot be deleted because the revision
+ * is unknown (i.e. the current revision is lower than the revision that we
+ * attempted to delete).
+ *
+ * @param msg the exception message
+ * @since 1.1.0
+ */
+final class UnknownRevisionException(msg: String)

Review Comment:
   Same as https://github.com/apache/pekko/pull/1271/files#r1560842646



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new persistence exceptions [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1567200311


##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/exception/DurableStateStoreExceptions.scala:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.typed.state.exception

Review Comment:
   I'm travelling for a few days. Later this week, I will refactor this PR to try to move the new exceptions back to the main pekko-persistence lib instead of the typed one.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new durable state persistence exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1574094509


##########
persistence/src/test/scala/org/apache/pekko/persistence/state/exception/DurableStateExceptionsSpec.scala:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.state.exception
+
+import java.lang.invoke.{ MethodHandles, MethodType }
+
+import scala.util.Try
+import scala.util.control.NoStackTrace
+
+import org.scalatest.wordspec.AnyWordSpecLike
+import org.scalatest.matchers.should.Matchers
+
+/**
+ * Tests for [[DurableStateException]]s.
+ * <p>
+ *   To avoid making Pekko persistence implementations dependent on
+ *   Pekko v1.1, these exceptions will be created using MethodHandles.
+ * </p>
+ */
+class DurableStateExceptionsSpec extends AnyWordSpecLike
+    with Matchers {
+
+  private val methodHandleLookup = MethodHandles.publicLookup()
+
+  "DurableStateException support" must {
+    "allow creating DeleteRevisionException using MethodHandle" in {
+      val exceptionClassOpt: Option[Class[_]] = Try(Class.forName(
+        "org.apache.pekko.persistence.state.exception.DeleteRevisionException")).toOption
+      exceptionClassOpt should not be empty
+      val constructorOpt = exceptionClassOpt.map { clz =>
+        val mt = MethodType.methodType(classOf[Unit], classOf[String])
+        methodHandleLookup.findConstructor(clz, mt)
+      }
+      constructorOpt should not be empty
+      val constructor = constructorOpt.get
+      val ex = constructor.invoke("delete failed").asInstanceOf[Exception]
+      ex shouldBe an[DeleteRevisionException]
+      ex shouldBe an[NoStackTrace]
+      ex.getMessage shouldEqual "delete failed"
+    }

Review Comment:
   cool for test this.



##########
persistence/src/test/scala/org/apache/pekko/persistence/state/exception/DurableStateExceptionsSpec.scala:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.state.exception
+
+import java.lang.invoke.{ MethodHandles, MethodType }
+
+import scala.util.Try
+import scala.util.control.NoStackTrace
+
+import org.scalatest.wordspec.AnyWordSpecLike
+import org.scalatest.matchers.should.Matchers
+
+/**
+ * Tests for [[DurableStateException]]s.
+ * <p>
+ *   To avoid making Pekko persistence implementations dependent on
+ *   Pekko v1.1, these exceptions will be created using MethodHandles.
+ * </p>
+ */
+class DurableStateExceptionsSpec extends AnyWordSpecLike
+    with Matchers {
+
+  private val methodHandleLookup = MethodHandles.publicLookup()
+
+  "DurableStateException support" must {
+    "allow creating DeleteRevisionException using MethodHandle" in {
+      val exceptionClassOpt: Option[Class[_]] = Try(Class.forName(
+        "org.apache.pekko.persistence.state.exception.DeleteRevisionException")).toOption
+      exceptionClassOpt should not be empty
+      val constructorOpt = exceptionClassOpt.map { clz =>
+        val mt = MethodType.methodType(classOf[Unit], classOf[String])
+        methodHandleLookup.findConstructor(clz, mt)
+      }
+      constructorOpt should not be empty
+      val constructor = constructorOpt.get
+      val ex = constructor.invoke("delete failed").asInstanceOf[Exception]
+      ex shouldBe an[DeleteRevisionException]
+      ex shouldBe an[NoStackTrace]
+      ex.getMessage shouldEqual "delete failed"
+    }

Review Comment:
   cool for testing this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] new durable state persistence exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1271:
URL: https://github.com/apache/pekko/pull/1271#discussion_r1574096730


##########
persistence/src/main/scala/org/apache/pekko/persistence/state/exception/DurableStateException.scala:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pekko.persistence.state.exception
+
+import scala.util.control.NoStackTrace
+
+/**
+ * Exception thrown when Durable State cannot be updated or deleted.
+ *
+ * @param msg the exception message
+ * @param cause the exception cause
+ * @since 1.1.0
+ */
+abstract class DurableStateException(msg: String, cause: Throwable)
+    extends RuntimeException(msg, cause) {

Review Comment:
   Maybe `DurableStateException` can extend something like `PersistenceException`, but we may introduce that later.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org