You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gg...@apache.org on 2022/04/14 01:07:44 UTC

[mina-ftpserver] branch 1.2.X updated: [FTPSERVER-506] Fix binary compatibility issues.

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

ggregory pushed a commit to branch 1.2.X
in repository https://gitbox.apache.org/repos/asf/mina-ftpserver.git


The following commit(s) were added to refs/heads/1.2.X by this push:
     new e41fd329 [FTPSERVER-506] Fix binary compatibility issues.
e41fd329 is described below

commit e41fd329a79a146714623aba479a1eab68ba298b
Author: Gary Gregory <gg...@rocketsoftware.com>
AuthorDate: Wed Apr 13 21:07:39 2022 -0400

    [FTPSERVER-506] Fix binary compatibility issues.
    
    Pick 1.1.2 as the baseline for FTPSERVER-506 but it should be the
    previous version in more normal usage when you've been sure that binary
    compatibility has not been broken from release to release.
---
 .../org/apache/ftpserver/ssl/SslConfiguration.java |  8 +--
 .../ftpserver/ssl/SslConfigurationFactory.java     | 28 +++++++-
 .../ssl/impl/DefaultSslConfiguration.java          | 11 +++-
 .../org/apache/ftpserver/util/StringUtils.java     | 23 ++++---
 distribution/pom.xml                               |  1 +
 examples/ftpserver-example-spring-war/pom.xml      |  1 +
 examples/ftpserver-osgi-ftplet-service/pom.xml     |  1 +
 examples/ftpserver-osgi-spring-service/pom.xml     |  1 +
 examples/pom.xml                                   |  1 +
 pom.xml                                            | 74 +++++++++++++++++++++-
 10 files changed, 132 insertions(+), 17 deletions(-)

diff --git a/core/src/main/java/org/apache/ftpserver/ssl/SslConfiguration.java b/core/src/main/java/org/apache/ftpserver/ssl/SslConfiguration.java
index 1c646c30..ec3ad066 100644
--- a/core/src/main/java/org/apache/ftpserver/ssl/SslConfiguration.java
+++ b/core/src/main/java/org/apache/ftpserver/ssl/SslConfiguration.java
@@ -73,16 +73,16 @@ public interface SslConfiguration {
      * 
      * @return The name of the protocol as a String
      */
-    default String getEnabledProtocol() {
-        return DEFAULT_ENABLED_PROTOCOL;
-    }
+    String getEnabledProtocol();
 
     /**
      * Returns the list of ssl protocols
      * 
      * @return The list of enabled protocols as a String
      */
-    String[] getEnabledProtocols();
+	default String[] getEnabledProtocols() {
+		return new String[] { getEnabledProtocol() };
+	}
 
     /**
      * Return the required client authentication setting
diff --git a/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java b/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java
index 6ee613a0..97d0753a 100644
--- a/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java
+++ b/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java
@@ -157,11 +157,37 @@ public class SslConfigurationFactory {
      * The SSL protocol used for this channel. Supported values are "SSL" and "TLS". Defaults to "TLS".
      * 
      * @return The SSL protocol
+     * @deprecated Use {@link #getSslProtocols()}.
+     */
+    @Deprecated
+    public String getSslProtocol() {
+        return sslProtocols[0];
+    }
+
+    /**
+     * The SSL protocols used for this channel. Supported values are "SSL" and "TLS". Defaults to "TLS".
+     * 
+     * @return The SSL protocol
      */
     public String[] getSslProtocols() {
-	return sslProtocols;
+        return sslProtocols;
     }
 
+    /**
+     * Set the SSL protocols used for this channel. Defaults to "TLSv1.2".
+     * 
+     * @param sslProtocols
+     *            The SSL protocols
+     * @deprecated Use {@link #setSslProtocol(String...)}.
+     */
+	public void setSslProtocol(String sslProtocols) {
+		if (sslProtocols == null) {
+			throw new FtpServerConfigurationException("SslProcotol must not be null");
+		}
+
+		this.sslProtocols = new String[] { sslProtocols };
+	}
+
     /**
      * Set the SSL protocols used for this channel. Defaults to "TLSv1.2".
      * 
diff --git a/core/src/main/java/org/apache/ftpserver/ssl/impl/DefaultSslConfiguration.java b/core/src/main/java/org/apache/ftpserver/ssl/impl/DefaultSslConfiguration.java
index 019170c3..f4266a95 100644
--- a/core/src/main/java/org/apache/ftpserver/ssl/impl/DefaultSslConfiguration.java
+++ b/core/src/main/java/org/apache/ftpserver/ssl/impl/DefaultSslConfiguration.java
@@ -109,9 +109,18 @@ public class DefaultSslConfiguration implements SslConfiguration {
 
     /**
      * @see SslConfiguration#getEnabledProtocol()
+     *
+     * @deprecated Use {@link #getEnabledProtocol()}
      */
     public String getEnabledProtoco() {
-        if ((enabledProtocols != null) && (enabledProtocols.length > 0)) {
+        return getEnabledProtocol();
+    }
+
+    /**
+     * @see SslConfiguration#getEnabledProtocol()
+     */
+    public String getEnabledProtocol() {
+        if (enabledProtocols != null && enabledProtocols.length > 0) {
             // We use the first one
             return enabledProtocols[0];
         } else {
diff --git a/core/src/main/java/org/apache/ftpserver/util/StringUtils.java b/core/src/main/java/org/apache/ftpserver/util/StringUtils.java
index 7bba65dc..a618ed7c 100644
--- a/core/src/main/java/org/apache/ftpserver/util/StringUtils.java
+++ b/core/src/main/java/org/apache/ftpserver/util/StringUtils.java
@@ -28,8 +28,13 @@ import java.util.Map;
  *
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public final class StringUtils {
-    private StringUtils() {
+public class StringUtils {
+	
+	/**
+	 * @deprecated Do not instantiate.
+	 */
+	@Deprecated
+    public StringUtils() {
         // Nothing to do
     }
 
@@ -41,7 +46,7 @@ public final class StringUtils {
      * @param newStr The replacement string
      * @return The modified string
      */
-    public static String replaceString(String source, String oldStr,
+    public static final String replaceString(String source, String oldStr,
             String newStr) {
         StringBuilder sb = new StringBuilder(source.length());
         int sind = 0;
@@ -68,7 +73,7 @@ public final class StringUtils {
      * the original string
      * @return The modified string
      */
-    public static String replaceString(String source, Object[] args) {
+    public static final String replaceString(String source, Object[] args) {
         int startIndex = 0;
         int openIndex = source.indexOf('{', startIndex);
         if (openIndex == -1) {
@@ -117,7 +122,7 @@ public final class StringUtils {
      * the original string
      * @return The modified string
      */
-    public static String replaceString(String source,
+    public static final String replaceString(String source,
             Map<String, Object> args) {
         int startIndex = 0;
         int openIndex = source.indexOf('{', startIndex);
@@ -165,7 +170,7 @@ public final class StringUtils {
      *                          '>' will be replaced by &gt;
      * @param bReplaceQuote if true '\"' will be replaced by &quot;
      */
-    public static String formatHtml(String source, boolean bReplaceNl,
+    public static final String formatHtml(String source, boolean bReplaceNl,
             boolean bReplaceTag, boolean bReplaceQuote) {
 
         StringBuilder sb = new StringBuilder();
@@ -231,7 +236,7 @@ public final class StringUtils {
     /**
      * Pad string object.
      */
-    public static String pad(String src, char padChar, boolean rightPad,
+    public static final String pad(String src, char padChar, boolean rightPad,
             int totalLength) {
 
         int srcLength = src.length();
@@ -255,7 +260,7 @@ public final class StringUtils {
     /**
      * Get hex string from byte array.
      */
-    public static String toHexString(byte[] res) {
+    public static final String toHexString(byte[] res) {
         StringBuilder sb = new StringBuilder(res.length << 1);
         for (int i = 0; i < res.length; i++) {
             String digit = Integer.toHexString(0xFF & res[i]);
@@ -270,7 +275,7 @@ public final class StringUtils {
     /**
      * Get byte array from hex string.
      */
-    public static byte[] toByteArray(String hexString) {
+    public static final byte[] toByteArray(String hexString) {
         int arrLength = hexString.length() >> 1;
         byte buff[] = new byte[arrLength];
         for (int i = 0; i < arrLength; i++) {
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 4f3f0f9d..dbf10d21 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -25,6 +25,7 @@
 
   <properties>
     <checkstyle.configdir>..</checkstyle.configdir>
+    <japicmp.skip>true</japicmp.skip>
   </properties>
 
   <build>
diff --git a/examples/ftpserver-example-spring-war/pom.xml b/examples/ftpserver-example-spring-war/pom.xml
index ac92b112..2aa457df 100644
--- a/examples/ftpserver-example-spring-war/pom.xml
+++ b/examples/ftpserver-example-spring-war/pom.xml
@@ -26,6 +26,7 @@
 
   <properties>
     <checkstyle.configdir>${basedir}/../..</checkstyle.configdir>
+    <japicmp.skip>true</japicmp.skip>
   </properties>
 
   <dependencies>
diff --git a/examples/ftpserver-osgi-ftplet-service/pom.xml b/examples/ftpserver-osgi-ftplet-service/pom.xml
index 14d442f4..8d1c8de3 100644
--- a/examples/ftpserver-osgi-ftplet-service/pom.xml
+++ b/examples/ftpserver-osgi-ftplet-service/pom.xml
@@ -30,6 +30,7 @@
 
   <properties>
     <checkstyle.configdir>../..</checkstyle.configdir>
+    <japicmp.skip>true</japicmp.skip>
   </properties>
 
   <dependencies>
diff --git a/examples/ftpserver-osgi-spring-service/pom.xml b/examples/ftpserver-osgi-spring-service/pom.xml
index 0eada184..b31f2a9f 100644
--- a/examples/ftpserver-osgi-spring-service/pom.xml
+++ b/examples/ftpserver-osgi-spring-service/pom.xml
@@ -30,6 +30,7 @@
 
   <properties>
     <checkstyle.configdir>${basedir}/../..</checkstyle.configdir>
+    <japicmp.skip>true</japicmp.skip>
   </properties>
 
   <dependencies>
diff --git a/examples/pom.xml b/examples/pom.xml
index 2f05b47f..1987624e 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -35,6 +35,7 @@
 
   <properties>
     <checkstyle.configdir>..</checkstyle.configdir>
+    <japicmp.skip>true</japicmp.skip>
   </properties>
 
 </project>
diff --git a/pom.xml b/pom.xml
index c7c5fe8c..4b06f134 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,6 +41,7 @@
   </licenses>
 
   <!-- Temporary add snapshot repository here to be able to resolve snapshot parent pom -->
+  <!--
   <repositories>
     <repository>
       <id>apache.snapshots</id>
@@ -51,7 +52,8 @@
       </releases>
     </repository>
   </repositories>
-
+  -->
+  
   <mailingLists>
     <mailingList>
       <name>FtpServer Users mailing list</name>
@@ -271,7 +273,7 @@
   </dependencyManagement>
 
   <build>
-    <defaultGoal>clean verify</defaultGoal>
+    <defaultGoal>clean verify japicmp:cmp</defaultGoal>
     <pluginManagement>
       <plugins>
         <plugin>
@@ -359,6 +361,50 @@
             </dependency>
           </dependencies>
         </plugin>
+        
+        <plugin>
+          <groupId>com.github.siom79.japicmp</groupId>
+          <artifactId>japicmp-maven-plugin</artifactId>
+          <version>0.15.7</version>
+          <configuration>
+            <oldVersion>
+              <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>${project.artifactId}</artifactId>
+                <!-- 
+                Pick 1.1.2 for FTPSERVER-506 but it should be the previous version in more normal usage
+                when you've been sure that binary compatibility has not been broken from release to release. 
+                -->
+                <version>1.1.2</version>
+                <type>jar</type>
+             </dependency>
+            </oldVersion>
+            <newVersion>
+              <file>
+                <path>${project.build.directory}/${project.artifactId}-${project.version}.jar</path>
+              </file>
+            </newVersion>
+            <parameter>
+              <onlyModified>true</onlyModified>
+              <breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
+              <breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
+              <!-- skip japicmp on "mvn site" - use "mvn package site" to include report -->
+              <ignoreMissingNewVersion>true</ignoreMissingNewVersion>
+              <reportOnlyFilename>true</reportOnlyFilename>
+              <skipPomModules>true</skipPomModules>
+              <ignoreMissingClasses>false</ignoreMissingClasses>
+              <overrideCompatibilityChangeParameters>
+                <overrideCompatibilityChangeParameter>
+                  <compatibilityChange>METHOD_NEW_DEFAULT</compatibilityChange>
+                  <binaryCompatible>true</binaryCompatible>
+                  <sourceCompatible>true</sourceCompatible>
+                  <semanticVersionLevel>PATCH</semanticVersionLevel>
+                </overrideCompatibilityChangeParameter>
+              </overrideCompatibilityChangeParameters>
+            </parameter>
+          </configuration>
+        </plugin>
+
       </plugins>
     </pluginManagement>
 
@@ -565,6 +611,30 @@
         </plugins>
       </build>
     </profile>
+    <profile>
+      <id>japicmp</id>
+      <activation>
+        <property>
+          <name>enforce.japicmp</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>com.github.siom79.japicmp</groupId>
+            <artifactId>japicmp-maven-plugin</artifactId>
+            <executions>
+              <execution>
+                <phase>verify</phase>
+                <goals>
+                  <goal>cmp</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>    
   </profiles>
 
   <modules>