You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by ti...@apache.org on 2023/04/26 19:11:02 UTC

[db-jdo] branch main updated: JDO-823 - Make fields in JDOException final (#76)

This is an automated email from the ASF dual-hosted git repository.

tilmannz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/db-jdo.git


The following commit(s) were added to refs/heads/main by this push:
     new a4f02348 JDO-823 - Make fields in JDOException final (#76)
a4f02348 is described below

commit a4f02348e12186a23605f5197ae67b9b64cf7571
Author: Tobias Bouschen <to...@googlemail.com>
AuthorDate: Wed Apr 26 21:10:56 2023 +0200

    JDO-823 - Make fields in JDOException final (#76)
    
    Make all fields in JDOException final. Explicitly excludes
    'inPrintStackTrace' as it is needed for some state tracking. Makes it
    'transient' instead.
---
 api/src/main/java/javax/jdo/JDOException.java | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/api/src/main/java/javax/jdo/JDOException.java b/api/src/main/java/javax/jdo/JDOException.java
index fa6a1372..4be4962a 100644
--- a/api/src/main/java/javax/jdo/JDOException.java
+++ b/api/src/main/java/javax/jdo/JDOException.java
@@ -40,7 +40,7 @@ public class JDOException extends java.lang.RuntimeException {
    *
    * @serial the nested <code>Throwable</code> array
    */
-  Throwable[] nested;
+  final Throwable[] nested;
 
   /**
    * This exception may be the result of incorrect parameters supplied to an API. This is the object
@@ -48,16 +48,19 @@ public class JDOException extends java.lang.RuntimeException {
    *
    * @serial the failed <code>Object</code>
    */
-  transient Object failed;
+  final transient Object failed;
 
   /** The Internationalization message helper. */
   private static final I18NHelper MSG = I18NHelper.getInstance("javax.jdo.Bundle"); // NOI18N
 
   /** Flag indicating whether printStackTrace is being executed. */
-  private boolean inPrintStackTrace = false;
+  private transient boolean inPrintStackTrace = false;
 
   /** Constructs a new <code>JDOException</code> without a detail message. */
-  public JDOException() {}
+  public JDOException() {
+    this.nested = null;
+    this.failed = null;
+  }
 
   /**
    * Constructs a new <code>JDOException</code> with the specified detail message.
@@ -66,6 +69,8 @@ public class JDOException extends java.lang.RuntimeException {
    */
   public JDOException(String msg) {
     super(msg);
+    this.nested = null;
+    this.failed = null;
   }
 
   /**
@@ -78,6 +83,7 @@ public class JDOException extends java.lang.RuntimeException {
   public JDOException(String msg, Throwable[] nested) {
     super(msg);
     this.nested = nested;
+    this.failed = null;
   }
 
   /**
@@ -90,6 +96,7 @@ public class JDOException extends java.lang.RuntimeException {
   public JDOException(String msg, Throwable nested) {
     super(msg);
     this.nested = new Throwable[] {nested};
+    this.failed = null;
   }
 
   /**
@@ -100,6 +107,7 @@ public class JDOException extends java.lang.RuntimeException {
    */
   public JDOException(String msg, Object failed) {
     super(msg);
+    this.nested = null;
     this.failed = failed;
   }