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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git


The following commit(s) were added to refs/heads/master by this push:
     new 8149de04 Deprecate direct access to 
org.apache.commons.net.nntp.Article.kid and next fields
8149de04 is described below

commit 8149de0468689bd3449f49fd552a10d4d2b6cad3
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Thu Jun 20 19:18:23 2024 -0400

    Deprecate direct access to org.apache.commons.net.nntp.Article.kid and
    next fields
    
    - [ERROR] Medium: Primitive field
    org.apache.commons.net.nntp.Article.kid is public and set from inside
    the class, which makes it too exposed. Consider making it private to
    limit external accessibility. [org.apache.commons.net.nntp.Article] At
    Article.java:[line 64] PA_PUBLIC_PRIMITIVE_ATTRIBUTE
    - [ERROR] Medium: Primitive field
    org.apache.commons.net.nntp.Article.next is public and set from inside
    the class, which makes it too exposed. Consider making it private to
    limit external accessibility. [org.apache.commons.net.nntp.Article] At
    Article.java:[line 67] PA_PUBLIC_PRIMITIVE_ATTRIBUTE
---
 pom.xml                                            |  8 ++--
 src/changes/changes.xml                            |  6 ++-
 src/conf/findbugs-exclude-filter.xml               | 14 ++++++
 .../java/org/apache/commons/net/nntp/Article.java  | 50 ++++++++++++++++++----
 .../org/apache/commons/net/nntp/Threadable.java    | 11 +++--
 5 files changed, 70 insertions(+), 19 deletions(-)

diff --git a/pom.xml b/pom.xml
index 6d24636c..53525259 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
     <groupId>commons-net</groupId>
     <artifactId>commons-net</artifactId>
-    <version>3.11.2-SNAPSHOT</version>
+    <version>3.12.0-SNAPSHOT</version>
     <name>Apache Commons Net</name>
     <!-- N.B. the description content is deliberately not indented ! to 
improve the layout of the Release Notes generated 
         by mvn changes:announcement-generate -->
@@ -51,14 +51,14 @@ Supported protocols include Echo, Finger, FTP, NNTP, NTP, 
POP3(S), SMTP(S), Teln
         <checkstyle.configdir>src/conf</checkstyle.configdir>
         <spotbugs.configdir>src/conf</spotbugs.configdir>
         <!-- Current release -->
-        <commons.release.version>3.11.1</commons.release.version>
-        <commons.release.next>3.11.2</commons.release.next>
+        <commons.release.version>3.12.0</commons.release.version>
+        <commons.release.next>3.12.1</commons.release.next>
         <commons.rc.version>RC1</commons.rc.version>
         <commons.release.desc>(Requires Java ${maven.compiler.target} or 
later)</commons.release.desc>
         
<project.build.outputTimestamp>2024-06-10T18:44:36Z</project.build.outputTimestamp>
         <!-- Release plugin defines -->
         <!-- Previous version of the component (used for reporting binary 
compatibility check)-->
-        <commons.bc.version>3.11.0</commons.bc.version>
+        <commons.bc.version>3.11.1</commons.bc.version>
         <commons.release.isDistModule>true</commons.release.isDistModule>
         <!--
           Define the following in ~/.m2/settings.xml in an active profile:
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a61f934b..503cb4f8 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -64,7 +64,7 @@ The <action> type attribute can be add,update,fix,remove.
     -->
 
   <body>
-    <release version="3.11.2" date="YYYY-MM-DD" description="This is a feature 
and maintenance release. Java 8 or later is required.">
+    <release version="3.12.0" date="YYYY-MM-DD" description="This is a feature 
and maintenance release. Java 8 or later is required.">
       <!-- FIX -->
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Remove 
InvalidKeySpecException from AuthenticatingIMAPClient.auth(AUTH_METHOD, String, 
String) never throws, it's not thrown.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Remove 
InvalidKeySpecException from AuthenticatingIMAPClient.authenticate(AUTH_METHOD, 
String, String) never throws, it's not thrown.</action> 
@@ -77,8 +77,10 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix PMD 
UselessOverridingMethod in org.apache.commons.net.telnet.TelnetClient.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix PMD 
UnnecessaryModifier.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate 
MLSxEntryParser default constructor in favor of 
MLSxEntryParser.getInstance().</action>
-
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate direct 
access to org.apache.commons.net.nntp.Article.kid and next fields.</action>
       <!-- ADD -->
+      <action type="add" dev="ggregory" due-to="Gary 
Gregory">org.apache.commons.net.nntp.Article#getChild().</action>
+      <action type="add" dev="ggregory" due-to="Gary 
Gregory">org.apache.commons.net.nntp.Article#getNext().</action>
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Gary Gregory, 
Dependabot">Bump org.apache.commons:commons-parent from 70 to 71 #261.</action> 
     </release>
diff --git a/src/conf/findbugs-exclude-filter.xml 
b/src/conf/findbugs-exclude-filter.xml
index 144fb57c..7972911f 100644
--- a/src/conf/findbugs-exclude-filter.xml
+++ b/src/conf/findbugs-exclude-filter.xml
@@ -132,6 +132,20 @@
     <Bug pattern="NM_CLASS_NAMING_CONVENTION" />
   </Match>
 
+  <!-- Keep for binary compatibility -->
+  <Match>
+    <Class name="org.apache.commons.net.nntp.Article" />
+    <Field name="kid"/>
+    <Bug pattern="PA_PUBLIC_PRIMITIVE_ATTRIBUTE" />
+  </Match>
+
+  <!-- Keep for binary compatibility -->
+  <Match>
+    <Class name="org.apache.commons.net.nntp.Article" />
+    <Field name="next"/>
+    <Bug pattern="PA_PUBLIC_PRIMITIVE_ATTRIBUTE" />
+  </Match>
+
   <!-- Used externally -->
   <Match>
     <Class name="org.apache.commons.net.pop3.POP3MessageInfo" />
diff --git a/src/main/java/org/apache/commons/net/nntp/Article.java 
b/src/main/java/org/apache/commons/net/nntp/Article.java
index 3e3c688a..09a8f533 100644
--- a/src/main/java/org/apache/commons/net/nntp/Article.java
+++ b/src/main/java/org/apache/commons/net/nntp/Article.java
@@ -26,7 +26,7 @@ import org.apache.commons.net.util.NetConstants;
 /**
  * Basic state needed for message retrieval and threading. With thanks to 
Jamie Zawinski (j...@jwz.org)
  */
-public class Article implements Threadable {
+public class Article implements Threadable<Article> {
 
     /**
      * Recursive method that traverses a pre-threaded graph (or tree) of 
connected Article objects and prints them out.
@@ -92,7 +92,21 @@ public class Article implements Threadable {
 
     private boolean isReply;
 
-    public Article kid, next;
+    /**
+     * Will be private in 4.0.
+     *
+     * @deprecated Use {@link #setChild(Article)} and {@link #getChild()}.
+     */
+    @Deprecated
+    public Article kid;
+
+    /**
+     * Will be private in 4.0.
+     *
+     * @deprecated Use {@link #setNext(Article)} and {@link #getNext()}.
+     */
+    @Deprecated
+    public Article next;
 
     public Article() {
         articleNumber = -1; // isDummy
@@ -151,6 +165,16 @@ public class Article implements Threadable {
         return articleNumber;
     }
 
+    /**
+     * Gets the child article.
+     *
+     * @return the child article.
+     * @since 3.12.0
+     */
+    public Article getChild() {
+        return kid;
+    }
+
     /**
      * Gets the article date header.
      *
@@ -169,6 +193,16 @@ public class Article implements Threadable {
         return from;
     }
 
+    /**
+     * Gets the next article.
+     *
+     * @return the next article.
+     * @since 3.12.0
+     */
+    public Article getNext() {
+        return next;
+    }
+
     /**
      * Returns the MessageId references as an array of Strings
      *
@@ -196,7 +230,7 @@ public class Article implements Threadable {
     }
 
     @Override
-    public Threadable makeDummy() {
+    public Article makeDummy() {
         return new Article();
     }
 
@@ -234,8 +268,8 @@ public class Article implements Threadable {
     }
 
     @Override
-    public void setChild(final Threadable child) {
-        this.kid = (Article) child;
+    public void setChild(Article child) {
+        this.kid = child;
         flushSubjectCache();
     }
 
@@ -258,8 +292,8 @@ public class Article implements Threadable {
     }
 
     @Override
-    public void setNext(final Threadable next) {
-        this.next = (Article) next;
+    public void setNext(Article next) {
+        this.next = next;
         flushSubjectCache();
     }
 
@@ -280,8 +314,6 @@ public class Article implements Threadable {
         return simplifiedSubject;
     }
 
-    // DEPRECATED METHODS - for API compatibility only - DO NOT USE
-
     /**
      * Attempts to parse the subject line for some typical reply signatures, 
and strip them out
      */
diff --git a/src/main/java/org/apache/commons/net/nntp/Threadable.java 
b/src/main/java/org/apache/commons/net/nntp/Threadable.java
index f1f22c95..39cbdf8e 100644
--- a/src/main/java/org/apache/commons/net/nntp/Threadable.java
+++ b/src/main/java/org/apache/commons/net/nntp/Threadable.java
@@ -19,19 +19,22 @@ package org.apache.commons.net.nntp;
 
 /**
  * A placeholder interface for threadable message objects Author: Rory Winston 
(rwins...@checkfree.com)
+ *
+ * @param <T> The Threadable implementation.
  */
-public interface Threadable {
+public interface Threadable<T extends Threadable<T>> {
+
     boolean isDummy();
 
-    Threadable makeDummy();
+    T makeDummy();
 
     String messageThreadId();
 
     String[] messageThreadReferences();
 
-    void setChild(Threadable child);
+    void setChild(T child);
 
-    void setNext(Threadable next);
+    void setNext(T next);
 
     String simplifiedSubject();
 

Reply via email to