You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@causeway.apache.org by "danhaywood (via GitHub)" <gi...@apache.org> on 2023/09/26 14:20:38 UTC

[GitHub] [causeway] danhaywood opened a new pull request, #1902: CAUSEWAY-3605: also adds handling on calling side

danhaywood opened a new pull request, #1902:
URL: https://github.com/apache/causeway/pull/1902

   (no comment)


-- 
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: dev-unsubscribe@causeway.apache.org

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


[GitHub] [causeway] danhaywood closed pull request #1902: CAUSEWAY-3605: also adds handling on calling side

Posted by "danhaywood (via GitHub)" <gi...@apache.org>.
danhaywood closed pull request #1902: CAUSEWAY-3605: also adds handling on calling side
URL: https://github.com/apache/causeway/pull/1902


-- 
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: dev-unsubscribe@causeway.apache.org

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


[GitHub] [causeway] andi-huber commented on a diff in pull request #1902: CAUSEWAY-3605: also adds handling on calling side

Posted by "andi-huber (via GitHub)" <gi...@apache.org>.
andi-huber commented on code in PR #1902:
URL: https://github.com/apache/causeway/pull/1902#discussion_r1337319911


##########
persistence/jdo/datanucleus/src/main/java/org/apache/causeway/persistence/jdo/datanucleus/entities/DnStateManagerForHollow.java:
##########
@@ -224,49 +224,56 @@ public DnStateManagerForHollow(final @NonNull String oidStringified) {
     @Override public void checkInheritance(final FieldValues fv) { }
     @Override public void markFieldsAsLoaded(final int[] fieldNumbers) { }
 
-    private final static String INVALID_FIELD_ACCESS_MSG =
-            "JDO entity %s is in HOLLOW state, its fields are no longer valid.";
-
     @Override public boolean getBooleanField(final Persistable pc, final int field, final boolean currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public char getCharField(final Persistable pc, final int field, final char currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public byte getByteField(final Persistable pc, final int field, final byte currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public short getShortField(final Persistable pc, final int field, final short currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public int getIntField(final Persistable pc, final int field, final int currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public long getLongField(final Persistable pc, final int field, final long currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public float getFloatField(final Persistable pc, final int field, final float currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public double getDoubleField(final Persistable pc, final int field, final double currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public String getStringField(final Persistable pc, final int field, final String currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
         //return null; // mimics behavior as if there was no StateManager
     }
 
     @Override public Object getObjectField(final Persistable pc, final int field, final Object currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
         //return null; // mimics behavior as if there was no StateManager
     }
 
+    /**
+     * The exception message will indicate only the Oid of the entity; we don't attempt pass the entity itself because
+     * this would trigger <code>toString()</code> on it, likely to cause a stack overflow.
+     */
+    private static RuntimeException unrecoverable(Persistable pc) {
+        return _Exceptions.unrecoverable(
+                "JDO entity %s is in HOLLOW state, its fields are no longer valid.",
+                DnOidStoreAndRecoverHelper.forEntity(pc).recoverOid().orElse(pc.getClass().getSimpleName() + " (with no OID)"));

Review Comment:
   I've pushed a side-effect free variant of this to master.



-- 
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: dev-unsubscribe@causeway.apache.org

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


[GitHub] [causeway] andi-huber commented on a diff in pull request #1902: CAUSEWAY-3605: also adds handling on calling side

Posted by "andi-huber (via GitHub)" <gi...@apache.org>.
andi-huber commented on code in PR #1902:
URL: https://github.com/apache/causeway/pull/1902#discussion_r1337319911


##########
persistence/jdo/datanucleus/src/main/java/org/apache/causeway/persistence/jdo/datanucleus/entities/DnStateManagerForHollow.java:
##########
@@ -224,49 +224,56 @@ public DnStateManagerForHollow(final @NonNull String oidStringified) {
     @Override public void checkInheritance(final FieldValues fv) { }
     @Override public void markFieldsAsLoaded(final int[] fieldNumbers) { }
 
-    private final static String INVALID_FIELD_ACCESS_MSG =
-            "JDO entity %s is in HOLLOW state, its fields are no longer valid.";
-
     @Override public boolean getBooleanField(final Persistable pc, final int field, final boolean currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public char getCharField(final Persistable pc, final int field, final char currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public byte getByteField(final Persistable pc, final int field, final byte currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public short getShortField(final Persistable pc, final int field, final short currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public int getIntField(final Persistable pc, final int field, final int currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public long getLongField(final Persistable pc, final int field, final long currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public float getFloatField(final Persistable pc, final int field, final float currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public double getDoubleField(final Persistable pc, final int field, final double currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
     }
 
     @Override public String getStringField(final Persistable pc, final int field, final String currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
         //return null; // mimics behavior as if there was no StateManager
     }
 
     @Override public Object getObjectField(final Persistable pc, final int field, final Object currentValue) {
-        throw _Exceptions.unrecoverable(INVALID_FIELD_ACCESS_MSG, pc);
+        throw unrecoverable(pc);
         //return null; // mimics behavior as if there was no StateManager
     }
 
+    /**
+     * The exception message will indicate only the Oid of the entity; we don't attempt pass the entity itself because
+     * this would trigger <code>toString()</code> on it, likely to cause a stack overflow.
+     */
+    private static RuntimeException unrecoverable(Persistable pc) {
+        return _Exceptions.unrecoverable(
+                "JDO entity %s is in HOLLOW state, its fields are no longer valid.",
+                DnOidStoreAndRecoverHelper.forEntity(pc).recoverOid().orElse(pc.getClass().getSimpleName() + " (with no OID)"));

Review Comment:
   I've pushed a simpler variant of this to master.



-- 
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: dev-unsubscribe@causeway.apache.org

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