From 8b0248c34618f31f313e99d725ccc03790b16cbb Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 15 Feb 2021 13:03:30 +0100 Subject: [PATCH 1/2] Bump Mockito to 3.7.7 --- build.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 47e5e334e..e861087b2 100644 --- a/build.gradle +++ b/build.gradle @@ -152,6 +152,7 @@ allprojects { commonsIoVersion = '2.6' bouncyCastleVersion = '1.68' guavaVersion = '30.1-jre' + mockitoVersion = '3.7.7' if (project.hasProperty("useSonatype")) { useSonatype = project.getProperty("useSonatype").toBoolean() @@ -312,10 +313,10 @@ tasks.withType(Javadoc) { // The smack-extensions subproject uses mockito in its fest // fixtures, and we want to have mockito also available in // test, so we use API here. - testFixturesApi "org.mockito:mockito-core:3.3.3" + testFixturesApi "org.mockito:mockito-core:${mockitoVersion}" // To mock final classes - testImplementation 'org.mockito:mockito-inline:3.3.3' + testImplementation "org.mockito:mockito-inline:${mockitoVersion}" testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2' errorprone 'com.google.errorprone:error_prone_core:2.5.1' From 4e90db31911ea1ded4baea1830d373413f1cb12f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 14 Feb 2021 20:34:48 +0100 Subject: [PATCH 2/2] [gitlab-ci] Also check with Java 15 --- .github/workflows/ci.yml | 1 + build.gradle | 23 ++++++++++++------- .../android/ServerPingWithAlarmManager.java | 11 +++++++++ .../android/AndroidSmackInitializer.java | 6 ++--- .../android/AndroidBase64Encoder.java | 11 ++++----- .../android/AndroidBase64UrlSafeEncoder.java | 15 +++++++----- .../debugger/android/AndroidDebugger.java | 7 +++++- .../org/jivesoftware/smackx/pubsub/Item.java | 8 +++++-- .../smackx/pubsub/PayloadItem.java | 9 ++++++-- 9 files changed, 63 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c82e759c2..a38b26f4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,7 @@ jobs: matrix: java: - 11 + - 15 steps: - name: Checkout diff --git a/build.gradle b/build.gradle index e861087b2..de0d5323f 100644 --- a/build.gradle +++ b/build.gradle @@ -256,7 +256,7 @@ allprojects { } jacoco { - toolVersion = "0.8.3" + toolVersion = "0.8.6" } jacocoTestReport { @@ -274,7 +274,10 @@ allprojects { // since the one paramater addStringOption doesn't seem to // work, we extra add '-quiet', which is added anyway by // gradle. - options.addStringOption('Xdoclint:all', '-quiet') + // TODO: This enables all doclint check but + // 'missing'. Re-enable 'missing' once every public API in + // Smack has a javadoc comment. + options.addStringOption('Xdoclint:accessibility,html,reference,syntax', '-quiet') // Treat warnings as errors. // See also https://bugs.openjdk.java.net/browse/JDK-8200363 @@ -286,12 +289,16 @@ allprojects { tasks.withType(Javadoc) { options.addStringOption('-release', javaMajor) - // Fix for javadoc search. If not set, the search result would direct to - // javadoc/undefined/org/jivesoftware/smack/altconnections/HttpLookupMethod.html - // instead of - // javadoc/org/jivesoftware/smack/altconnections/HttpLookupMethod.html - // https://stackoverflow.com/a/53732633/194894 - options.addBooleanOption("-no-module-directories", true) + // The -no-modules-directories javadoc option was removed in Java 13 + // See https://bugs.openjdk.java.net/browse/JDK-8215582 + if (JavaVersion.current() < JavaVersion.VERSION_13) { + // Fix for javadoc search. If not set, the search result would direct to + // javadoc/undefined/org/jivesoftware/smack/altconnections/HttpLookupMethod.html + // instead of + // javadoc/org/jivesoftware/smack/altconnections/HttpLookupMethod.html + // https://stackoverflow.com/a/53732633/194894 + options.addBooleanOption("-no-module-directories", true) + } } tasks.withType(JavaCompile) { options.compilerArgs.addAll([ diff --git a/smack-android-extensions/src/main/java/org/jivesoftware/smackx/ping/android/ServerPingWithAlarmManager.java b/smack-android-extensions/src/main/java/org/jivesoftware/smackx/ping/android/ServerPingWithAlarmManager.java index 1d7e6b826..a81f51ade 100644 --- a/smack-android-extensions/src/main/java/org/jivesoftware/smackx/ping/android/ServerPingWithAlarmManager.java +++ b/smack-android-extensions/src/main/java/org/jivesoftware/smackx/ping/android/ServerPingWithAlarmManager.java @@ -79,6 +79,12 @@ public final class ServerPingWithAlarmManager extends Manager { }); } + /** + * Get the instance of this manager for the given connection. + * + * @param connection the connection. + * @return the instance of this manager for the given connection. + */ public static synchronized ServerPingWithAlarmManager getInstanceFor(XMPPConnection connection) { ServerPingWithAlarmManager serverPingWithAlarmManager = INSTANCES.get(connection); if (serverPingWithAlarmManager == null) { @@ -104,6 +110,11 @@ public final class ServerPingWithAlarmManager extends Manager { mEnabled = enabled; } + /** + * Check if this manager is enabled. + * + * @return true if this manager is enabled, false otherwise. + */ public boolean isEnabled() { return mEnabled; } diff --git a/smack-android/src/main/java/org/jivesoftware/smack/android/AndroidSmackInitializer.java b/smack-android/src/main/java/org/jivesoftware/smack/android/AndroidSmackInitializer.java index 81a228ce0..a34fb1776 100644 --- a/smack-android/src/main/java/org/jivesoftware/smack/android/AndroidSmackInitializer.java +++ b/smack-android/src/main/java/org/jivesoftware/smack/android/AndroidSmackInitializer.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2014-2018 Florian Schmaus + * Copyright © 2014-2021 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,8 +39,8 @@ public class AndroidSmackInitializer implements SmackInitializer { @Override public List initialize() { SmackConfiguration.setDefaultHostnameVerifier(new StrictHostnameVerifier()); - Base64.setEncoder(AndroidBase64Encoder.getInstance()); - Base64UrlSafeEncoder.setEncoder(AndroidBase64UrlSafeEncoder.getInstance()); + Base64.setEncoder(AndroidBase64Encoder.INSTANCE); + Base64UrlSafeEncoder.setEncoder(AndroidBase64UrlSafeEncoder.INSTANCE); return null; } diff --git a/smack-android/src/main/java/org/jivesoftware/smack/util/stringencoder/android/AndroidBase64Encoder.java b/smack-android/src/main/java/org/jivesoftware/smack/util/stringencoder/android/AndroidBase64Encoder.java index 8e4d47d6c..6ae2cfb6b 100644 --- a/smack-android/src/main/java/org/jivesoftware/smack/util/stringencoder/android/AndroidBase64Encoder.java +++ b/smack-android/src/main/java/org/jivesoftware/smack/util/stringencoder/android/AndroidBase64Encoder.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2014-2019 Florian Schmaus + * Copyright © 2014-2021 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,10 @@ import android.util.Base64; */ public final class AndroidBase64Encoder implements org.jivesoftware.smack.util.stringencoder.Base64.Encoder { - private static AndroidBase64Encoder instance = new AndroidBase64Encoder(); + /** + * An instance of this encoder. + */ + public static AndroidBase64Encoder INSTANCE = new AndroidBase64Encoder(); private static final int BASE64_ENCODER_FLAGS = Base64.NO_WRAP; @@ -32,10 +35,6 @@ public final class AndroidBase64Encoder implements org.jivesoftware.smack.util.s // Use getInstance() } - public static AndroidBase64Encoder getInstance() { - return instance; - } - @Override public byte[] decode(String string) { return Base64.decode(string, Base64.DEFAULT); diff --git a/smack-android/src/main/java/org/jivesoftware/smack/util/stringencoder/android/AndroidBase64UrlSafeEncoder.java b/smack-android/src/main/java/org/jivesoftware/smack/util/stringencoder/android/AndroidBase64UrlSafeEncoder.java index b83d3014d..70c144e66 100644 --- a/smack-android/src/main/java/org/jivesoftware/smack/util/stringencoder/android/AndroidBase64UrlSafeEncoder.java +++ b/smack-android/src/main/java/org/jivesoftware/smack/util/stringencoder/android/AndroidBase64UrlSafeEncoder.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2014-2019 Florian Schmaus + * Copyright © 2014-2021 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,16 @@ import org.jivesoftware.smack.util.stringencoder.StringEncoder; import android.util.Base64; +/** + * An URL-safe Base64 encoder. + * @author Florian Schmaus + */ public final class AndroidBase64UrlSafeEncoder implements StringEncoder { - private static AndroidBase64UrlSafeEncoder instance = new AndroidBase64UrlSafeEncoder(); + /** + * An instance of this encoder. + */ + public static AndroidBase64UrlSafeEncoder INSTANCE = new AndroidBase64UrlSafeEncoder(); private static final int BASE64_ENCODER_FLAGS = Base64.URL_SAFE | Base64.NO_WRAP; @@ -32,10 +39,6 @@ public final class AndroidBase64UrlSafeEncoder implements StringEncoder // Use getInstance() } - public static AndroidBase64UrlSafeEncoder getInstance() { - return instance; - } - @Override public String encode(String string) { return Base64.encodeToString(string.getBytes(StandardCharsets.UTF_8), BASE64_ENCODER_FLAGS); diff --git a/smack-android/src/main/java/org/jivesoftware/smackx/debugger/android/AndroidDebugger.java b/smack-android/src/main/java/org/jivesoftware/smackx/debugger/android/AndroidDebugger.java index c1a355def..068dab202 100644 --- a/smack-android/src/main/java/org/jivesoftware/smackx/debugger/android/AndroidDebugger.java +++ b/smack-android/src/main/java/org/jivesoftware/smackx/debugger/android/AndroidDebugger.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2014-2017 Florian Schmaus + * Copyright © 2014-2021 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,11 @@ import android.util.Log; */ public class AndroidDebugger extends AbstractDebugger { + /** + * Constructs a new Smack debugger for Android. + * + * @param connection the connection to debug. + */ public AndroidDebugger(XMPPConnection connection) { super(connection); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java index 0cb4db2e3..571bb10d6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java @@ -27,7 +27,9 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider; * PubSub node. An Item has several properties that are dependent * on the configuration of the node to which it has been or will be published. * - *

An Item received from a node (via {@link LeafNode#getItems()} or {@link LeafNode#addItemEventListener(org.jivesoftware.smackx.pubsub.listener.ItemEventListener)}

+ *

+ * An Item received from a node (via {@link LeafNode#getItems()} or {@link LeafNode#addItemEventListener(org.jivesoftware.smackx.pubsub.listener.ItemEventListener)} + *

*
    *
  • Will always have an id (either user or server generated) unless node configuration has both * {@link ConfigureForm#isPersistItems()} and {@link ConfigureForm#isDeliverPayloads()}set to false. @@ -35,7 +37,9 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider; * to true, otherwise it will be null. *
* - *

An Item created to send to a node (via {@link LeafNode#publish()} or {@link LeafNode#publish()}

+ *

+ * An Item created to send to a node (via {@link LeafNode#publish()} or {@link LeafNode#publish()} + *

*
    *
  • The id is optional, since the server will generate one if necessary, but should be used if it is * meaningful in the context of the node. This value must be unique within the node that it is sent to, since diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java index 6cb4210d8..94462de7c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java @@ -28,7 +28,9 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider; * pubsub node. An Item has several properties that are dependent * on the configuration of the node to which it has been or will be published. * - *

    An Item received from a node (via {@link LeafNode#getItems()} or {@link LeafNode#addItemEventListener(org.jivesoftware.smackx.pubsub.listener.ItemEventListener)}

    + *

    + * An Item received from a node (via {@link LeafNode#getItems()} or {@link LeafNode#addItemEventListener(org.jivesoftware.smackx.pubsub.listener.ItemEventListener)} + *

    *
      *
    • Will always have an id (either user or server generated) unless node configuration has both * {@link ConfigureForm#isPersistItems()} and {@link ConfigureForm#isDeliverPayloads()}set to false.
    • @@ -36,7 +38,9 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider; * to true, otherwise it will be null. *
    * - *

    An Item created to send to a node (via {@link LeafNode#publish()}

    + *

    + * An Item created to send to a node (via {@link LeafNode#publish()} + *

    *
      *
    • The id is optional, since the server will generate one if necessary, but should be used if it is * meaningful in the context of the node. This value must be unique within the node that it is sent to, since @@ -45,6 +49,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider; * to true.
    • *
    * + * *

    To customise the payload object being returned from the {@link #getPayload()} method, you can * add a custom parser as explained in {@link ItemProvider}.

    *